• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Building a compiler in JRuby
 

Building a compiler in JRuby

on

  • 625 views

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.

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.

Statistics

Views

Total Views
625
Views on SlideShare
602
Embed Views
23

Actions

Likes
0
Downloads
6
Comments
0

4 Embeds 23

http://eventifier.co 16
http://franklinchen.com 5
http://www.eventifier.co 1
http://eventifier.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Building a compiler in JRuby Building a compiler in JRuby Presentation Transcript

    • Building a Miserably Fun Compiler in JRuby. Chris Umbel @chrisumbel http://www.chrisumbel.comSunday, January 29, 12
    • Agenda Ruby/JRuby introduction Talk background Building a compilerSunday, January 29, 12
    • 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
    • Ruby Examples OO Data StructuresSunday, January 29, 12
    • 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
    • JRuby Examples Java types Using .jars conventionsSunday, January 29, 12
    • Inspiration Ian Dees @undees JRubyConf 2011 JRuby, Not Just for Hard-Headed Pragmatists Anymore Author: Using JRuby: Bringing Ruby to JavaSunday, January 29, 12
    • JRubyConf Practical problem solving Customers, Customers, Customers! ROISunday, January 29, 12
    • 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 literatureSunday, January 29, 12
    • What We’ll Build Lisp-style S-expressions Pure JRuby Compiles to Java bytecodeSunday, January 29, 12
    • What We’ll Use JRuby Parslet Kaspar Shiess Parser in pure Ruby Bitescript Charles Nutter JVM bytecode emitter for JRubySunday, January 29, 12
    • What it wont’ do Conditionals Non-parametric locally scoped variables OO Provide Java library support, standard or otherwise.Sunday, January 29, 12
    • What It’ll Do Basic math Functions Standard output Suck!!!Sunday, January 29, 12
    • sucklangSunday, January 29, 12
    • Language Components Simple Atoms (identifiers; literal strings and integers) Lists Function callsSunday, January 29, 12
    • sucklang Code Sample (defun foo [x y] (+ x y)) (println "result is " (foo 6 9))Sunday, January 29, 12
    • Parts Parser Transmogrifier CompilerSunday, January 29, 12
    • Step 1 Parser Numbers Basic list Whitespace handlingSunday, January 29, 12
    • Step 2 Parser ExpressionsSunday, January 29, 12
    • Step 3 Parser Identifiers Atoms Lists in lists Operators are IdentifiersSunday, January 29, 12
    • Step 4 Parser StringsSunday, January 29, 12
    • Step 5 Parser VectorsSunday, January 29, 12
    • Step 6 Transmogrifier ASTSunday, January 29, 12
    • Step 7: STOP! javap - Java disassemblerSunday, January 29, 12
    • Step 8 bitescript exampleSunday, January 29, 12
    • Step 9 compiler java requires/imports emitting of simple typesSunday, January 29, 12
    • Step 10 emitting of functions + println defun callsSunday, January 29, 12
    • What It Did Parsed S-expressions into an AST Compiled AST to JVM bytecode Sucked (a lot of assumptions)Sunday, January 29, 12
    • What We’ve Learned Parslet Bitescript JVM innardsSunday, January 29, 12
    • Thank you!Sunday, January 29, 12