Several people I know have asked me this recently. Without just pointing straight to Bruce Tate, here's what I've come up with.
<short_answer>
* Ruby is an order of magnitude more powerful and less bloated than Java
* Ruby has Rails and an explosion of new libraries being built with or for Ruby
* Ruby will make you look good to your customers by developing more efficiently, making you more money
* Ruby is hot
</short_answer>
<long_answer>
With Ruby, you get more done in fewer lines of code and have more fun
doing it. Though I haven't put something into production like
Basecamp, or even Bandcamp,
with Ruby yet, Ruby's joy and associated productivity increases are
also my personal experience so far. Often mentioned 2-5X productivity
increases using Ruby should make competent programmers really stand out
in the present world of Java and Microsoft.
Ruby's syntax is Java friendly. Like Python, it's concise and clear. Like Lisp, it's powerfully expressive (or so I'm told). You find yourself less and less blocked by what lies between your brain and working code. This is empowering.
There are one or two language features that require new thinking (blocks, mix-ins, and symbols come to mind) but otherwise, not only is the transition from Java to Ruby relatively painless, it's warm, inviting, and pleasurable - that is unless you're a eunuch or a bitter contrarian, revolting against a lifetime of misunderstanding and rejection, who probably hates their own mother. It's you who will do the rejecting now, you say...
I digress.
Truly, the joy of Ruby is something you must experience to appreciate. And, when you do, in no time, you become a Ruby convert, walking around with a secret glow, skeptically dismissed by the established robot armies of static-typers and mother-hating contrarians.
To the static typers: Fear not, Ruby is replete with 'types.' You just don't have to declare them next to each variable, like a mute stranger who, for legal reasons, must accompany you during all future conversations, occasionally pounding you with a heavy club when you speak illegally.
As it turns out the lack of static typing is really a huge improvement in making conversations happen. It's an 'obstacle' only for tooling. So far, this seems to be Ruby's only substantial criticism - though a collegue and I are finding that even this deficit will soon be a thing of the past (with increasingly sophisticated TextMate, and RadRails support).
Almost everyone I know has heard of Ruby, wants to learn more, or they are actively trying to work with it. For the remainder, I'm spreading the word. Ruby advocacy is particularly strong among those I happen to respect the most: Martin Fowler, Chad Fowler, James Duncan Davidson, Paul Graham, Stuart Halloway & Justin Ghetland, Bruce Tate, Dave Thomas, Ed Burnette, and, on, and on.
The wind of the times is eerily similar to Java in the mid 90s. Nay-sayer guys on the left said Java was slow and immature. Proponent guys on the right said Java made them more productive because it made the pain of C++ (pointer arithmetic, memory management, etc) go away. The guy in the middle... got his id phished.
To put it in Geoffrey Moore's terms, Ruby seems to be 'crossing the chasm.' I believe the future business benefits may be comparable to Java's in the mid 90s for a company considering language/platform options.
Bruce Tate has done much to analyze Ruby's potential for decision
makers. To get the best feel for Ruby's potential from a pro-Ruby
perspective, check out Bruce's related post on InfoQ or buy his book on the topic. For another perspective, Google recent Ruby comments from the author of Java, himself, James Gosling.
</long_answer>
My big concern with ruby is that a lot of the counter arguments against how "loose" it is versus java is "your unit tests will catch it". Now this is all very well and good, but assuming that any variable can be any type of thing (array versus single item) doesn't seem like something you really *need* if you just design things properly. Also: having to write a hundred extra tests to do things that the java compiler did doesn't seem like a huge time saving feature of a language.
I'm also not a huge fan of obsession over trying to reduce code down to the smallest most funky/tricky number of lines of code. Smacks of PERL (and we know how maintainable that is).
To me maintainability and readability are more important. The times I've dug into ruby code it just seems cluttered, "dense" and quite tricky to read (perhaps cos people are trying to minimise code and use the funky syntax to the full).
I've played around with ruby (like everyone) and haven't used it commercially (like everyone) and I'm sure for small trivial things you can find more succinct syntax. I've witnessed many other products and technologies demoed with dinky little CRUD apps created in 3 clicks but which choke and require lots of tinkering to do anything real world. There are some nice things about ruby syntax that just "make sense", but it needs to tighten up other areas I think.
Given the lack of developer tool support, limited library support and lack of ability to let the compiler catch common things I think it has a long way to go before it's truly useful (and I don't think it is as inherently enterprise applicable as java is). I will say it does have quite a lot of tutorials and documentation out there which is a definite plus.
The way you can just avoid declaring types makes it feel a lot like VB to me, which does the same sort of "cool stuff" allowing you to get away with loosly working out what something should be at any time you like.. And I fear that if used in the same way, will have the same maintainability and dodginess as VB.. Think it was a case of "give a man enough rope he'll hang himself with it", having 20 types of funky syntax to do a for loop in my opinion is not a good idea. Allowing someone the laziness of avoiding typing of variables is like java only allowing variables to be type "Object", sure that might make things easier to do sloppy or confusing things ("is this a string or an array or an object or what?") but really laughs in the face of common sense.
Bit harsh I know comparing it to VB, but VB was a scripting language that promised doing lots with less lines of code (the same arguments all the .net coders tried to use against java). Lines of code as a measure of a programming language's quality doesn't sit well with me, nor does getting excited about funky low level programming syntax.. ;)
Java being "bloated" tends to mean "the functionality you need in the API is there". Having a minimal included base API means you have to dig up 3rd party APIs for everything, and wasn't that a roaring success for the standardisation of c/c++!? Not having to track down and verify the usability of ten thousand external libraries to do stuff that the Java API provides by default is a hell of a timesaver.
I don't really see how ruby is more powerful though, what do you mean by that? To me java has more tools, libraries, included functionality, app server choices, platform choices (OS and application type: EE, SE, mobile etc) and proven reliability. Thus, more "powerful"?
Or is this along the lines of "assembly is more powerful than C which is more powerful than java"? Yes: assembly is more powerful, you can do anythign you like... So long as you have the time, resources, patience to do everything from the ground up and completely again for any change in platform or architecture.
Or maybe I just don't like having "end" all over the place (I like my squiggly brackets.. less characters that "end" so it must be better hehe). ;)
So short answer as for why java over ruby:
* Java is an order of magnitude more proven, deployed and tested in the real world
* Java has far larger, more powerful, more standard base API
* Java is a known quantity with customers, you are less likely to be stuck on an unproven platform
* There are far more java coders available to support your applications in industry
* Java has less hype and more substance
But enough shit stirring ;) I think best tool for the job, scripting languages (regardless of how funky) in my book are suitable for a certain type of application..
Nath
Posted by: Nathan Lee | October 10, 2006 at 05:40 AM
Nath, good to hear from you. This has to be one the lengthiest and best formed comments to any post of mine. Much appreciated.
You state:
"* Java is an order of magnitude more proven, deployed and tested in the real world"
True, as will always be the case for the previous great programming language. I still love Java and in certain scenarios would continue to recommend it. However, Ruby is finding its way into increasingly mission critical applications (working on one now).
"* Java has far larger, more powerful, more standard base API"
Larger, true. More powerful - as you asked yourself: what is "power". To me, it is the ability reuse, write, and deploy new applications quickly. Ruby simply has fewer speed bumps and allows you to do more with less.
"* Java is a known quantity with customers, you are less likely to be stuck on an unproven platform"
True. This is part of the growing pain of any new language and associated catalyst. As Ruby is increasingly deployed, however, this argument inevitably fades away.
"* There are far more java coders available to support your applications in industry"
True, again. However, given the productivity benefits of Ruby, small investments in training can return a company's investment in short order. In the end, Ruby requires fewer resources to do the same work. Addtionally, it seems clear that ramping up with Ruby (and Rails, et al) can be done more quickly that it would take to ramp up to a comparable production app using Spring, Struts, etc. Java could close this gap, however. And, I expect it will.
"* Java has less hype and more substance"
No disagreement about the hype. Java's 'substance' is part of the problem though. It has too much. Ruby, Rails, etc. has made large waves with the philosophy that simplicity and doing more with less (in the right places, of course) can sometimes be a better way. Perhaps, even most of the time.
Posted by: Ben | October 10, 2006 at 03:19 PM
Though I've been neglecting the internet and blogging community a tad lately.. Your post caught my eye as I'd just been playing around with ruby a bit more that day..
So I guess where you and I disagree on is APIs and what should be "platform" and what should be "external library". Java has a history of criticism from the early days about having a large API, although I tend to regard it as having a very large toolshed full of various things. Sure you can say having that shed full of tools is "bloated" and "unnecessary", but (sticking with the analogy) it does save you having to jump in the car to trek around town when you need a phillips head screwdriver or a spanner..
It also means that if you move house (Operating system? platform etc) it comes with a pre-stocked garage complete with the same tools you're used to at your old house..
I do worry I'm a bit negative about ruby at times just the same way people were towards java when it came along all shiny and new with a JVM, garbage collection, large standard API etc.. But the lack of typing does scare me a bit I must admit. I don't really know what the reason for missing out this feature, I guess the inventor (matz was it?) didn't like having to do it.. I also got a little burnt when trying to debug a ruby app (damage control) and ended up stuck on a bug that the only google results for it were people posting that they'd come across it and it was a low low level ruby error.
But that's probably just the newness of the language and with time that starts to go away..
Something else I came across that was a little worrying was a set of slides on the future major release. It seems once again ruby will be one of those platforms that change things in such a way to require extensive re-coding/testing of existing code because maintainability takes a back seat to "we want to do xyz in the next version". Java's never taken anything out of the API (though there's a JSR in the pipeline that talks about cleaning some things up). .NET did this sort of thing where they pay little attention to making a version increment smooth and it is their clients who wear the significant cost of migration between versions.
Web app productivity: yeah, I agree that any framework should allow things to get done quickly. I had started on a little project to create template applications for things to speed things along, but alas got sidetracked as usual with these things ;). Some of the IDE's are making things quicker, I've had some fairly speedy to modify apps (even struts) due to the appropriate setup of maven/ant scripts with autogeneration of things like hibernate.. But there's still an entry barrier that could be lower..
Nath
Posted by: Nathan Lee | October 11, 2006 at 05:16 AM