ruby under the hood - by craig lehmann and robert young - ottawa ruby november 2015 meetup
TRANSCRIPT
![Page 1: Ruby Under The Hood - By Craig Lehmann and Robert Young - Ottawa Ruby November 2015 Meetup](https://reader033.vdocuments.us/reader033/viewer/2022051404/587534391a28abe7728b5cbb/html5/thumbnails/1.jpg)
Ruby Under the Hood
Robert Young Craig Lehmann
Crob 2015
![Page 2: Ruby Under The Hood - By Craig Lehmann and Robert Young - Ottawa Ruby November 2015 Meetup](https://reader033.vdocuments.us/reader033/viewer/2022051404/587534391a28abe7728b5cbb/html5/thumbnails/2.jpg)
What’s under the hood?
I Reading your source
I understanding your program
I memory management
![Page 3: Ruby Under The Hood - By Craig Lehmann and Robert Young - Ottawa Ruby November 2015 Meetup](https://reader033.vdocuments.us/reader033/viewer/2022051404/587534391a28abe7728b5cbb/html5/thumbnails/3.jpg)
What’s under the hood?
Ruby is an Interpreted language.
![Page 4: Ruby Under The Hood - By Craig Lehmann and Robert Young - Ottawa Ruby November 2015 Meetup](https://reader033.vdocuments.us/reader033/viewer/2022051404/587534391a28abe7728b5cbb/html5/thumbnails/4.jpg)
Program Parsing
![Page 5: Ruby Under The Hood - By Craig Lehmann and Robert Young - Ottawa Ruby November 2015 Meetup](https://reader033.vdocuments.us/reader033/viewer/2022051404/587534391a28abe7728b5cbb/html5/thumbnails/5.jpg)
Syntax Tree
![Page 6: Ruby Under The Hood - By Craig Lehmann and Robert Young - Ottawa Ruby November 2015 Meetup](https://reader033.vdocuments.us/reader033/viewer/2022051404/587534391a28abe7728b5cbb/html5/thumbnails/6.jpg)
The ruby Interpreter?
The Ruby interpreter implements a virtual machine.
![Page 7: Ruby Under The Hood - By Craig Lehmann and Robert Young - Ottawa Ruby November 2015 Meetup](https://reader033.vdocuments.us/reader033/viewer/2022051404/587534391a28abe7728b5cbb/html5/thumbnails/7.jpg)
Bytecode Interpreter
I The main VM execution loop.
I Maps bytecodes to executable native instructions.
I Implements a virtual stack machine.
I Individual bytecodes implemented in C.
![Page 8: Ruby Under The Hood - By Craig Lehmann and Robert Young - Ottawa Ruby November 2015 Meetup](https://reader033.vdocuments.us/reader033/viewer/2022051404/587534391a28abe7728b5cbb/html5/thumbnails/8.jpg)
s
![Page 9: Ruby Under The Hood - By Craig Lehmann and Robert Young - Ottawa Ruby November 2015 Meetup](https://reader033.vdocuments.us/reader033/viewer/2022051404/587534391a28abe7728b5cbb/html5/thumbnails/9.jpg)
Push down Stack
![Page 10: Ruby Under The Hood - By Craig Lehmann and Robert Young - Ottawa Ruby November 2015 Meetup](https://reader033.vdocuments.us/reader033/viewer/2022051404/587534391a28abe7728b5cbb/html5/thumbnails/10.jpg)
Call Stack example and compiled method
![Page 11: Ruby Under The Hood - By Craig Lehmann and Robert Young - Ottawa Ruby November 2015 Meetup](https://reader033.vdocuments.us/reader033/viewer/2022051404/587534391a28abe7728b5cbb/html5/thumbnails/11.jpg)
Three Stacks
![Page 12: Ruby Under The Hood - By Craig Lehmann and Robert Young - Ottawa Ruby November 2015 Meetup](https://reader033.vdocuments.us/reader033/viewer/2022051404/587534391a28abe7728b5cbb/html5/thumbnails/12.jpg)
Control Frame Data Structure
![Page 13: Ruby Under The Hood - By Craig Lehmann and Robert Young - Ottawa Ruby November 2015 Meetup](https://reader033.vdocuments.us/reader033/viewer/2022051404/587534391a28abe7728b5cbb/html5/thumbnails/13.jpg)
Class lookup? What happens when you want to create anobject?
class Person
end
arbitraryConstant = "zZz"
![Page 14: Ruby Under The Hood - By Craig Lehmann and Robert Young - Ottawa Ruby November 2015 Meetup](https://reader033.vdocuments.us/reader033/viewer/2022051404/587534391a28abe7728b5cbb/html5/thumbnails/14.jpg)
A class is listed in a datastructure full of constants
class Person
end
arbitraryConstant = "zZz"
![Page 15: Ruby Under The Hood - By Craig Lehmann and Robert Young - Ottawa Ruby November 2015 Meetup](https://reader033.vdocuments.us/reader033/viewer/2022051404/587534391a28abe7728b5cbb/html5/thumbnails/15.jpg)
A class is listed in a datastructure full of constants
![Page 16: Ruby Under The Hood - By Craig Lehmann and Robert Young - Ottawa Ruby November 2015 Meetup](https://reader033.vdocuments.us/reader033/viewer/2022051404/587534391a28abe7728b5cbb/html5/thumbnails/16.jpg)
constants with the same name as a class? That’s a No No
class Person
end
Person = "hello"
# warning: already initialized constant Person
![Page 17: Ruby Under The Hood - By Craig Lehmann and Robert Young - Ottawa Ruby November 2015 Meetup](https://reader033.vdocuments.us/reader033/viewer/2022051404/587534391a28abe7728b5cbb/html5/thumbnails/17.jpg)
Intro to GC
I What is garbage collection
I Example of how a simple GC algorithm
![Page 18: Ruby Under The Hood - By Craig Lehmann and Robert Young - Ottawa Ruby November 2015 Meetup](https://reader033.vdocuments.us/reader033/viewer/2022051404/587534391a28abe7728b5cbb/html5/thumbnails/18.jpg)
What is garbage collection?
I Automatic memory management
![Page 19: Ruby Under The Hood - By Craig Lehmann and Robert Young - Ottawa Ruby November 2015 Meetup](https://reader033.vdocuments.us/reader033/viewer/2022051404/587534391a28abe7728b5cbb/html5/thumbnails/19.jpg)
What is garbage collection?
I Allocate and free objectsI Keep track of objects currently in use
I Run finalizers
![Page 20: Ruby Under The Hood - By Craig Lehmann and Robert Young - Ottawa Ruby November 2015 Meetup](https://reader033.vdocuments.us/reader033/viewer/2022051404/587534391a28abe7728b5cbb/html5/thumbnails/20.jpg)
A simple GC example - Mark and Sweep
![Page 21: Ruby Under The Hood - By Craig Lehmann and Robert Young - Ottawa Ruby November 2015 Meetup](https://reader033.vdocuments.us/reader033/viewer/2022051404/587534391a28abe7728b5cbb/html5/thumbnails/21.jpg)
A simple GC example - Mark and Sweep
![Page 22: Ruby Under The Hood - By Craig Lehmann and Robert Young - Ottawa Ruby November 2015 Meetup](https://reader033.vdocuments.us/reader033/viewer/2022051404/587534391a28abe7728b5cbb/html5/thumbnails/22.jpg)
A simple GC example - Mark and Sweep
![Page 23: Ruby Under The Hood - By Craig Lehmann and Robert Young - Ottawa Ruby November 2015 Meetup](https://reader033.vdocuments.us/reader033/viewer/2022051404/587534391a28abe7728b5cbb/html5/thumbnails/23.jpg)
A simple GC example - Mark and Sweep
![Page 24: Ruby Under The Hood - By Craig Lehmann and Robert Young - Ottawa Ruby November 2015 Meetup](https://reader033.vdocuments.us/reader033/viewer/2022051404/587534391a28abe7728b5cbb/html5/thumbnails/24.jpg)
A simple GC example - Mark and Sweep
![Page 25: Ruby Under The Hood - By Craig Lehmann and Robert Young - Ottawa Ruby November 2015 Meetup](https://reader033.vdocuments.us/reader033/viewer/2022051404/587534391a28abe7728b5cbb/html5/thumbnails/25.jpg)
A simple GC example - Mark and Sweep
![Page 26: Ruby Under The Hood - By Craig Lehmann and Robert Young - Ottawa Ruby November 2015 Meetup](https://reader033.vdocuments.us/reader033/viewer/2022051404/587534391a28abe7728b5cbb/html5/thumbnails/26.jpg)
A simple GC example - Mark and Sweep
![Page 27: Ruby Under The Hood - By Craig Lehmann and Robert Young - Ottawa Ruby November 2015 Meetup](https://reader033.vdocuments.us/reader033/viewer/2022051404/587534391a28abe7728b5cbb/html5/thumbnails/27.jpg)
A simple GC example - Mark and Sweep