

Ruby or Java. Why? - roizy


======
unclebobmartin
The advantages to Java: * Lots of programmers know it. * Execution speed is
very fast. * Static typing can help you find some bugs. * The tooling (The
IDEs) are spectacular! IntelliJ!!! Refactoring!!!!

The Disadvantages of Java: * It's wordy. List<Integer> l = new
ArrayList<Integer>(); * Static typing is constraining. * The data
representation is clumsy. Can't say: [1,2,3] * Minimal meta-programming,
limited to reflection.

The Advantages of Ruby: * Terse and elegant. You can say a lot in a few words.
* Very flexible. * Simple to learn (not counting Rails). * Very convenient
data representations. * Powerful meta-programming capability. * REPL! * You
can write really lovely DSLs. * Rails can get you going on a web app in a
jiffy. It's very slick. * Development speed can be _much_ faster than Java, at
least at first. Carelessness is the great equalizer!

Disadvantages of Ruby. * Slow. Damned slow. Really damned slow. * Did I say it
was slow? It is. Really. * It's really slow. * Jruby is faster, but still
really slow. * There aren't as many programmers. * Rails has a steep learning
curve once you get past the basics. * People use meta-programming too much.
This is a people problem, not a language problem; but it's real. * The tooling
is nowhere near as good as for Java. Refactoring tools are pretty weak. * It's
really easy to make a mess if your are careless.

The speed of Ruby is not really a huge concern in most cases since processors
are cheap. But the language is really, awfully, slow.

If I were starting a new website project, and had to choose bewteen Ruby and
Java, I'd pick Ruby and Rails, and then I'd be _very_ careful with programming
disciplines.

If I was starting a new enterprise project for a large company, I'd write the
backend servers in Java, and I'd consider writing the frontend in Ruby,
especially if the frontend was web based.

For thick client apps, I'd likely write them in Ruby using LimeLight on the
front end.

------
lutusp
> Ruby or Java. Why?

What? Ruby and Java aren't even comparable -- not to say one is "better", only
to say that they aren't on the same gradient or even the same dimension. They
have completely different purposes.

If you want to make a comparison, compare Ruby and Python (both easy-to-use
languages originally meant to make scripting more powerful and productive). Or
Java and Scala (both languages run on the Java JVM). But comparing Ruby and
Java is like comparing oranges and Volkswagens.

~~~
nessus42
_> What? Ruby and Java aren't even comparable -- not to say one is "better",
only to say that they aren't on the same gradient or even the same dimension._

This assertion is false. One could, with enough resources, for instance,
perform experiments to determine which is better. E.g., you could come up with
a million different software development projects, and then set a thousand
different development teams on each different project, half of the teams using
Java and half using Ruby, and then once the projects had all been completed
you could crunch the data on productivity of the development teams and on
robustness and efficiency of the products. For all we know, if this experiment
were done, it might turn out that one of the languages _is_ better than the
other.

Now of course, no one is going to have the funds to do this experiment, though
perhaps a dent might me made at a much smaller scale. Also, it is likely to
turn out that neither is better simpliciter, but rather that each language is
better for a certain type of project.

If we did this, we are likely to discover that each language is better for the
types of problem that each language is already typically used for. Though in
the realm of web development, both languages are often used to tackle similar
problems. So, we may want to start our grand experiment with, _Which language
is better for large web development projects?_

------
palidanx
It kind of depends on a history of a project. If the team is most familiar
with Java, and all the processes work with Java, then that would make sense.

I actually started off as a Java programmer, and in the last couple years
switched to rails. I found Java to be incredibly verbose. I don't know if
things have changed, but in addition to declared exceptions, we constantly had
to be catching runtime exceptions like NumberFormatExceptions, etc. I really
find Java to be incredibly verbose.

Ruby on the other hand is syntactically cleaner, but I do miss compilations to
catch some of my errors instead of in run time things blowing up.

I'd say the bigger question is Rails or J2EE? J2EE's overcomplex frameworks
really wanted to make me pull my hair out (but I'm hoping the newer Java
frameworks have fixed it since).

Digressing a bit, Rails is nice, but only if your application fits that
paradigm.

------
akaak
Agree with other responses. You may compare Ruby (considering Ruby as your
reference) with Python. There are good discussion on Ruby vs Python in HN. One
of the threads is at <http://news.ycombinator.com/item?id=682101>

------
VivaTechnics
<http://ask.metafilter.com/192158/Ruby-vs-Java-which-wins>

------
devonbarrett
Java, because its not ruby ;)

------
dylangs1030
This is monumentally difficult to answer when the question is presented so
generally.

• What are you trying to accomplish? • Which language has superior/more
libraries for your task? • Which language is more amenable to creating further
libraries if needed? • Which operating system are you working on? • Are you
doing server-side or client-side work? Web applications or desktop software? •
If server, does yours have a particular tie with one or the other language?
(example: specializing in RoR) • Are you working with a team? Which do they
know better? • Which do _you_ know better? • Are you going to iterate your
code a lot or do a one-off project that doesn't need updating? • Do you know
other tools/languages that stack well with one or the other? Which language
complements your coding habits more adequately? • Do you need to have a high-
performance application or can you sacrifice that for versatility and
readability?

etc. etc. etc...and you could double that list easily.

