Hacker News new | ask | show | jobs
by why-el 5121 days ago
I would like to get some advice from experienced Ruby hackers. Currently I am picking up Ruby through rails, which I am assuming is fairly common. I want to know the downsides to this and what people did to supplement their ruby knowledge beyond Rails. I eventually would like to write my own gems, contribute to open source, and so forth. I am absolutely not satisfied with just consuming Rails.
10 comments

I'd highly recommend The Well Grounded Rubyist by David Black http://www.manning.com/black2/ if you want a good intro to Ruby, I found it a much better intro than the Pickaxe
I work with David and he is totally awesome. He's giving a talk at the NYC.rb meetup on June 12 called "The Well-Grounded Nuby" which is an intro tour to Ruby. Here's the meetup link. http://www.meetup.com/NYC-rb/events/57344932/
His previous book Ruby for Rails is just as good an introduction to Ruby.
In fact, "The Well Grounded Rubyist" is a "reworking" of "Ruby for Rails". The author mentions this relationship between the books in his "about this book" section at the beginning of "The Well Grounded Rubyist".
I found Ruby for Rails very helpful when I was getting started. It helped separate Rails "magic" from the underlying language aspects in a way that most other books did not.
I can't recommend The Well-Grounded Rubyist higher myself and totally agree regarding it's accessibility in comparison to the Pickaxe. This is the book that taught me programming.
The best advice I can give is get to know Ruby well - don't just focus on Rails in the beginning. Eloquent Ruby by Russ Olsen is a great read and will give you a deeper understanding if you've got the basics down. Also, the PragProg book Metaprogramming in Ruby is a great intro to metaprogramming.
I can't recommend Eloquent Ruby at all: http://news.ycombinator.com/item?id=3803016
Really? Eloquent Ruby is one of the best Ruby books I've read - Russ Olsen is one of the best and most well respected technical writers out there. Design Patterns in Ruby is also excellent.
Agreed, Eloquent Ruby is a smashing book and I recommend it to all of my own Ruby students. I don't use it as an official textbook but I might as well do. Superb book.
I had this discussion already (see the link). Maybe it's a matter of taste but I think this book has some severe weaknesses and thus, I wouldn't recommend it.
No offence but perhaps you bought the wrong book? Eloquent Ruby is about style and design patterns, it's almost about the philosophy of Ruby code, best practises, aesthetics and the author's experiences.

Books like that are fundamentally about taste and style and technique; they can't really be "wrong". You might disagree with the author and think you have a superior approach but to say that randomly googling the topic led you to a "better" explanation tells me that perhaps you were looking at the wrong book in the first place.

Again the same discussion. I did not buy the wrong book. I knew exactly what I wanted

Don't get me wrong, your reply is kind of abstract and philosophical. I explained why this book just failed and should not be recommended (mainly the style and really, really awkward, wacky examples) and I face abstract replies. Sometimes I think these comments and Amazon reviews are all faked by SEO/Webspam people driving the book's sale (no offence, but because of guys like you recommending a totally weak book over and over without the slightest criticism I bought this crappy book and it's a really bad and frustrating experience). And again: I am not dumb or do not know what I wanted or bought (btw this is bad discussion style to implicitly question the buyer intent or skills, it was very indirect but still there).

Spend a week just learning Ruby before doing anything with Rails. There's a huge learning curve to Rails - learning the language simultaneously will just make you frustrated.
Probably the biggest downside is that you'll incorrectly assume that some parts of Rails are actually part of Ruby. Then you'll miss them when they're not there and possibly feel a small amount of sadness. Oh the humanity! :)

The big one is ActiveSupport. There are many extensions to common Ruby objects like String, Enumerable, Hash, etc. For example. In Rails, you'll use something like this quite frequently:

    some_string_var.parameterize
The parameterize method is part of ActiveSupport::Inflector. As you start to write Ruby outside of Rails, you'll come across occasions where you'd really like to use ActiveSupport methods like these, but fortunately, RubyGems and Bundler make that easy.

EDIT: My last paragraph isn't clear enough that you can use ActiveSupport outside of Rails by simply adding the gem to your Gemfile and requiring it in the relevant location. The downside is that you create a dependency. If you are writing ad hoc scripts, this can be an annoyance, but if you package all your scripts as a Gem using something like Thor, dependencies won't be a problem.

Thanks. I was expecting somebody to mention this. What I am currently doing is investigating most of the code I use, be it methods, classes, and so on. It takes me off of the main task, but I think based on what you experienced its a good thing. I have a folder for rails source code in my editor and I usually just hang out there. ;) Hopefully this will mitigate the problem.
Any gem can use ActiveSupport as a dependency, just like Rails does
Added a clarification edit. Thanks!
I'd recommend reading Eloquent Ruby by Russ Olsen. It's a great after-Rails intro to Ruby and uses a lot of specific examples from the framework to highlight how Ruby features make some of the magic happen in Rails.
I wonder if this can be read hand in hand with Ruby Best Practices. After all Matz wrote the preface to this one so I have to give it a go.
I came up the ranks like you, and actually abandoned Rails but stuck with Ruby for a while longer. I supplemented my Ruby skills the same way I do with most programming languages - I had an end-state in mind, and I coded towards it. In my case, this was a script and wrapper based around the MediaWiki API, but that doesn't matter. It just needs to be something doable. At that point, it's just a 10,000 hour play - code until you get it. I spend a lot of time with the docs open, but eventually that goes down, which is when you know you're getting it.
If you have a choice in framework, I'd actually recommend not learning Ruby through Rails. I'd learn it through Sinatra. Sinatra is a lightweight web framework (Rails is a heavyweight), and it has a lot less "magic", so it's more plain Ruby and less connecting framework components together.

Not knocking Rails, it's just that you'll get a really narrow and somewhat skewed perception of Ruby if you learn it through Rails (you'll have no way of easily separating the Rails magic from plain Ruby as you learn things).

I've put together a list of some of the better learning resources all in one place if anyone's interested: http://news.ycombinator.com/item?id=4070379
I've also heard good things about the PragProg Ruby course - its $199 but is supposed to be excellent, though I have no direct personal experience with the course.
Read everything from Gregory Brown.