[Tutor] (OT) Flame wars

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Mon Nov 6 23:28:30 CET 2006


> Wow... I had to click this e-mail just because I saw the first posts on the
> mentioned thread and could see it turning for the worst..

Hi everyone,

So let's try to squash this one now.  There are more interesting problems 
to solve.  Or other flame wars to fight.


Let me see if we can do something constructive.  I've been doing a 
shallow, superficial study of the Ruby language at the moment.  One of the 
things I've been impressed about is that they've managed to make lambdas 
look non-threatening to people with their syntactic sugar of "code 
blocks".

For example,

## Ruby #####################
def twice
     yield
     yield
twice { puts "hello world" }
#############################

This prints out "hello world" twice in a row: the twice() function takes 
in an implicit "code block", which it can later call by using their 
'yield' statement.  What the Ruby folks are doing is trying to make the 
use of higher-order procedures look really simple.  In fact, most of the 
encouraged idiom style I've seen so far extensively uses this code style 
pervasively (especially for iteration), and that's very admirable.


The exact functionality can be done in Python, but it does look a little 
more intimidating at first:

     ## Python
     def twice(f):
         f()
         f()
     twice(lambda: sys.stdout.write("hello world\n"))

This does the same thing, but it looks a little scarier because the 
concepts needed to grasp his are superficially harder than that in the 
Ruby code.


Anyway, let's derail off this regex flamewar and get us back to talking 
about code and about stuff that actually matters, like learning how to use 
functions well.. *wink*


More information about the Tutor mailing list