JRuby combines the object-oriented strength of Smalltalk, the expressiveness of Perl, and the flexibility of the Java class libraries into a single, efficient rapid development framework for the Java platform. This article introduces JRuby, a sophisticated addition to your Java development toolbox.
Nifty. Me like. (From the looks of it, at least)
“Simpler syntax: JRuby contains no statement terminator (like the semicolon in the Java language) and allows the omission of parentheses in function calls that have no arguments.”
I don’t know. Just testing the field on this one, but I find I have more issues with languages that are not explicit when it comes to line terminations.
Then again I like to put parenthesis everywhere just to make sure my order of operations is right, so maybe I’m just a nut.
Personally, I hate missing tabs in makefiles. Sometimes my text editor replaces tabs with spaces, which I then have to check. Using new lines as statement terminator can create issues when transferring the code between different OSs (Windows Linux CRLF crap). I don’t like the vagueness of thinking does this statement come under this condition statement…
The same goes for function calls. Isn’t it easier to read when there are parenthesis, so you know that you’re making a function call?
I really like the simpler features of many RAD languages like VB (yes…I really do like it ). I don’t mind untyped variables as long as the language is able to cast things easily.
I think parenthesis are most important when you have complex argument lists or functional calls. But for a simple one-argument procedure call, like :
myproc(itsarg);
I think that the parenthesis and semi-colon are somewhat extraneous. Simple calls like this are easier to read without syntactic clutter. I find Ruby code to be pretty fast to read/write because one can get rid of unnecessary clutter.
As a Ruby amateur, I figure this tool gives hooks into the rich Java libraries, and this is great. This makes it indeed a great platform for network communication software and front-ends, as well as other applications that don’t demand a top efficiency over the use of machine cycles. As such, it indeed positions itself as a nifty RAD and prototyping tool.
I program java for a living…and I program Python for fun. That being said….what is a guy to do? Everyday there seems to be a new language popping up to that is so close to something else that it is crazy!
oh well…tis the world of programming I guess.
That would probably be Ruby.Net. Or jBoo…
to mention that JRuby does indeed have something to do with Ruby? I know the summary was just copy-paste from the intro paragraph of the article, but even so, some sort of indication that JRuby and Ruby are related would have made sense.
The summary doesn’t make it clear that JRuby is not a new language (exactly), but an implementation of Ruby on JVM.
The absence of semicolon as line terminator actually has less to do with “simpler syntax” than with “cleaner syntax”. I personally think it does make the code looks cleaner. And just like with compulsary indentation in Python, after a while you’ll get used to it (as long as you don’t think about it too much).
About the parenthesis-is-optional thingy, remember that in Ruby there is no “function call”, technically speaking. There are only objects and sending messages (= methods) to objects:
obj.msg1
obj.msg2 = value
obj.msg3 param1, param2
obj.msg3(param1, param2, …)
How do you differentiate between attribute access and method call? Answer: you don’t. Everything is a method call. Attribute access is done through accessor methods. So there’s no confusion between obj.msg1 and obj.msg1().
Contrast this with Python. In Python you _need_ the parenthesis because it signifies calling. foo.bar means attribute access and foo.bar() means function/method call.
So, the point is, they both have different philosophy. I hope you understand why you don’t need parenthesis in Ruby.
That was a nice post. It would help everyone if people elucidate the intricacies of a language or compare philosophies of two languages rather than just stating that a particular language ( OS, what have you :^) ) is better than any other.
I don’t know, while I agree that having the possibility to use either obj.msg1 and obj.msg1() is nice (Eiffel was the first to allow this AFAIK).
But I find that the extension of this to the several parameter case is weird:
obj.msg3 param1, param2
obj.msg3(param1, param2, …)
Without parenthesis I find that this makes hard to associate the parameters with the method, maybe it is just because I’m too used to parenthesis happy languages (C,C++,Java).
PS:
I thought that obj.msg3 param1 param2 (which I find even less readable) was also authorised in Ruby, am-I wrong?
I thought that obj.msg3 param1 param2 (which I find even less readable) was also authorised in Ruby, am-I wrong?
Yes, the commas are mandatory
I had trouble working out what this method meant when I first saw it:
def << aNode
@children << aNode
end
It’s actually an operator method, but if you’re used to other languages that isn’t obvious. It means this:
def <<(aNode)
@children << aNode
end