Hacker News new | past | comments | ask | show | jobs | submit login
Ruby hacking guide (ruby-hacking-guide.github.io)
155 points by steveklabnik on Aug 12, 2013 | hide | past | favorite | 22 comments

Anyone interested in this kind of content should see Pat Shaughnessy's Ruby Under a Microscope book: http://patshaughnessy.net/ruby-under-a-microscope

It's the closest thing we have to a new Ruby Hacking Guide. It's a somewhat gentler, more approachable treatment of the subject matter, but no less awesome.

Shaughnessy also has a number of blog posts on his site that dive into the same kind of details covered in his book (and RHG).

Pat is awesome and a great pedagogue. I second this, his articles, books and guides are absolute must-reads for the Ruby enthusiast.

It's only a very light, high level overview (so not one for experienced MRI hackers) but I recorded a 30 minute screencast with Pat a few months ago touring the MRI codebase: http://www.rubyinside.com/ruby-mri-code-walk-tour-6020.html

There is a quote: "Rails is like Bible. Unless you are a Saint, you do not need to understand it and you probably will never understand; all you need to do is to believe in it."

Ruby changed my life, it changed my mindset.

Just how big are the differences between Ruby 1.7.3 (the topic of this hacking guide) and the current version?

Has anything fundamental changed in how Ruby manages objects or does garbage collection?

I suspect it has changed considerably, especially with the change from full interpreter to VM in Ruby 1.9.

Garbage collection has changed from regular mark-and-sweep to lazy sweep to using bitmap marking.

Doesn't mention how @@ is evil. @@ are not your usual class variables. @@ should be avoided in most programs.

This guide is specifically about the internals of and "hacking" the Ruby MRI -- it's not about hacking Ruby in general.

Unless there is something specific about the MRI implementation and class variables?

Yep, as Martin Fowler nicely points out in http://martinfowler.com/bliki/ClassInstanceVariable.html

"A class variable is shared across all instances of a class, which includes all subclasses". Can be surprising when using inheritance.

Well, that behavior is not surprising or anything. Many other languages have some kind of concept of a class instance variable (such as Python).

You're right saying that it's the proper behavior for such a semantic. But the problem is, @@ notation can make you forget you're not manipulating something that might be shared and re-assigning an ancestor class variable accidentally, messing up its behavior. And while it's common to check for method overrides, class variable overrides is not something that is checked very frequently.

It is the kind of bug that can be very long to figure out, since when you make this mistake, it's very likely because you forgot to think about this behavior.

This is so awesome. I have been waiting for this to finish translating for some time now. When I read the first two chapters almost a year ago, I was pleased by how much detail the author goes into to explain the inner workings of Ruby. I recommend it to everyone.

This is extremely cool, I am becoming more interesting in the idea of trying to write a small toy language and articles like this excite and inform, great work.

It would be great to host an up-to-date PDF with this, too. (Any interest in publishing this when it's at 1.0?)

Sounds like a good idea. After a considerable length of inactivity we've had some great translation contributions from github use ocha-. Taking it pretty much to the finish line. I'll do some proofreading too, as I know he's not a native English speaker. I guess epub formats etc would make sense too.

I'm happy to contribute, too -- let me know if you're interested in any help with editing or creating/maintaining a PDF.

Absolutely :) https://github.com/ruby-hacking-guide/ruby-hacking-guide.git... I'm taking the approach of trusting first, so if your first PR isn't insane, then no reason not to add you to the team.

Thanks for taking the time and effort to create this Steve! I'm always looking for more beginner and non-beginner resources to direct my friends too!

I did not create this, I just saw the link float by Twitter.

is there something like this for Scala ?

Or for python?

Applications are open for YC Winter 2022

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact