views:

85

answers:

3

I have been C/C++/VBNET programmer for a long time. Now Ruby advanced concept is attracting me. So I decided to learn how to use it.But the "Behavior" of Ruby used to confused me. I usually feel like can't completely control my Ruby program.

Can you help me get clearly about this ?

(Maybe some of your favorite guide about "Ideas" and "Styles" in Ruby may help >:D< . Thank)

+4  A: 

Ruby is quite an unusual programming language if you are more used to static/declarative style languages like C/C++.

I suspect it's the highly dynamic nature of the language which is causing you a problem, it can be difficult to get your head around this when you encounter it for the first time after having used only the more static languages. Ideas like Duck Typing can seem weird if you are used to declaring variables as strict types before use.

I would thoroughly recommend working your way through one of the excellent books about ruby that are out there. Don't just mess around writing code without really understanding the concepts.

Personally I really liked "The Ruby Programming Language" from O'Reilly, but I have experiance of a lot of different languages so I'm used to some of the more dynamic features in Ruby.

However you may prefer to start with something less terse such as Dave Thomas' "Programming Ruby" (make sure you get the 1.9 version).

Work through one of these books, do the examples, play around with the code. That way you will get a thorough understanding of the language.

Best of luck. Once you get your head around it, Ruby can be a very powerful language.

Paul Leader
+1  A: 

I recommend reading Why's Poignant Guide to Ruby. It will open your mind to the wonders of working in a dynamic language. Or it will piss you off with its cartoons of talking foxes. Either way it will change your thinking about Ruby :)

zetetic
Yeah, it pissed me off to no end, but mostly because it never seemed to get to the point of *explaining* Ruby. It's a classic though either way. ;)
deceze
Likewise, I got bored reading Why's guide. It's a cute idea, but it's a bit slow going.
Paul Leader
I think it's too "Discrete" to sum up a clear view . I found myself usually distracted by the cartoon and story. Maybe, it's like a relax book to read about ruby ..
Dark Cloud
+2  A: 

I think that the book Design Patterns in Ruby might help you. The first chapter describes the syntax of Ruby (which I guess that you won't need), but the rest of the book goes through the classic design patterns and shows you a Ruby way of approaching them. It's very clearly written and I learned a lot about Ruby idioms from it.

If you can talk to a Rubyist then that will probably help a lot - from experience, a code review or pairing session with someone else can get you over mental blocks better than anything else. If you don't know anyone, try writing some code then post a link to it to the Ruby Talk mailing list with questions. This is a very friendly community, and people are happy to help.

Stuart Ellis
I'd not heard of that book, it looks like an essential read.
Paul Leader
I would put it in my personal top three at the moment (Beginning Ruby by Peter Cooper, Design Patterns in Ruby, Ruby Best Practices by Gregory Brown). Having said that, I have to add that I recommend it because I think that it's good at showing you features and idioms of Ruby in context, and I found it very helpful. It shouldn't be read as some kind of authoritative statement about how to implement particular design patterns in Ruby.
Stuart Ellis