Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why would I Ruby when I can do everything in Java?

 
Timothy Sam
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would be better that you learn it and then decide which is better.
 
sergio mendez-rueda
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
<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:-))
ser
help?
ruby:
def foo (n) lambda {|i| n += i } end WOOOOO!!!
please, post your java funtion!!!
java-hint:
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.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[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:

    http://ruby-gnome2.sourceforge.jp/
    http://rubyforge.org/projects/wxruby/

    And if you use JRuby, you can use Swing or SWT/JFace.
     
    Justin Gehtland
    author
    Ranch Hand
    Posts: 31
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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.
     
    Timothy Sam
    Ranch Hand
    Posts: 751
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thank you for your replies. I am downloading it right now, and see if I get to like it.
     
    Chris Stehno
    Ranch Hand
    Posts: 180
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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 :-)
     
    Roseanne Zhang
    Ranch Hand
    Posts: 1953
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Actually, Ruby and Java were born in the same year (1995)
     
    Ulf Dittmer
    Rancher
    Posts: 42967
    73
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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.
     
    Alex Lewis
    Greenhorn
    Posts: 3
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic