Ten Things Every Java Programmer Should Know About Ruby

J

Jim Weirich

We will be introducing Ruby to our XP Users group in Cincinnati next week.
I thought it would be fun to create a list of "Ten Things Every Java
Programmer Should Know About Ruby" to help the transition. I've got a
number of things in my head, but would love to hear ideas from the mailing
list.

So go ahead and submit your ideas. What things should a Java programmer
be aware of when starting out in Ruby?
 
M

martinus

Classes really are objects. this is the reason why e.g String.new makes
much more sense then Java's new String();

martinus
 
J

Joao Pedrosa

Hi,

We will be introducing Ruby to our XP Users group in Cincinnati next week.
I thought it would be fun to create a list of "Ten Things Every Java
Programmer Should Know About Ruby" to help the transition. I've got a
number of things in my head, but would love to hear ideas from the mailing
list.

So go ahead and submit your ideas. What things should a Java programmer
be aware of when starting out in Ruby?

1- Ruby does not have type casting.
2- Try to not think about interfaces, but enjoy fully the dynamic typing.
3- No overload of methods.
4- Enjoy closures/blocks.
5- Don't worry about performance until the program/library has been made.
6- Web-development is possible with other languages besides Java.
Enjoy FastCGI and mod_ruby. Give Rails a shot.
7- Ruby has O/R mappers, so find your Ruby "hibernate", but drop any
preconceptions.
8- Ruby has MVC and OO programming and libraries, but drop any preconceptions.
9- Ruby is a language to be used everywhere. You use it even in
templates. No need for "Velocity/JSP."
10- Ruby is not a Silver Bullet, unlike Java, right? :)

Cheers,
Joao
 
B

Belorion

1) Ruby rocks.

Seriously though... It's been a while since I've done any Java coding,
but, the first points that came to my mind are:

-In Ruby data is strongly typed, but variables are *not* (no messy
typecasting, yay!)
-No method overloading (probably as a result of the above, but that is
just speculation)
-*BUT* you can have variable number of parameters, and multiple return values

of course, the list of differences goes on and on, but those were the
first 3 that came to my mind.
 
M

Mike Clark

We will be introducing Ruby to our XP Users group in Cincinnati next
week.
I thought it would be fun to create a list of "Ten Things Every Java
Programmer Should Know About Ruby" to help the transition. I've got a
number of things in my head, but would love to hear ideas from the
mailing
list.

So go ahead and submit your ideas. What things should a Java
programmer
be aware of when starting out in Ruby?

1. Once you start coding Ruby, going back to Java is painful.

Mike
 
E

Edgardo Hames

We will be introducing Ruby to our XP Users group in Cincinnati next week.
I thought it would be fun to create a list of "Ten Things Every Java
Programmer Should Know About Ruby" to help the transition. I've got a
number of things in my head, but would love to hear ideas from the mailing
list.

So go ahead and submit your ideas. What things should a Java programmer
be aware of when starting out in Ruby?

I would suggest that once you come up with the top ten list, it would
be really nice if you did post it to the mailing list. I'd like to
forward it to some friends.

Kind Regards,
Ed
 
J

Jim Weirich

Edgardo Hames said:
I would suggest that once you come up with the top ten list, it would
be really nice if you did post it to the mailing list. I'd like to
forward it to some friends.

I'm going to collect responses in a public Ta-Da list at
http://jimweirich.tadalist.com/lists/public/14055 (which is already way
over 10 items!). Later (possibly this weekend) I'll sort through the
collected suggestions, edit them down to my top ten and publish the
result.
 
M

Mathieu Bouchard

2- Try to not think about interfaces, but enjoy fully the dynamic typing.

*Think* about interfaces, but for yourself, not for the compiler's
benefit. Don't *worry* about interface. Still enjoy fully the dynamic
typing.
5- Don't worry about performance until the program/library has been made.

In any language, I'd say, think about global performance issues before
writing the program (or at every major refactoring), but don't worry about
local performance issues until everything works. When one says "premature
optimisation is the root of all evil" it's usually implied that it's about
local optimisations.
10- Ruby is not a Silver Bullet, unlike Java, right? :)

Java's marketing/gospel/selfcontradiction/bellythinking department has
caused a lot of harm, so when looking at which preconceptions to drop
first, start there!

11- Reflection in Ruby is much easier than in Java, and more deeply into
the language than the java.lang.reflect tack-on.

12- eval.

13- the builtin classes are much faster because they're written in C and
not Ruby, and this should be taken into account. (same as for
Perl/Python/Tcl/...)

_____________________________________________________________________
Mathieu Bouchard -=- Montréal QC Canada -=- http://artengine.ca/matju
 
C

Curt Hibbs

Jim said:
Edgardo Hames said:

I'm going to collect responses in a public Ta-Da list at
http://jimweirich.tadalist.com/lists/public/14055 (which is already way
over 10 items!). Later (possibly this weekend) I'll sort through the
collected suggestions, edit them down to my top ten and publish the
result.

Also, if you are creating a presentation, it would great if you'd be willing
to add your presentation to those hosted on the WhyRuby? project (on
RubyForge).

Curt
 
C

Curt Hibbs

Mathieu said:
13- the builtin classes are much faster because they're written in C and
not Ruby, and this should be taken into account. (same as for
Perl/Python/Tcl/...)

This reminds me...

- C extensions/wrappers are *much* easier in Ruby than JNI interfaces in
Java.

Curt
 
E

Eric Anderson

Jim said:
We will be introducing Ruby to our XP Users group in Cincinnati next week.
I thought it would be fun to create a list of "Ten Things Every Java
Programmer Should Know About Ruby" to help the transition. I've got a
number of things in my head, but would love to hear ideas from the mailing
list.

So go ahead and submit your ideas. What things should a Java programmer
be aware of when starting out in Ruby?

One of my favorite features in Ruby is the fact that the object
definition never closes. You can always add new methods, change methods
and delete existing methods on an object at runtime even if that object
is implement in C or is one of the core objects of the system.

The Ruby Facets library
(http://calibre.rubyforge.org/facets/doc/index.html) is a great example
of doing this and anybody that has done even a minor project usually has
augmented one of the core objects a little to make it fit in their
application domain better. And since you are simply modifying a
existing class and not creating a new (or subclassing a existing class)
all your literals work still. So when you do:

foo = "A string of text"
foo.my_special_function

It just works. Just my 2 cents.

Eric
 
J

James G. Britt

Hi,

1- Ruby does not have type casting.
Well, Ruby does not have a lot of things, but listing them will not
always explain anything.

I would rephrase this as, "Ruby has types, but does not need type casting."

Or, simply, "Ruby does not need type casting."

I'm wondering, too, if the things to list can be divided into aspects
common to most dynamically typed languages and features largely
specific to Ruby.

So one could start with, 'Ruby has strong, dynamic typing, which
means, among other things: [list of stuff]'

Then, "And in addition to all the goodness of a dynamically-typed
language, Ruby has [blocks, closures, continuations, ...]

One could also make distinctions between features built into the
language (e.g. blocks, continuations) and features available through
bundled or otherwise available libraries (REXML, YAML, O/R mapping,
Rake).


James
 
J

Joao Pedrosa

Hi,

*Think* about interfaces, but for yourself, not for the compiler's
benefit. Don't *worry* about interface. Still enjoy fully the dynamic
typing.


In any language, I'd say, think about global performance issues before
writing the program (or at every major refactoring), but don't worry about
local performance issues until everything works. When one says "premature
optimisation is the root of all evil" it's usually implied that it's about
local optimisations.


Java's marketing/gospel/selfcontradiction/bellythinking department has
caused a lot of harm, so when looking at which preconceptions to drop
first, start there!

11- Reflection in Ruby is much easier than in Java, and more deeply into
the language than the java.lang.reflect tack-on.

12- eval.

13- the builtin classes are much faster because they're written in C and
not Ruby, and this should be taken into account. (same as for
Perl/Python/Tcl/...)

Well put Mathieu, thanks. :)

Regards,
Joao
 
Z

Zach Dennis

Some of the things I like in ruby thinking directly about java... being
both a ruby and java programmer:

- there is no type casting in ruby
- ruby has better loop constructs
- writing a class in ruby opposed to writing a class in java takes
much less time
- ruby eliminates the # of (, ), {, and } 's
- you can use characters like ?, !, etc.. in your method names
- you can use string interpolation, ex: "x: #{@myvar}" instead of
having to say "x:" + myvar'
- ruby doesn't force you to have 1 file per public class, you can have
all the public classes you want in a file (not that you have to do this,
but it's a nice option to have)
- ruby has multiple inheritance through mixins (this is sooo nice to have)
- ruby has a lower percentage of dr. diagnoses carpal tunnel sydrome
cases then java (ok, this is just an opinion...=)
- writing code in ruby, can improve the code you write in java (i say
this from prototyping code in ruby, then porting it to java at work,
because ruby allows me to focus on the design of my code more. Once my
design and testing is done in ruby it's so easy to port it to Java and
my java code looks better since I was able to put better design into
upfront, then having to worry about typing 18,000 lines of code
including the following characters: ;, return, int, char, String, byte,
[], {}, (), etc... )

- ruby has shortcuts for accessor methods which reduces alot of
redundant coding in java


I know I've got lots more, but I'm at work now...and need to get to that
5pm java deadline. =) If it were ruby it would have been done before
lunch...

Zach

P.S. - Although ruby's gui's are coming along, I still find Swing the
easiest RAD GUI to use, and yes over VB...I hate VB. And because of
JRuby I can utilize Ruby Code and a Swing GUI. Ah...raw power.



Hi,

1- Ruby does not have type casting.

Well, Ruby does not have a lot of things, but listing them will not
always explain anything.

I would rephrase this as, "Ruby has types, but does not need type casting."

Or, simply, "Ruby does not need type casting."

I'm wondering, too, if the things to list can be divided into aspects
common to most dynamically typed languages and features largely
specific to Ruby.

So one could start with, 'Ruby has strong, dynamic typing, which
means, among other things: [list of stuff]'

Then, "And in addition to all the goodness of a dynamically-typed
language, Ruby has [blocks, closures, continuations, ...]

One could also make distinctions between features built into the
language (e.g. blocks, continuations) and features available through
bundled or otherwise available libraries (REXML, YAML, O/R mapping,
Rake).


James
 
Z

Zach Dennis

Mathieu said:
Java's marketing/gospel/selfcontradiction/bellythinking department has
caused a lot of harm, so when looking at which preconceptions to drop
first, start there!

11- Reflection in Ruby is much easier than in Java, and more deeply into
the language than the java.lang.reflect tack-on.

I 100% agree!! This is a great one.
12- eval.

yes...so yes!!

Zach
 
P

PA

What things should a Java programmer be aware of when starting out in
Ruby?

My 2 ¥

(1) No explicit types. Probably the most disconcerting thing for a
Javahead.
(2) Because of (1), you cannot rely on the compiler to catch trivial
mistakes.
(3) Think in terms of methods (behaviors) instead of classes.
(4) KISS.
(5) Discipline. Because of its inherent flexibility, Ruby require more
self-discipline.

Cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top