Sunday, May 26, 2013

Buddha would have coded in Java, Python, Ruby, Scala or Groovy?

From the (very nice) presentation of REXML I read:

in Java:
for (Enumeration e=parent.getChildren(); e.hasMoreElements(); ) { 
  Element child = (Element)e.nextElement(); // Do something with child 
}


in Ruby:
parent.each_child{ |child| # Do something with child }

Then he says: Can't you feel the peace and contentment in this block of code? Ruby is the language Buddha would have programmed in.
However, in groovy:
parent.each {
 // do something with "it", process(it) 
}

or
parent.each { child ->
 // do something with child
}

in Scala:
parent.foreach ( thing =>
 // do somthing with thing
)

in python:
for child in parent:
   # do stuff with child


So, all in all if I were Buddha (in common we have only a large belly) I would have coded in Python
Keep it Simple, Luke!

No comments: