“Ruby on Rails is just one facet of what makes Ruby great, just like EJB is only part of the Java enterprise platform. Andrew Glover digs beneath the hype for a look at what Java developers can do with Ruby, all by itself. Ruby’s syntax is quite different from that of the Java language, but it’s amazingly easy to pick up. Moreover, some things are just plain easier to do in Ruby than they are in the Java language.”
An article on Ruby syntax…wow
But not to install!
What system are you running? Normally it is not hard to install unless you don’t know what to get.
I tried on a WindowsXP box. I followed the O’Reilly tutorial, and the command to install rails didn’t work when trying to download from the ruby forge. Then I had to install each dependency one after the other because installing manually didn’t manage dependency.
At last, when everything was installed, pointing to http://127.0.0.1:3000/ didn’t work, it timed out. I gave up.
Installation can be a little tricky — especially under Windows. But it’s well worth the effort. Maybe this will help:
http://instantrails.rubyforge.org/wiki/wiki.pl
I thought the same thing. Then I looked at the ONLamp tutorial, and I now have a webserver running with rails
http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html
(I had to allow time to let the server start up before going to the URL btw)
Yes, this is the tutorial I followed.
Issuing ‘gem install rails –remote’, the command line froze, nothing happened.
Then, issuing ‘ruby scriptserver’ started the server but opening http://127.0.0.1:3000 in Opera timed out. I opened port 3000 in my firewall with no luck.
Did you use the windows installer for ruby? If so, I got no clue. I’m just starting to fiddle around with this stuff myself.
I’m having a hard time understanding what could have gone wrong with your install. I got the installer here ( http://rubyforge.org/frs/?group_id=167 ) and got everything else per gem, no problem.
Did anyone else notices that IBM’s URL calls the article “RubyOFFRailes”.
If you read the article, you’ll find that the author starts off by stating that this is an article about Ruby — and not Ruby on Rails.
What are all of these “rails” articles targeted at Java devs? I’ve made a living the last few years w/ Java and C#…both are great and both have a lot in common. Both of them are also entirely different than Ruby or RoR…so why are there always articles on here extolling the virtues of “rails” specifically to the Java crowd?
Apples and oranges…entirely.
Java is where the money is at, and 37signals wants a piece of it, so that’s where they’re directing their hype. Rails does not fully live up to the hype, but it is good enough for the one-off web development portion of the hype.
“Rails does not fully live up to the hype, but it is good enough for the one-off web development portion of the hype.”
Please give at least one solid example, with some real data to back this statement up. How much time did you spend with Rails before you came to this conclusion?
“Rails does not fully live up to the hype, but it is good enough for the one-off web development portion of the hype.”
This is just plain ignorance.. I am by no means a particularly brainy or quick learner, but I learnt how the whole MVC (IIRC ) thing worked in under a week and am currently porting our entire (Realtor) intranet system to RAILS.
The Scaffold generation saves one alot of time even when rebuilding/customizing your forms. I also don’t need to write the same stupid SQL queries over and over. I did find Ruby a bit of a pain to install but that is because the Ubuntu Rmagick package is broken..
Rails is really hyped up and in my opinion deservedly so. I have turned my back to 4 years of PHP…
The article’s author is a recognized Java developer so this article isn’t about Java-bashing or written my someone who doesn’t understand Java.
Just take 30 seconds to glance at the Java code vs Ruby code in the article.
It doesn’t take a genius to recognize how much productivity gains can be achieved by using Ruby.
Obviously, this doesn’t mean Ruby should be used for everything–it is going to execute slower (in most cases) compared to Java. Same thing can be said when comparing c and Java. productivity <-> performance
I’ve programmed in Java for 4+ years, got 3 Java certifications from Sun, mentored around 12-15 Java developers, and yet I am much more productive in Ruby despite having used it for only a six months with no training.
If you haven’t tried Ruby programming on a 1+ week project, you’re really missing out on a tool that can help you get a massive amount of work done very quickly–without having code you can’t understand when revisited the following year.
Think of Java as sitting somewhere between C++ and Ruby regarding the performance vs productivity spectrum.
It is literally possible to replace a 1-year Java project in production with a Ruby version in 2 months. In my experience, it usually runs slower but the extra hardware you can buy with 8 months of development cost savings is *many* times more than the performance difference.
i disagree. when is a project develpoement speed is tied to the language syntax or syntatic sugar? Planning and preparing the logic comes much before, tools are second, syntax is at the end. Java’s verbosity shortcomings can easily be compansated by high quality IDE’s. C – Java and Ruby are three completely different things you are comparing.
At the end i also disagree that Ruby code is more “understandable”. it is just like eperl for god sake. i dont want to start talking about libraries, speed and concurrency issues.. this whole Ruby thing is becoming a big joke.
>>At the end i also disagree that Ruby code is more “understandable”.
After you’ve developed and maintained numerous systems written in numerous languages, you begin to appreciate languages that require fewer lines of code–but unlike perl, ruby supports language features that make the shorter code easier to understand & maintain.
Shorter code was one initial attraction of perl–but perl wasn’t OO, didn’t have exception handling, and many other language features that can help make code more easily understandable.
And languages that later kludge OO features onto an existing procedural language aren’t exactly a joy to use because of the inconsistent approaches.
>>it is just like eperl for god sake.
I use both perl and Ruby and I disagree. Can you back up your claim or was it purely based on fear of your skills with your current language losing demand?
For example, in ruby, everything is an object which means you can even do a “this is a string value”.length to get the length of a string. You can even obtain string values of numeric literals in the same manner.
If you’ve never used a language that supported blocks & closures, duck typing, mixins, exceptions, etc. then you’re like a blind person explaining why a color they haven’t seen is worse than one being described.
This reminds me why it took me several months to convince a very hardcore c programmer that using exceptions in c++ was sometimes better than using return values for error conditions. He never used exceptions and only read about it–and hated exceptions before even trying it. The advantages didn’t become clear until it was actually used and maintained in production code–now he sometimes even uses c++ exceptions a bit too much in places where performance doesn’t matter so its kind of funny.
>>this whole Ruby thing is becoming a big joke.
In what ways is it becoming a big joke? Are you talking about Ruby or RubyOnRails?
IMHO, RubyOnRails is to Ruby what Java Applets were to Java. It was what initially attracted widespread attention to the language but two things will follow (just like Java):
1. people will eventually discover Ruby’s benefits outside of Rails (the title of the article which indicates this is already happening)
2. performance will become more optimized–after Java Applet hyped went away and people discovered Java’s other uses, we saw massive improvements in performance because these new uses demanded it
> It is literally possible to replace a 1-year Java
> project in production with a Ruby version in 2 months.
Absolutely, but it has little to do with language productivity. It is also possible to replace a 1-year Java project in production with a new Java version in 2 months. Code design work, UI design work, database design, requirements extraction, and unit test design are the hard parts. Once you have those, starting from scratch is relatively simple.
I like Ruby. IMO, it’s a cleaner and better designed language than Python. But Ruby isn’t god. The reason C became so popular despite lacking most features is that the C designers discovered that it’s much better to have a huge reusable library than have a featureful language. At the moment, Java has a huge number of libraries that connect it an enormous number of legacy systems, whereas Ruby has a relatively small number. While it may be possible to create a Ruby for the JVM that interoperates seemlessly with Java’s libraries, it wouldn’t feel like Ruby (any more than Ruby for .NET feels like Ruby) because it would have to a use “foriegn” libraries in favour of its own. It also wouldn’t be documented as well as real Ruby. So if you’re going this route, Groovy (which is inspired by Ruby) would be a more natural fit.
So please cut the hype. Ruby is a great language. Java is a great language. Now let’s get back to producing great software with each.
I like Boo
Somehow the article reads like fanboy utterings.
For example the heading “Collections done right”. This is not backed by anything. Just some neat shorthands like [] or “adding” collections, but what makes Ruby doing collections “right”?
And what does “and do so without the fear of things blowing up on you!” mean?
And duck typing is not necessarily just positive. But no explanations on its effects. Just: “it’s great and here’s the syntax”
The polyglott arguments somehow sound like lame excuses to look at this minority language. Knowing the priniciples of OO and being able to use them in several languages is a plus, of course. But that’s something that stands on its own, tapping on this argument is nothing Ruby-specific. There should be better reasons for Ruby, otherwise I try to learn Objective Befunge (if that exists) instead.
I programmed a little bit in Ruby, and I think the language would deserve a better article.
I work in a mixed Python and Java development environment, and have evaluated Ruby a couple of times in the last year or so. I must admit, I’ve yet to be impressed with Ruby so far – certainly nothing to draw me away from either Python or Java. Other developers in my team have come to similar conclusions.
My background was originally Perl and C, and it just seems like Ruby was developed to add a few Perl-like features to Python, with less than satisfactory results.
It’s an interesting language, for sure, but feels like it hasn’t reached maturity yet – it feels like the same stage Python was at a few years ago.
You might be dissapointed that Ruby adds nothing over Python, but almost everyone agrees that Ruby and Python are basically equivalent equally great languages, with advantages over other languages.
I use Python and Ruby and I have found a few things in Ruby I like, there is nothing that makes me want to drop Python for Ruby but there are a few things I would like Python to learn.
Blocks, I would like them in Python, Lambda isn’t as good and Lambda is going away in Python3000 (whenever it may appear).
Yield, works nicely with blocks, I want them in Python and I will get them in 2.5.
Class methods, they are implemented cleaner in Ruby.
Adding methods to a preexisting class is really simple in Ruby and clean (yes I know you can do this in Python too but Ruby is cleaner).
Other then that, I like FXRuby (fox tookit bindings), they make Gui programming fun for me (and are easier to get working on windows then GTK) and let me also give you my obligatory Ruby on Rails comment >>I like Raisl<< while I’m at it.
What’s my point? I like Ruby, I also like Python, I think they have a lot in common an are the two dynamic languages right now that should work together most (or steal ideas from one another most, I’m not picky) to refine themselves.
Why ruby vs java, why not ruby vs php, ruby vs perl,ruby vs C#.
Why you compare script language with java?!
why not not C++? 😉
I’ll tell you why.
Every one will look at chicken that will try to attack a lion.
Author do not use java 5 syntax to show how ruby is good.
using java 5 syntax will make java code much cleaner
why not using Generics and for(each)?
I wrote two examples of what could be if author didn’t what to show how ruby is cool.
you deside what is better
ruby:
def add_synonym(synonym)
@synonyms << synonym
end
or java
void addSynonym(Word synonym){
synonyms.add(synonym);
}
and one again ruby
definitions.each{
|idef| idef.word = self
}
or java
for(Definition d:definitions){
validate(def);
}
for me it’s all the same
lets look at other mistakes that author did.
author uses the word “this” all the time (even in place there is no need for it)
author created 4 constructors (why?)
author tries to make kids think that using attributes directly better than accessors/mutators
(but what if he need to add constrains? in java code he will have to add one line in java against adding 3 and remove 1 ruby ).
Author insists that using one file for 10 classes is much better that 10 files for 10 classes.
Its wrong when you work in team with version control system.
Those who use one file will always have conflicts.
Author forgot to mention how slow ruby is.
Who said the java was slow?!!
Java is almost as fast as C++
but ruby is 3-5 times slower than java.
do you know how its hard to debug code like this?
File.open(“./src/dictionary.rb”).each { |loc| puts “#{count += 1}:” + loc }
and do you know that still there is no acceptable IDE for ruby (ruby is 5 years old and still there is no good IDE for it)?
do you know how hard to find errors in languages without strong typisation (like PHP,Python,Ruby,etc)?
Some times it can take you a half of the day.
And some times your users will find this error instead of you.
How about security framework in ruby?
NTLM/SPNEGO support in ruby?
how about correct Unicode/localization support in ruby?
why rails authors don’t use rails on their own site anymore?
So, do you still believe in ruby with java?
Maybe you believe in Santa too? 😉
Welcome back to earth.
Ruby can fight with other scripting languages but not with java and C++.
While I agree to many points of your some are incorrect:
– snippets showing that Ruby and Java are somehow as terse: not true and you know it.
Java’s static typing and lack of properties or user-defined operators makes it definitely more verbose (and I don’t even mention the stupid lack of generics before 1.5!).
Granted there are benefits to static typing and lack of users-defined operators, but verbosity and the corresponding reduced readability is clearly a downside.
– “author tries to make kids think that using attributes directly better than accessors/mutators” sorry but when the accessors do nothing but simple assignment which is the case really often, then properties are better.
Besides replacing properties with accessors/mutators in Ruby in case of modification doesn’t need to replace client code, which make it very simple to do the change. Why clutter code with unneeded accessors/mutators? It just degrades readability.
If Sun added properties now to Java’s language, everybody would claim it’s the greatest things since sliced bread, same as what happened with generics.
– With very small classes, it is quite usefull to be able to have several classes in the same file.
Especially if there are used only on this file.
– *I* think that Java is slow: in Solaris9, GUI admin tools recoded by Sun in Java feel 10 times slower than previously available tools which did the same thing. If Sun is not even able to make Java GUI apps feel fast, then I think Java is slow!
I know that Ruby is even much slower, that’s why Ruby users tend to use some C parts on performance’s critical parts which usually are a very small part of an application.
– I don’t know what you mean about debugging ‘File.open(“./src/dictionary.rb”).each { |loc| puts “#{count += 1}:” + loc }’, sorry.
– Agreed about most of your comment at the end, except that 1) you’re confusing static typing and strong typing 2) currently Java is competing against PHP for web serving, now Ruby is competing against PHP and so against Java on this particular niche.
That said I don’t beleive that Ruby is perfect, IMHO static typing with local type inferencing that Limbo, Scala have and that C#v3 will have is the best of both worlds, easy mandatory variable declaration such as Limbo’s syntax (:=) is nice too: a mandatory variable declaration which avoids being too verbose.
All those arguments against Ruby by Java folks remind me of all those arguments against Java by C++ folks. Especially speed.
C++ guy to Java guy: “Yeah but Java is slow, it’s not a real language it’s just VM based”
Java guy to Ruby guy: “Yeah but Ruby is slow, it’s not a real language it’s a scripting language”
(reminds me of a -you hit me with a stick and drop it, I’ll pick it up and hit someone else- attitude)
I like Ruby and I don’t mind other languages. The more languages, the better because the fittest will survive. A more important fact for me, and you might call me idealistic here, is that Ruby is free and Java is Sun. I tend to prefere free.
C++ guy to Java guy: “Yeah but Java is slow, it’s not a real language it’s just VM based”
Java guy to Ruby guy: “Yeah but Ruby is slow, it’s not a real language it’s a scripting language”
It seems your post was address to me.
All I was trying to say that comparring Ruby with Java is stupid because these languages designed for different needs.
In my previos post I showed that the article fails to show that ruby code is clear than code written in java. If you use java5 features the code is much clear than the code in the article.
Also, I do not insist that problems with performance are worst think about ruby.
Yes, ruby is slow (it is even slower than perl,php,python) but
there are other disadbatages this article didn’t cover.
Hard to debug and maintain code(no strong typisation and huge clousers).
Lack of libs.
Problems with unicode/localization.
Please, read Ruby on Rails IRC to understand how many problems ruby brings.
IMHO Ruby is only for very small/pico projects.
My question was – why always Ruby vs Java?
Why not Ruby vs Perl,Python,PHP?