# Ten Things Every Java Programmer Should Know About Ruby

**URL:** <https://rubytalk.org/t/ten-things-every-java-programmer-should-know-about-ruby/16080>\
**Category:** ruby-talk\
**Created:** [27 January 2005 17:55 UTC](https://rubytalk.org/t/ten-things-every-java-programmer-should-know-about-ruby/16080 "2005-01-27T17:55:46Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jim\_Weirich1](https://avatars.discourse-cdn.com/v4/letter/j/73ab20/32.png) [@Jim\_Weirich1](https://rubytalk.org/u/Jim_Weirich1)\
**Post date:** [27 January 2005 17:55 UTC](https://rubytalk.org/t/ten-things-every-java-programmer-should-know-about-ruby/16080/1 "2005-01-27T17:55:46Z")

</div>

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?

> **···**
>
> --  
> -- Jim Weirich [jim@weirichhouse.org](mailto:jim@weirichhouse.org)[http://onestepback.org](http://onestepback.org)  
> -----------------------------------------------------------------  
> "Beware of bugs in the above code; I have only proved it correct,  
> not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)

---

<div class="post-metadata">

**Author:** ![Nathaniel\_Talbott1](https://avatars.discourse-cdn.com/v4/letter/n/a4c791/32.png) [@Nathaniel\_Talbott1](https://rubytalk.org/u/Nathaniel_Talbott1)\
**Post date:** [27 January 2005 18:29 UTC](https://rubytalk.org/t/ten-things-every-java-programmer-should-know-about-ruby/16080/2 "2005-01-27T18:29:29Z")

</div>

Well, it would obviously need to be adapted, but I loved this article:

&nbsp;&nbsp;&nbsp;[http://dirtsimple.org/2004/12/python-is-not-java.html](http://dirtsimple.org/2004/12/python-is-not-java.html)

Nathaniel  
Terralien, Inc.

\<:((\>\<

> **···**
>
> On Jan 27, 2005, at 12:55, Jim Weirich wrote:
> 
> > What things should a Java programmer  
> > be aware of when starting out in Ruby?

---

<div class="post-metadata">

**Author:** ![Joao\_Pedrosa](https://avatars.discourse-cdn.com/v4/letter/j/e56c9b/32.png) [@Joao\_Pedrosa](https://rubytalk.org/u/Joao_Pedrosa)\
**Post date:** [27 January 2005 18:35 UTC](https://rubytalk.org/t/ten-things-every-java-programmer-should-know-about-ruby/16080/3 "2005-01-27T18:35:11Z")

</div>

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

> **···**
>
> On Fri, 28 Jan 2005 02:55:46 +0900, Jim Weirich \<jim@weirichhouse.org\> wrote:

---

<div class="post-metadata">

**Author:** ![Belorion](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@Belorion](https://rubytalk.org/u/Belorion)\
**Post date:** [27 January 2005 18:35 UTC](https://rubytalk.org/t/ten-things-every-java-programmer-should-know-about-ruby/16080/4 "2005-01-27T18:35:32Z")

</div>

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.

> **···**
>
> On Fri, 28 Jan 2005 02:55:46 +0900, Jim Weirich \<jim@weirichhouse.org\> wrote:
> 
> > 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?
> > 
> > --  
> > -- Jim Weirich jim@weirichhouse.org [http://onestepback.org](http://onestepback.org)  
> > -----------------------------------------------------------------  
> > "Beware of bugs in the above code; I have only proved it correct,  
> > not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)

---

<div class="post-metadata">

**Author:** ![Martin\_Ankerl](https://avatars.discourse-cdn.com/v4/letter/m/f04885/32.png) [@Martin\_Ankerl](https://rubytalk.org/u/Martin_Ankerl)\
**Post date:** [27 January 2005 18:35 UTC](https://rubytalk.org/t/ten-things-every-java-programmer-should-know-about-ruby/16080/5 "2005-01-27T18:35:59Z")

</div>

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

martinus

---

<div class="post-metadata">

**Author:** ![Mike\_Clark](https://avatars.discourse-cdn.com/v4/letter/m/c77e96/32.png) [@Mike\_Clark](https://rubytalk.org/u/Mike_Clark)\
**Post date:** [27 January 2005 18:39 UTC](https://rubytalk.org/t/ten-things-every-java-programmer-should-know-about-ruby/16080/6 "2005-01-27T18:39:40Z")

</div>

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

Mike

> **···**
>
> On Jan 27, 2005, at 10:55 AM, Jim Weirich wrote:
> 
> > 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?

---

<div class="post-metadata">

**Author:** ![why\_the\_lucky\_stiff1](https://avatars.discourse-cdn.com/v4/letter/w/898d66/32.png) [@why\_the\_lucky\_stiff1](https://rubytalk.org/u/why_the_lucky_stiff1)\
**Post date:** [27 January 2005 18:42 UTC](https://rubytalk.org/t/ten-things-every-java-programmer-should-know-about-ruby/16080/7 "2005-01-27T18:42:38Z")

</div>

Jim Weirich wrote:

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

Schwern's paper is written for Perl, but it rings of many Rubyisms.  
\<[http://magnonel.guild.net/~schwern/papers/Why\_I\_Am\_Not\_A\_Java\_Programmer/why.html&gt](http://magnonel.guild.net/~schwern/papers/Why_I_Am_Not_A_Java_Programmer/why.html&gt);

\_why

---

<div class="post-metadata">

**Author:** ![Ed\_Hames](https://avatars.discourse-cdn.com/v4/letter/e/ecb155/32.png) [@Ed\_Hames](https://rubytalk.org/u/Ed_Hames)\
**Post date:** [27 January 2005 18:56 UTC](https://rubytalk.org/t/ten-things-every-java-programmer-should-know-about-ruby/16080/8 "2005-01-27T18:56:38Z")

</div>

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

> **···**
>
> On Fri, 28 Jan 2005 02:55:46 +0900, Jim Weirich \<jim@weirichhouse.org\> wrote:
> 
> > 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?
> 
> --  
> Alcohol is the anesthesia by which we endure the operation of life.  
> -- George Bernard Shaw

---

<div class="post-metadata">

**Author:** ![PA1](https://avatars.discourse-cdn.com/v4/letter/p/71c47a/32.png) [@PA1](https://rubytalk.org/u/PA1)\
**Post date:** [27 January 2005 19:07 UTC](https://rubytalk.org/t/ten-things-every-java-programmer-should-know-about-ruby/16080/9 "2005-01-27T19:07:42Z")

</div>

That you can write Ruby in Java:

> **[JRuby](https://sourceforge.net/projects/jruby/)**
>
> Download JRuby for free. JRuby is the effort to recreate the Ruby interpreter in Java. JRuby is tightly integrated with Java to allow both to script any Java class and to embed the interpreter into any Java application.

Cheers

> **···**
>
> On Jan 27, 2005, at 18:55, Jim Weirich wrote:
> 
> > What things should a Java programmer  
> > be aware of when starting out in Ruby?
> 
> --  
> PA, onnay equitursay  
> [http://alt.textdrive.com/](http://alt.textdrive.com/)

---

<div class="post-metadata">

**Author:** ![Dan\_Fitzpatrick](https://avatars.discourse-cdn.com/v4/letter/d/53a042/32.png) [@Dan\_Fitzpatrick](https://rubytalk.org/u/Dan_Fitzpatrick)\
**Post date:** [27 January 2005 20:01 UTC](https://rubytalk.org/t/ten-things-every-java-programmer-should-know-about-ruby/16080/10 "2005-01-27T20:01:06Z")

</div>

Take a look at: [http://fhwang.net/blog/40.html](http://fhwang.net/blog/40.html)

Dan

Jim Weirich wrote:

> **···**
>
> > 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?

---

<div class="post-metadata">

**Author:** ![Eric\_Anderson1](https://avatars.discourse-cdn.com/v4/letter/e/57b2e6/32.png) [@Eric\_Anderson1](https://rubytalk.org/u/Eric_Anderson1)\
**Post date:** [27 January 2005 20:21 UTC](https://rubytalk.org/t/ten-things-every-java-programmer-should-know-about-ruby/16080/11 "2005-01-27T20:21:08Z")

</div>

Jim Weirich wrote:

> 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\](http://calibre.rubyforge.org/facets/doc/index.html%5C)) 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

---

<div class="post-metadata">

**Author:** ![PA1](https://avatars.discourse-cdn.com/v4/letter/p/71c47a/32.png) [@PA1](https://rubytalk.org/u/PA1)\
**Post date:** [27 January 2005 20:59 UTC](https://rubytalk.org/t/ten-things-every-java-programmer-should-know-about-ruby/16080/12 "2005-01-27T20:59:10Z")

</div>

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

> **···**
>
> On Jan 27, 2005, at 18:55, Jim Weirich wrote:
> 
> > What things should a Java programmer be aware of when starting out in Ruby?
> 
> --  
> PA, onnay equitursay  
> [http://alt.textdrive.com/](http://alt.textdrive.com/)

---

<div class="post-metadata">

**Author:** ![Glenn\_Vanderburg1](https://avatars.discourse-cdn.com/v4/letter/g/439d5e/32.png) [@Glenn\_Vanderburg1](https://rubytalk.org/u/Glenn_Vanderburg1)\
**Post date:** [28 January 2005 02:38 UTC](https://rubytalk.org/t/ten-things-every-java-programmer-should-know-about-ruby/16080/13 "2005-01-28T02:38:59Z")

</div>

In addition to the many great suggestions already made, here are two more:

\* Many things that you're used to thinking of as syntax are now just code.

\* For good (but subtle) reasons, you have to leave the '++' and '--' operators behind. You can still use '+=' and '-=', though.

Although I understand the reasons for that last one, years of C, C++, Perl, and Java still lead me to try to use them in Ruby every now and then.

---Glenn

---

<div class="post-metadata">

**Author:** ![Nicholas\_Van\_Weerde2](https://avatars.discourse-cdn.com/v4/letter/n/59ef9b/32.png) [@Nicholas\_Van\_Weerde2](https://rubytalk.org/u/Nicholas_Van_Weerde2)\
**Post date:** [28 January 2005 05:05 UTC](https://rubytalk.org/t/ten-things-every-java-programmer-should-know-about-ruby/16080/14 "2005-01-28T05:05:57Z")

</div>

These are the concepts that got me interested, by leveraging my  
Java/C++ heritage, my mild Perl experience, my Python experiment, and  
the Smalltalk mystique that drifts back and forth across the computing  
landscape...  
1. you can fit in your mind and write code without looking at the docs  
every six minutes.  
2. less syntax and less typing  
3. Fixed what's wrong with Perl  
4. Fixes what's wrong with Python  
5. It's super productive (like Perl, Python and Smalltalk)- maybe 5-10x Java.

This excited me, because I always wanted to learn Smalltalk...  
= 6. Is a lot like Smalltalk, but doesn't look as funny

JavaScript gets some unfair knocks, so maybe best avoided...  
+ 7. Is a lot like JavaScript, but more OO and more for ful app development

The following are cool when you know them, and in many ways the heart  
of Ruby, but were meaningless to me until I banged my head against  
them for a while. I think a lot of what is exciting about Ruby is  
better learned then taught, much like Zen meditation. Just think what  
marketing these concepts did for Smalltalk and Lisp- Java and C#.  
\* 8. Blocks and Closures  
\* 9. Open Classes  
\* 10. Duck Typing

Regards,  
Nick

> **···**
>
> On Fri, 28 Jan 2005 02:55:46 +0900, Jim Weirich \<jim@weirichhouse.org\> wrote:
> 
> > 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?
> > 
> > --  
> > -- Jim Weirich jim@weirichhouse.org [http://onestepback.org](http://onestepback.org)  
> > -----------------------------------------------------------------  
> > "Beware of bugs in the above code; I have only proved it correct,  
> > not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://rubytalk.org/u/Robert)\
**Post date:** [28 January 2005 10:20 UTC](https://rubytalk.org/t/ten-things-every-java-programmer-should-know-about-ruby/16080/15 "2005-01-28T10:20:52Z")

</div>

"Jim Weirich" \<jim@weirichhouse.org\> schrieb im Newsbeitrag  
news:9813.192.223.163.6.1106848530.squirrel@weirichhouse.org...

> 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?

There are no interfaces - and you don't need them.

There are anonymous functions, called "blocks" or "lambdas". Learn to use  
them.

Use IRB.

"finally" is called "ensure". Use blocks for transactional behavior like  
File.open() does.

Cou can find help here:  
&nbsp;&nbsp;[http://www.ruby-doc.org/](http://www.ruby-doc.org/)  
&nbsp;&nbsp;[Ruby Programming Language](http://www.ruby-lang.org/en/)  
&nbsp;&nbsp;news:comp.lang.ruby

Strings are mutable but can be frozen.

Don't worry if your Ruby program is half LOC of the same Java program. As  
soon as you get experienced this will drop to one fourth or less. 🙂

"Serializing" is called "marshalling" in Ruby.

You can keep your habit of ending every statement with a semicolon - but  
without them Ruby code looks much better.

Kind regards

&nbsp;&nbsp;&nbsp;&nbsp;robert

---

<div class="post-metadata">

**Author:** ![Peter\_Hickman](https://avatars.discourse-cdn.com/v4/letter/p/ecd19e/32.png) [@Peter\_Hickman](https://rubytalk.org/u/Peter_Hickman)\
**Post date:** [28 January 2005 10:42 UTC](https://rubytalk.org/t/ten-things-every-java-programmer-should-know-about-ruby/16080/16 "2005-01-28T10:42:14Z")

</div>

Jim Weirich wrote:

> 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?

You will end up writing less code and it will do more.

---

<div class="post-metadata">

**Author:** ![Gavin\_Kistner2](https://avatars.discourse-cdn.com/v4/letter/g/b9e5f3/32.png) [@Gavin\_Kistner2](https://rubytalk.org/u/Gavin_Kistner2)\
**Post date:** [29 January 2005 16:51 UTC](https://rubytalk.org/t/ten-things-every-java-programmer-should-know-about-ruby/16080/17 "2005-01-29T16:51:08Z")

</div>

An instance of a class can be extended to be subtly different, without needing to subclass.

> **···**
>
> On Jan 27, 2005, at 10:55 AM, Jim Weirich wrote:
> 
> > So go ahead and submit your ideas. What things should a Java programmer  
> > be aware of when starting out in Ruby?

---

<div class="post-metadata">

**Author:** ![Gavin\_Kistner2](https://avatars.discourse-cdn.com/v4/letter/g/b9e5f3/32.png) [@Gavin\_Kistner2](https://rubytalk.org/u/Gavin_Kistner2)\
**Post date:** [29 January 2005 16:55 UTC](https://rubytalk.org/t/ten-things-every-java-programmer-should-know-about-ruby/16080/18 "2005-01-29T16:55:35Z")

</div>

Since all access to the inside of an instance is through methods, you can change your mind about whether .foo is a simple property or a complex method call, without affecting the interface to your class. Syntax sugar makes getter/setter methods indistinguishable from direct property access.

> **···**
>
> On Jan 27, 2005, at 10:55 AM, Jim Weirich wrote:
> 
> > So go ahead and submit your ideas. What things should a Java programmer  
> > be aware of when starting out in Ruby?

---

<div class="post-metadata">

**Author:** ![Gavin\_Kistner2](https://avatars.discourse-cdn.com/v4/letter/g/b9e5f3/32.png) [@Gavin\_Kistner2](https://rubytalk.org/u/Gavin_Kistner2)\
**Post date:** [29 January 2005 17:07 UTC](https://rubytalk.org/t/ten-things-every-java-programmer-should-know-about-ruby/16080/19 "2005-01-29T17:07:27Z")

</div>

HEREDOC strings with variable interpolation make large chunks of output really easy to construct.

> **···**
>
> On Jan 27, 2005, at 10:55 AM, Jim Weirich wrote:
> 
> > So go ahead and submit your ideas. What things should a Java programmer  
> > be aware of when starting out in Ruby?

---

<div class="post-metadata">

**Author:** ![Jim\_Weirich1](https://avatars.discourse-cdn.com/v4/letter/j/73ab20/32.png) [@Jim\_Weirich1](https://rubytalk.org/u/Jim_Weirich1)\
**Post date:** [27 January 2005 19:36 UTC](https://rubytalk.org/t/ten-things-every-java-programmer-should-know-about-ruby/16080/20 "2005-01-27T19:36:57Z")

</div>

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  
[Feedback on "Ten Things a Java Programmer Should Know About Ruby"](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.

> **···**
>
> --  
> -- Jim Weirich jim@weirichhouse.org [http://onestepback.org](http://onestepback.org)  
> -----------------------------------------------------------------  
> "Beware of bugs in the above code; I have only proved it correct,  
> not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)

[Next page](https://rubytalk.org/t/ten-things-every-java-programmer-should-know-about-ruby/16080.md?page=2)
