• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Mirah Talk for Boulder Ruby Group
 

Mirah Talk for Boulder Ruby Group

on

  • 1,198 views

In which I talk about what Mirah is and some of it's fine features.

In which I talk about what Mirah is and some of it's fine features.

Statistics

Views

Total Views
1,198
Views on SlideShare
1,074
Embed Views
124

Actions

Likes
0
Downloads
7
Comments
0

2 Embeds 124

http://blog.baroquebobcat.com 114
https://twitter.com 10

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

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
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Mirah Talk for Boulder Ruby Group Mirah Talk for Boulder Ruby Group Presentation Transcript

  • Mirah
  • What’s Mirah?
  • It’s a small, fast,JVM language that uses Ruby syntax.
  • How’d it come about?
  • Charles Oliver Nutter, JRuby guy
  • Wanted to writeJava code in Ruby
  • Wanted to writeJava code in Ruby
  • Wanted to write Javacode in a language as expressive as Ruby.
  • Expressive as Ruby?
  • http://www.flickr.com/photos/caroslines/513429518/
  • Syntactic Sugar• Optional Arguments• Internal Iteration(each, map, etc)• Closures• Literals• String Interpretation
  • Mirahs got the sugar.
  • How Mirah Differs from Ruby
  • 1. It’s statically typed and compiled
  • Basically,No RuntimeObject/ClassModification
  • 2. It uses Java’s type system
  • It has slightly differentsemantics than Rubys
  • e.g.,Mirah has interfaces
  • So, what’s it look like?
  • FibonacciExample
  • Rubydef fib(a)  if a < 2    a  else    fib(a - 1) + fib(a - 2)  endend
  • Mirahgithub.com/mirah/mirah/examples/fib.mirahdef fib(a:int):int  if a < 2    a  else    fib(a - 1) + fib(a - 2)  endend
  • See what I did there?
  • def fib(a:int):int
  • def fib(a:int):int
  • Ruby Syntax+ Java Types- Runtime Modification
  • Other Super Powers
  • Type Inference & Macros
  • Type Inference?
  • Javaclass Foo { private int bar; Foo() { bar = 1; } public int bar() { return bar; }}
  • Rubyclass Foo def initialize @bar = 1 end def bar @bar endend
  • Mirahclass Foo def initialize @bar = 1 end def bar @bar endend
  • @bar is inferred to be an Integer
  • Mirahclass Foo def initialize @bar = 1 end def bar @bar endend
  • Javaclass Foo { private int bar; Foo() { bar = 1; } public int bar() { return bar; }}
  • Mirah Java// Generated from foo.mirahpublic class Foo extends java.lang.Object private int bar; public Foo() { this.bar = 1; } public int bar() { return this.bar; }}
  • Ruby Syntax+ Java Types- Runtime Modification+ Type Inference
  • Macros
  • For Convenience & Awesomeness.
  • Used by the compiler
  • For example,
  • puts =>System.out.println();
  • Macros:How each, map, ==, etc are implemented
  • Macro Basics
  • say you have code like:logger.debug( "this #{takes_too_much_time}")
  • runtakes_too_much_time in production?
  • No,it takes too much time.
  • Macros to the rescue
  • macro def debug debug_input quote do if logger.debugEnabled logger.debug `debug_input` end endend
  • macro def debug debug_input quote do if logger.debugEnabled logger.debug `debug_input` end endend
  • macro def debug debug_input quote do if logger.debugEnabled logger.debug `debug_input` end endend
  • macro def debug debug_input quote do if logger.debugEnabled logger.debug `debug_input` end endend
  • macro def debug debug_input quote do if logger.debugEnabled logger.debug `debug_input` end endend
  • debug( "this #{takes_too_much_time}")
  • if logger.debugEnabled logger.debug("this #takes_too_much_time}" )end
  • debug( "this #{takes_too_much_time}")
  • So, Macros are nifty
  • Ruby Syntax+ Java Types- Runtime Modification+ Type Inference+ Macros
  • Oh, theres another thing.
  • No Runtime Library
  • You can do this:$ mirahc -e "puts hello BRG"$ java -classpath . DashE.class
  • No Runtime ==Small compiled footprint
  • Small Footprint ==good for mobile
  • For example, see Pindah
  • Ruby Syntax+ Java Types- Runtime Modification+ Type Inference+ Macros- Runtime Library
  • Get Started$ rvm jruby$ gem install mirah$ mirah -e "puts hello world
  • Mirah projects to check out: • Dubious - Rails-like web framework for Google App Engine • Pindah - Android App framework
  • Im Nick@baroquebobcat
  • I work at
  • Were Hiring.gnip.com/jobs
  • A couple links mirah.orggithub.com/mirah
  • Questions?