http://www.perlmonks.org?node_id=971521


in reply to Ruby vs Perl vs LISP; the killer feature lacking in Ruby

To make a more compelling case that "Ruby destroys flow", you need to analyse some specific code examples.

To give an illustrative example, in this Builder AU interview, Damian Conway analyses a Java program that prints "Hello World":

Programming in Java always feels like a chore to me, because the language so often gets in the way of the problem you're trying to solve. The cliched example is, of course, the well-known exercise of getting a language to print "Hello World". In Java, that's:

class HelloWorldApp { public static void main(String[] args) { System.out.println("Hello World!"); } }
It's a cheap shot to point out how syntactically overburdened that is, but it does illustrate a far more important point: that it's *cognitively* over-burdened too.

To get the job done (i.e. print out a simple greeting), the Java programmer needs to understand the concept of classes, Java's particular class mechanisms and class declaration syntax, the concept of methods, Java's method syntax, the general concept of types, the specific concept of a void type, the concept of parameters and return types, Java's type and parameter syntaxes, the concept of arrays and Java's array declaration syntax, the concept of static methods, the concept of public class members, the concept of -- and Java syntax for -- method calls, the notion that method calls can return other objects which can then have method calls applied to them, the concept of class methods, the notion of a System class aggregating all system interactions, the concept of an I/O class mediating input and output, and the fact that "println" is an abbreviation for "print line".

And *then* you can print "Hello World".

Replies are listed 'Best First'.
Re^2: Ruby vs Perl vs LISP; the killer feature lacking in Ruby
by tobyink (Canon) on May 21, 2012 at 00:14 UTC

    That can be golfed down to just 80 characters.

    class H{public static void main(String[]a){System.out.println("Hello W +orld!");}}

    In Perl there's of course the 21 character solution, which can be reduced to 19 if STDERR is allowed.

    In PHP there's a 13 character solution.

    (I'm assuming that in all cases, "!\n" is required at the end.)

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'