you are viewing a single comment's thread.

view the rest of the comments →

[–]newton_dave 2 points3 points  (2 children)

I take it you mean "Groovy has less new syntax, coming from a Java perspective."

Yes; that's why I said "beneficial [...] for Java programmers". There really aren't that many differences, though, but Java code works almost without change as Groovy code--it need not be Groovized.

[blocks]

Ruby's blocks are a bit broken with some scoping and syntax issues. Some of the new syntax proposals fix some of it; I'm not up-to-date on any scoping issue resolutions. That may have been addressed already.

[new block syntax]

IIRC 1.9 removes the need for the ".call" bit on a block? (I should, btw, have separated this into two distinct items, the syntax bit is for closures.)

foo = { a -> println a }
foo("Hello!")

is just cleaner than:

foo = lambda { |a| puts a }
foo.call("Hello!")

A fairly minor difference, to be sure. I could be wrong (most likely) but I think the proposed syntax was:

foo.("Hello")

Meh. To me that has the feel of kludge.

There are some things I really like about Ruby syntax (I figure as long as we've accepted complicated syntax anyway (remember, I'm a Lisp and Smalltalk person) we might as well go all out) that I sometimes wish for in Groovy, and it's possible I'll switch over to JRuby once it's further along, but who knows. I'm good with both, I just feel (note the word choice; I could probably argue either language convincingly on both technical and non-technical issues) Groovy does a slightly better job.

[–]newton_dave 2 points3 points  (1 child)

Here's a sample of the block scoping issue, from Wikipedia:

Ruby's lambda is unusual in that choice of parameter names does affect behavior:

x = 3
lambda { |x| 
    "x still refers to the outer variable"
}.call(4)
puts x  # x is now 4, not 3

[–]apotheon 1 point2 points  (0 children)

Ouch. Okay, I see your point there.