Forums Register Login
Why would I Ruby when I can do everything in Java?
A friend was telling me that RoR would be the future. But then I said, I think not. I told him, if he could give me something that I can do in Ruby that I cannot do in Java, then I would go learn Ruby. So far, what I always intend to do with a language is

- Create a desktop App
- Create a mobile app
- Create a web app

of which I can all do in Java. Ruby is just good for the web as I can see it. I could be wrong though... What do you guys think?
So why aren't you programming in Assembly, then?

Seriously, it's not that Ruby would provide you with something you couldn't do with Java but rather that some things can be done better or faster with Ruby than with Java. And vice versa.
It would be better that you learn it and then decide which is better.
Hi @timothy sam,
<quote>if he could give me something that I can do in Ruby that
I cannot do in Java, then I would go learn Ruby
<quote>"If it doesn't exist, make it!"</quote>make it!
Here "the something-ruby":
We want to write a function that generates accumulators--
a function that takes a number n, and returns a function
that takes another number i and returns n incremented by i.
(That's incremented by, not plus. An accumulator has to accumulate.)
p.s. number => java-jargon: the function must be "generic"

viel spass(hoffentlich kannst du dieses Problem knacken:-))
def foo (n) lambda {|i| n += i } end WOOOOO!!!
please, post your java funtion!!!
Ken Anderson says that the following code is about as close as you
can get in Java:
public interface Inttoint { public int call(int i); }
public static Inttoint foo(final int n) {
return new Inttoint() {
int s = n;
public int call(int i) {
s = s + i;
return s; }};
This falls short of the spec because it only works for integers.
[I am not an RoR developer or advocate]

Why would I Ruby when I can do everything in Java?
  • Because you want to
  • Because being a geek means learning new technology is great fun
  • Because your boss told you to
  • Because scripting langauges are fun

  • I could go on. Also, you seem to be making a common mistake when speaking about Ruby and RoR. Ruby is a lanaguage. RoR is a web framework that uses the Ruby language.

    Also note that you can do Desktop apps using Ruby:


    And if you use JRuby, you can use Swing or SWT/JFace.
    IMHO, you would choose Ruby or Java based on how much time and effort you would spend in that language on a project and the overall quality of the result you would expect for that investment. For certain applications, Ruby (and Rails) will let you work faster and end up with higher quality code. The same is true for Java.

    Here's a short list of factors I would use to determine if the app was right for Ruby/Rails:

  • its a web app, like an ecommerce site or a social networking site, with a lot of custom ajax pieces
  • it doesn't need cross database transactions
  • it is going to have to change a lot both during production and after release due to changing requirements
  • I have a small dev team (say, four or less)
  • I have a certain amount of control, or at least input, on the database schema and the deployment environment

  • The first criteria (for type of web app) is not really a criteria as much as an indicator. We've done Ruby and Rails for lots of projects that weren't ecommerce or social networking apps, but if that's the gig, the rest of the criteria are less important.
    Thank you for your replies. I am downloading it right now, and see if I get to like it.
    Ten years ago when Java was "the new kid in town" there was a lot of talk about it and a lot of controversy. The old-school C/C++ programmers poo-pooed it as being a toy or just for the web.

    When I found myself saying similar things about Ruby and Ruby on Rails, I considered it a warning and started learning it. :-)

    I have been using Ruby for only a short while and am starting to use it for all kinds of automation scripts. I have also started learning RoR and am blown away by its powerful simplicity. What would take a week to do in Java (even with Hibernate and Spring) took a day with RoR.

    Is it the right tool for every job, no. Is it another tool for your tool box? YES!

    There is also some interesting work closer to the JAVA_HOME :-). If you look at Groovy and Groovy on Rails (Grails)... they are providing a lot of what Ruby and RoR provides but with a more Java flavoring.

    Good times ahead :-)
    Actually, Ruby and Java were born in the same year (1995)
    Originally posted by sergio mendez-rueda:
    Here "the something-ruby":

    That doesn't prove much. Ruby has different language concepts than Java, so sometimes you can't do things the same way; but it's certainly possible to do them.

    Just about all programming languages are alike in that they are Turing complete, so there's nothing one language can do that another positively can't. The differences are in the kinds of problems that are easy in one vs. easy in the other, as Lasse pointed out. That depends a great deal on what you'd use the language for, and thus can't be answered in general.
    I think of it as I read from a book. Ruby syntax is made for being easy for the human brain. Java, and many other languages, are made to be easier for the compiler/computer to learn. Now which one will get twice as fast in 18 months? Computers can handle any extra work. Just look at some Ruby code. I was amazed how readable it was before even knowing the language.
    Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards

    All times above are in ranch (not your local) time.
    The current ranch time is
    Dec 15, 2017 18:56:58.