Ruby Under a Microscope: Learning Ruby Internals through Experiment
patshaughnessy.net
patshaughnessy.net
Because I've already learned so much from this articles, I was eager to buy this when I saw the announcement in my inbox.
A lot of hard work! I do the hard work so you don't have to :)
Why study Ruby internals in the first place? Here are my reasons (from the book's preface): - By studying how Ruby works internally, you'll get a deeper understanding of the language and become a better Ruby developer. - You can learn a lot from the Ruby core team. There is some amazing stuff inside of Ruby, and Ruby's implementation might help you while solving your own coding problems. - It's fun! It's just super-fascinating stuff!
I learned a lot of stuff about Ruby usage that is not documented. You can read more in the book… :)
Thanks for your interest, and for asking!
I'm at a point in my Ruby career where I've begun peeking under all the abstractions I use after hitting performance bottlenecks. Performance has even led me to all sorts of new tools like using a SAX XML parser (using the Ox gem) instead of trying to walk the XML DOM in memory with Nokogiri.
Nokogiri has SAX capabilities as well (http://nokogiri.org/Nokogiri/XML/SAX/Document.html). Any reason not to use them, especially as Nokogiri also has native JRuby support?
I had just wanted to speed up my XML parser and stumbled upon a Nokogiri vs Ox benchmark (http://www.ohler.com/dev/xml_with_ruby/xml_with_ruby.html). So I tried Ox.
Here's my effort to benchmark Nokogiri vs Ox, DOM vs SAX parsing on an 80mb XML file with 38k nodes: https://gist.github.com/3977120
Ox DOM: 6 seconds (550mb)
Ox SAX: 6 seconds (12mb)
Nokogiri DOM: 13 seconds (900mb)
Nokogiri SAX: 24 seconds (11.8mb)
I'm no benchmarking wizard, though.