Building a Compiler in JRuby - Chris Umbel at Jan 24th 2012 PittJUG meeting showing how you can create a language using JRuby tools to parse the language an emit JVM bytecode.
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Building a compiler in JRuby
1. Building a Miserably
Fun Compiler in
JRuby.
Chris Umbel
@chrisumbel
http://www.chrisumbel.com
Sunday, January 29, 12
2. Agenda
Ruby/JRuby introduction
Talk background
Building a compiler
Sunday, January 29, 12
3. Ruby
Dynamic, but strongly typed.
Object-oriented
metaprogrammable
Has multiple implementations (MRI,
IronRuby, Rubinius, JRuby)
Has functional features (Higher-order
functions, blocks)
Sunday, January 29, 12
4. Ruby Examples
OO
Data Structures
Sunday, January 29, 12
5. JRuby
Highly compatible Ruby implementation
Written in Java/runs on the JVM
Can consume arbitrary Java libraries
Favorable concurrency characteristics
to CRuby (no GIL)
Sunday, January 29, 12
6. JRuby Examples
Java types
Using .jars
conventions
Sunday, January 29, 12
7. Inspiration
Ian Dees @undees
JRubyConf 2011
JRuby, Not Just for Hard-Headed
Pragmatists Anymore
Author: Using JRuby: Bringing Ruby to
Java
Sunday, January 29, 12
8. JRubyConf
Practical problem solving
Customers, Customers, Customers!
ROI
Sunday, January 29, 12
9. Thnad
Just enough of a fictional
programming language to show how to
write a compiler
https://github.com/undees/thnad
Sort of JavaScript-ey
Allusion to the greatest of classical
literature
Sunday, January 29, 12
10. What We’ll Build
Lisp-style S-expressions
Pure JRuby
Compiles to Java bytecode
Sunday, January 29, 12
11. What We’ll Use
JRuby
Parslet
Kaspar Shiess
Parser in pure Ruby
Bitescript
Charles Nutter
JVM bytecode emitter for JRuby
Sunday, January 29, 12
12. What it wont’ do
Conditionals
Non-parametric locally scoped
variables
OO
Provide Java library support,
standard or otherwise.
Sunday, January 29, 12
13. What It’ll Do
Basic math
Functions
Standard output
Suck!!!
Sunday, January 29, 12