Ruby Under a Microscope : Learning Ruby Internals Through Experiment.
How Ruby Works Under the HoodRuby is a powerful programming language with a focus on simplicity, but beneath its elegant syntax it performs countless unseen tasks. Ruby Under a Microscope gives you a hands-on look at Ruby's core, using extensive diagrams and thorough explanations to show you ho...
Clasificación: | Libro Electrónico |
---|---|
Autor principal: | |
Formato: | Electrónico eBook |
Idioma: | Inglés |
Publicado: |
San Francisco :
No Starch Press,
2013.
|
Temas: | |
Acceso en línea: | Texto completo |
Tabla de Contenidos:
- Foreword; Acknowledgments; Introduction; Who This Book Is For; Using Ruby to Test Itself; Which Implementation of Ruby?; Overview; Chapter 1: Tokenization and Parsing; Roadmap; Tokens: The Words That Make Up the Ruby Language; The parser_yylex Function; Experiment 1-1: Using Ripper to Tokenize Different Ruby Scripts; Parsing: How Ruby Understands Your Code; Understanding the LALR Parse Algorithm; Some Actual Ruby Grammar Rules; Reading a Bison Grammar Rule; Experiment 1-2: Using Ripper to Parse Different Ruby Scripts; Summary; Chapter 2: Compilation; Roadmap; No Compiler for Ruby 1.8.
- Ruby 1.9 and 2.0 Introduce a CompilerHow Ruby Compiles a Simple Script; Compiling a Call to a Block; How Ruby Iterates Through the AST; Experiment 2-1: Displaying YARV Instructions; The Local Table; Compiling Optional Arguments; Compiling Keyword Arguments; Experiment 2-2: Displaying the Local Table; Summary; Chapter 3: How Ruby Executes Your Code; Roadmap; YARV's Internal Stack and Your Ruby Stack; Stepping Through How Ruby Executes a Simple Script; Executing a Call to a Block; Taking a Close Look at a YARV Instruction; Experiment 3-1: Benchmarking Ruby 2.0 and Ruby 1.9 vs. Ruby 1.8.
- Local and Dynamic Access of Ruby VariablesLocal Variable Access; Method Arguments Are Treated Like Local Variables; Dynamic Variable Access; Climbing the Environment Pointer Ladder in C; Experiment 3-2: Exploring Special Variables; A Definitive List of Special Variables; Summary; Chapter 4: Control Structures and Method Dispatch; Roadmap; How Ruby Executes an if Statement; Jumping from One Scope to Another; Catch Tables; Other Uses for Catch Tables; Experiment 4-1: Testing How Ruby Implements for Loops Internally; The send Instruction: Ruby's Most Complex Control Structure.
- Method Lookup and Method DispatchEleven Types of Ruby Methods; Calling Normal Ruby Methods; Preparing Arguments for Normal Ruby Methods; Calling Built-In Ruby Methods; Calling attr_reader and attr_writer; Method Dispatch Optimizes attr_reader and attr_writer; Experiment 4-2: Exploring How Ruby Implements Keyword Arguments; Summary; Chapter 5: Objects and Classes; Roadmap; Inside a Ruby Object; Inspecting klass and ivptr; Visualizing Two Instances of One Class; Generic Objects; Simple Ruby Values Don't Require a Structure at All; Do Generic Objects Have Instance Variables?
- Reading the RBasic and RObject C Structure DefinitionsWhere Does Ruby Save Instance Variables for Generic Objects?; Experiment 5-1: How Long Does It Take to Save a New Instance Variable?; What's Inside the RClass Structure?; Inheritance; Class Instance Variables vs. Class Variables; Getting and Setting Class Variables; Constants; The Actual RClass Structure; Reading the RClass C Structure Definition; Experiment 5-2: Where Does Ruby Save Class Methods?; Summary; Chapter 6: Method Lookup and Constant Lookup; Roadmap; How Ruby Implements Modules; Modules Are Classes.