5 ms·
Ruby Under a Microscope: Learning Ruby Internals through Experiment
- pat_shaughnessy 14y agoThanks for posting this :) ...I'm happy to answer any questions anyone has.
- Who828 14y agoHey pat, how do you understand the internal code so well ? I read your free chapter on Ruby's Hash table and I loved every bit of it. It would be great if you can share the process you go through when you read the source code, so maybe I can apply it in the future. By the way, congrats for the release !
- saturnflyer 14y agoI suspect buying the book might yield some info like that.
- pat_shaughnessy 14y agoHey thanks for asking - and yes, in the preface to the book I do explain how I figure this stuff out. But basically I: - study the C code for a long time - step through it in GDB a lot - add printf statements and recompile it to print out debug/trace info - actually change it to see what would happen if things were written differently. A lot of hard work! I do the hard work so you don't have to :)
- milesf 14y agoYour process is something I'd like an ebook or screencast about. Perhaps others would find it interesting as well.
- pat_shaughnessy 14y agoYea I've thought about that. Let me see what I can do... :) thanks.
- petercooper 14y agoThe code for MRI is.. idiomatic, but actually pretty easy to read. I last did C full time in the 90s and so am mostly just a 'reader' now but it's not hard to follow, although some of the reasoning behind doing things a certain way in MRI is unfathomable.. ;-)
- JulianWasTaken 14y agoI don't understand the wording of your first sentence. Did you mean "idiotic" or?
- JonnieCache 14y agohttps://encrypted.google.com/search?q=define%3Aidiom https://encrypted.google.com/search?q=define%3Aidiom
- JulianWasTaken 14y agoYes, thanks. I know what idiomatic means, but the OP either does not or just wrote an awkward sentence.
- deleted 14y ago[deleted]
- omaranto 14y agoPat probably meant 'idiosyncratic' instead of 'idiomatic' (unless it's a non-idiomatic use of 'idiomatic').
- petercooper 14y ago'Idiosyncratic' is clearer, though 'idiomatic' is valid and what I wished to say, but in its secondary definition: http://www.merriam-webster.com/dictionary/idiomatic http://www.merriam-webster.com/dictionary/idiomatic (see def 2)
- 14y ago
- up_and_up 14y agoYou should move the purchase button higher on the page or put multiple buttons. My immediate assumption was it was not ready yet until I scrooooled way down to find the purchase link.
- marizmelo 14y ago+1 for this, I thought the comments were actual comments about the book. Usually comments are placed on the bottom of the page.
- IheartApplesDix 14y agoWhat is the purpose of this book? Is Ruby internal workings not widely known or understood, or is this more about how to reverse engineer a software stack? Did you discover anything that is not documented in Ruby docs?
- pat_shaughnessy 14y agoYes - Ruby's internal workings are very mysterious to most people. While the C source code behind Ruby is open source, it's hard to read and understand for most people. In Ruby Under a Microscope, I explain how Ruby works internally… without assuming you know anything about C programming. 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!
- vaneyckt 14y agoIt's just raining amazing Ruby books lately. Last week there was Working With TCP Sockets and now this. I'm having trouble finding time for them all :).
- danneu 14y agoCool, I just bought Ruby Under a Microscope and then looked up http://workingwithtcpsockets.com/ http://workingwithtcpsockets.com/ to buy that book, too. 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.
- Argorak 14y agoJust out of curiosity: Nokogiri has SAX capabilities as well (http://nokogiri.org/Nokogiri/XML/SAX/Document.html http://nokogiri.org/Nokogiri/XML/SAX/Document.html). Any reason not to use them, especially as Nokogiri also has native JRuby support?
- danneu 14y agoIt was just for fun. Both SAX APIs are sorta nebulous as it is to someone like me who's been so used to an abundance of tutorials on the tools I regularly use. Ox's SAX API was better, though. 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 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 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.
- Argorak 14y agoThank you!
- jstorimer 14y agoBefore Pat announced he was writing an ebook, I was following the articles he wrote on his blog. He has a real knack for making difficult concepts easy to understand using diagrams and simple language. And on top of that, he asks interesting questions. You might think that Ruby internals are a dull topic, but everything I've seen him cover has fascinated me. Because I've already learned so much from this articles, I was eager to buy this when I saw the announcement in my inbox.
- Willy_nourson 14y agoAh weird, I always assumed "modern" programming languages were bootstrapped (for all the advantages that it implies), didn't know it's not the case for Ruby. Good to know.
- randomdata 14y agoI guess that depends on what you consider Ruby. MRI isn't, but Rubinius is.
- ryandelk 14y agoGreat work, Pat!
- elliotlai 14y ago"Ruby Under a Microscope" I was expecting some beautiful images ... nevermind, my bad
- petercooper 14y agoEnjoy this one: http://micro.magnet.fsu.edu/birthstones/pages/ruby.html http://micro.magnet.fsu.edu/birthstones/pages/ruby.html
- pat_shaughnessy 14y agoNice! I think I have my design concept for RUAM part 2! :)
- marizmelo 14y agowhy not make available on Amazon as kindle version? I always think twice before share my card info on random websites.
- petercooper 14y agoI'd usually agree with a comment like this but in this case, it has so many (useful) color diagrams that while it wouldn't be impossible to put on the Kindle, I don't think you'd get an amazing experience. Could be wrong though!
- marizmelo 14y agoSince kindle fire, the books can be posted in colors :)
- petercooper 14y agoThat's true, but I suspect the vast majority of Kindle users and buyers are stuck on 6" greyscale screens which aren't great for diagrams or code without a lot of care. "Source code looks horrible on the Kindle edition!" is one of the most common complaints I've seen on Kindle books so far, but it's definitely getting better.
- pat_shaughnessy 14y agoFYI My download kit includes a mobi file, and it looks acceptable on the kindle. But yes, in black and white you'll lose a lot of the value of the diagrams I drew.
- IheartApplesDix 14y agoI would also like to see a version I can purchase through my Kindle as well.
- squidsoup 14y agoIs anyone aware of a similar book covering Python internals at this level of depth?