• Complain

Pat Shaughnessy - Ruby Under a Microscope

Here you can read online Pat Shaughnessy - Ruby Under a Microscope full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. year: 2012, genre: Computer. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

Pat Shaughnessy Ruby Under a Microscope

Ruby Under a Microscope: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "Ruby Under a Microscope" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

Pat Shaughnessy: author's other books


Who wrote Ruby Under a Microscope? Find out the surname, the name of the author of the book and a list of all author's works by series.

Ruby Under a Microscope — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "Ruby Under a Microscope" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
Ruby Under a
Microscope
Learning Ruby Internals
Through Experiment
Version 1.1 - November 11, 2012
Pat Shaughnessy

Copyright 2012 Pat Shaughnessy

Acknowledgments

I could never have finished a project like this without the support of manydifferent people!

First of all, thanks to Satty Bhens and everyone at McKinsey for giving me theflexibility to write a book and keep my day job at a great company. AlexRothenberg and Daniel Higginbotham gave me invaluable advice, suffered throughreading many early drafts and helped me throughout the process. Alex alsoproofread the rough draft, and Daniel put together a fantastic landing page forthe book thank you guys! Special thanks to Xavier Noria who took an interestin the project early on, gave me the inspiration behind Experiment 3-3 and thengave me fantastic feedback on the entire rough draft. Thank you also toSantiago Pastorino who reviewed the rough draft as well. Also thank you to JillCaporrimo, Prajakta Thakur, Yvannova Montalvo, Divya Ganesh and Yanwing Wong my proofreading SWAT team self publishing would have been much harderwithout your help. Finally, without the constant encouragement and supportPeter Cooper has given me this year, I probably never would have even attemptedto write this book thank you Peter.

Dedicated to my wife Cristina, my daughter Ana and my son Liam thanks forsupporting me all along. Special thanks to Ana for the cover art!

Preface
My approach in this book: theory and experiment
It doesnt matter how beautiful your theory is, it doesnt matter how smartyou are. If it doesnt agree with experiment, its wrong. Richard Feynman

In Ruby Under a Microscope Im going to teach you how Ruby works internally.Ill use a series of simple, easy to understand diagrams that will show youwhat is happening on the inside when you run a Ruby program. Like a physicistor chemist, Ive developed a theory about how things actually work based onmany hours of research and study. Ive done the hard work of reading andunderstanding Rubys internal C source code so you dont have to.

But, like any scientist, I know that theory is worthless without some hardevidence to back it up. Therefore after explaining some aspect of Rubyinternals, some feature or behavior of the language, Ill perform an experimentto prove that my theory was correct. To do this Ill use Ruby to test itself!Ill run some small Ruby test scripts to see whether they produce the expectedoutput or whether they run as fast or as slowly as I expect. Well find out ifRuby actually behaves the way my theory says it should. Since these experimentsare written in simple Ruby, you can try them yourself.

A travel journal

Before teaching you how Ruby works internally, I had to learn it myself. To dothis, I went on a six month journey through MRI Rubys internal implementation.I also took a few side trips to visit JRuby and Rubinius. I started by simplyreading and studying Rubys C source code; later I continued by looking at howit actually functions by setting breakpoints and stepping through the codeusing the GDB debugger. Finally, I modified and recompiled the C source code tobe sure I thoroughly understood how it worked. Often I added printfstatements to write out debug information; occasionally I changed the codedirectly to see what would happen if it were written differently.

Ruby Under a Microscope is my travel journal; Ive written everything Ivelearned during this long journey. I hope the following pages give you the samesense of beauty and excitement which I found and felt as I discovered oneamazing thing after another.

Rubys internal C source code is like a foreign country where people speak alanguage you dont understand. At first its difficult to find your way andunderstand the people around you, but if you take the time to learn somethingof the local language you can eventually come to know the fascinating people,places, food and culture from what was previously uncharted territory.

What this book is not

Ruby Under a Microscope is not a beginners guide to learning Ruby. Instead, inRuby Under a Microscope I assume you already know Ruby and use it on a dailybasis. There are many great books on the market that teach Ruby far better thanI ever could.

Ruby Under a Microscope is also not a newer, updated version of the RubyHacking Guide. As the name implies, the RubyHacking Guide is a guide for C programmers who want to understand Rubysinternal C implementation at a detailed level. Its an invaluable resource forthe Ruby community and required reading for those who want to read and work onthe MRI source code. Ruby Under a Microscope, on the other hand, is intended togive Ruby developers a high level, conceptual understanding of how Ruby worksinternally. No knowledge of C programming is required.

For those people familiar with C, however, I will show a few vastly simplifiedsnippets of C code to give you a more concrete sense of whats going on insideRuby. Ill also indicate which MRI C source code file I found the snippet in;this will make it easier for you to get started studying the MRI C codeyourself if you ever decide to. Like this paragraph, Ill display thisinformation on a yellow background.

If youre not interested in the C code details, just skip over these yellowsections.

Why bother to study Ruby internals?

Everyday you need to use your car to drive to work, drop your kids off atschool, etc., but how often have you ever thought about how your car actuallyworks internally? When you stopped at that red light on your way to the grocerystore last weekend were you thinking about the theory and engineering behindthe internal combustion engine? No, of course not! All you need to know aboutyour car is which pedal is which, how to turn the steering wheel and a fewother important details like shifting gears, turn indicator lights, etc.

At first glance, studying how Ruby is implemented internally is no different.Why bother to learn how the language was implemented when all you need to do isuse it? Well, in my opinion, there are a few good reasons why you should takethe time to study the internal implementation of Ruby:

  • Youll become a better Ruby developer. By studying how Ruby works internally,you can become more aware of how Yukihiro Matsumoto and the rest of the Rubycore team intended the language to be used. Youll be a better Ruby developerby using the language as it was intended to be used, and not just in the wayyou prefer to use it.

  • You can learn a lot about computer science. Beyond just appreciating thetalent and vision of the Ruby core team, youll be able to learn from theirwork. While implementing the Ruby language, the core team had to solve many ofthe same computer science problems that you might have to solve in your job oropen source project.

  • Its fun! I find learning about the algorithms and data structures Ruby usesinternally absolutely fascinating, and I hope you will too.

Roadmap

The journey I took through Rubys internal implementation was a long one, and Icovered a lot of ground. Heres a quick summary of what I will teach you aboutin Ruby Under a Microscope:

I start in Chapter 1, Tokenization, Parsing and Compilation, by describing howRuby reads in and processes your Ruby program. When you type rubymy_script.rb at the console and press ENTER, what happens? How doesRuby make sense of the text characters you typed into your Ruby program? Howand why does Ruby transform your Ruby code from one format to another andanother? I find this to be one of the most fascinating areas of Ruby internalsand of computer science.

Next in Chapter 2, How Ruby Executes Your Code, I pick up the story from whereChapter 1 left off and describe how Rubys virtual machine, called Yet AnotherRuby Virtual Machine (YARV) executes your program. How does YARV actually executeyour Ruby code? How does it keep track of local variables? How does YARVexecute if statements and other control structures?

Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Ruby Under a Microscope»

Look at similar books to Ruby Under a Microscope. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «Ruby Under a Microscope»

Discussion, reviews of the book Ruby Under a Microscope and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.