Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Getting Fancy on Rubinius

bakkdoor
October 01, 2011

Getting Fancy on Rubinius

RubyConf 2011 talk on Fancy and Rubinius.
http://www.fancy-lang.org

bakkdoor

October 01, 2011
Tweet

More Decks by bakkdoor

Other Decks in Programming

Transcript

  1. Motivation • A language & implementation that is: • Easy

    to understand and extend • Consistent (no “magic”) • Well documented • Noob friendly • Without ambiguities (syntax & semantics) 3 Friday, September 30, 11
  2. Inspiration: Smalltalk • Object oriented • Pure message passing semantics

    • Limited syntax and special keywords • Dynamic • Class based • Reflective 5 Friday, September 30, 11
  3. Inspiration: Ruby • TMTOWTDI • File based • Embrace Unix

    • Similar literal syntax • Naming conventions • It’s a script! (Class / Method defs) 6 Friday, September 30, 11
  4. Inspiration: Io / Erlang • Lock-free concurrency using: • Asynchronous

    message sends • Futures • Actors 7 Friday, September 30, 11
  5. Async & Actors • Actors: Asynchronous message passing • Asynchronous

    object-orientation! • Any object can be an actor: • Interested in the value? Use a FutureSend: 12 Friday, September 30, 11
  6. Be friendly • Friendly coexistance with Ruby • Reuse available

    libraries, possibly fancy-fied if used a lot • Explicit syntax for calling out to Ruby methods • Namespacing of Fancy methods 16 Friday, September 30, 11
  7. FancySpec • RSpec-like testing library • Light-weight (~ 430 loc)

    • Testcases for all of Standard Library and expected runtime behaviour of the language • Helped a lot during migration from old C++ implementation to Rubinius 26 Friday, September 30, 11
  8. Dynamic scoping • Popular in Lisp dialects • Implemented using

    thread locals • Used for things like stdio: 30 Friday, September 30, 11
  9. Tooling • Editor support for • Emacs • Textmate •

    Vim? (Brian?) • Debugging (shiny backtraces!) • fancy -cv foo.fy 32 Friday, September 30, 11
  10. Why Rubinius? • — Ruby • — Dynamic Languages •

    Hackable • Understandable • Transparent • Culturally a good fit 34 Friday, September 30, 11
  11. Compiler • Reusing as much as possible from Rubinius’ Compiler

    API • Subclassing and extending • C-extension based parser (bison) • Coming soon: kpeg based parser • Most syntax gets compiled into dynamic message sends that are executed at runtime 35 Friday, September 30, 11
  12. Applications • DSLs • Parser Combinator library • Storm •

    Encapsulation-preserving OO Pattern Matching 38 Friday, September 30, 11
  13. Pattern Matching • Right now (master): • Simple, but useful

    pattern matching • Uses === method (like Ruby’s case/when expressions) 43 Friday, September 30, 11
  14. Pattern Matching • In the (maybe distant) future: • Pure

    OO Pattern Matching that preserves encapsulation (patterns branch) • Keyword patterns • Pattern literals • Dynamic bindings See: Felix Geller, Robert Hirschfeld and Gilad Bracha: Pattern Matching for an Object-Oriented Dynamically Typed Programming Language 45 Friday, September 30, 11
  15. And much more... Travis CI FancyIRC Class-based Mixins Default args

    Local returns C-extensions fyi ifancy Exception Handling 47 Friday, September 30, 11
  16. Conclusions • Rubinius is a great platform to experiment with

    (dynamic) language implementations • Innovations & interesting ideas within the Ruby ecosystem • Composability by simplicity and homogeneity • Explore, fail, retry - win! 48 Friday, September 30, 11
  17. Other cool stuff • Atomy ( http://rubini.us/projects/ ) • Ian

    Piumarta: Building Your Own Dynamic Language* • http://createyourproglang.com/ * http://www.youtube.com/watch?v=cn7kTPbW6QQ 49 Friday, September 30, 11