Your SlideShare is downloading. ×
0
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() {   ...
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 framew...
Im Nick@baroquebobcat
I work at
Were Hiring.gnip.com/jobs
A couple links    mirah.orggithub.com/mirah
Questions?
Mirah Talk for Boulder Ruby Group
Mirah Talk for Boulder Ruby Group
Mirah Talk for Boulder Ruby Group
Mirah Talk for Boulder Ruby Group
Upcoming SlideShare
Loading in...5
×

Mirah Talk for Boulder Ruby Group

1,047

Published on

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

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,047
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
8
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • \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
  • Transcript of "Mirah Talk for Boulder Ruby Group"

    1. 1. Mirah
    2. 2. What’s Mirah?
    3. 3. It’s a small, fast,JVM language that uses Ruby syntax.
    4. 4. How’d it come about?
    5. 5. Charles Oliver Nutter, JRuby guy
    6. 6. Wanted to writeJava code in Ruby
    7. 7. Wanted to writeJava code in Ruby
    8. 8. Wanted to write Javacode in a language as expressive as Ruby.
    9. 9. Expressive as Ruby?
    10. 10. http://www.flickr.com/photos/caroslines/513429518/
    11. 11. Syntactic Sugar• Optional Arguments• Internal Iteration(each, map, etc)• Closures• Literals• String Interpretation
    12. 12. Mirahs got the sugar.
    13. 13. How Mirah Differs from Ruby
    14. 14. 1. It’s statically typed and compiled
    15. 15. Basically,No RuntimeObject/ClassModification
    16. 16. 2. It uses Java’s type system
    17. 17. It has slightly differentsemantics than Rubys
    18. 18. e.g.,Mirah has interfaces
    19. 19. So, what’s it look like?
    20. 20. FibonacciExample
    21. 21. Rubydef fib(a)  if a < 2    a  else    fib(a - 1) + fib(a - 2)  endend
    22. 22. Mirahgithub.com/mirah/mirah/examples/fib.mirahdef fib(a:int):int  if a < 2    a  else    fib(a - 1) + fib(a - 2)  endend
    23. 23. See what I did there?
    24. 24. def fib(a:int):int
    25. 25. def fib(a:int):int
    26. 26. Ruby Syntax+ Java Types- Runtime Modification
    27. 27. Other Super Powers
    28. 28. Type Inference & Macros
    29. 29. Type Inference?
    30. 30. Javaclass Foo { private int bar; Foo() { bar = 1; } public int bar() { return bar; }}
    31. 31. Rubyclass Foo def initialize @bar = 1 end def bar @bar endend
    32. 32. Mirahclass Foo def initialize @bar = 1 end def bar @bar endend
    33. 33. @bar is inferred to be an Integer
    34. 34. Mirahclass Foo def initialize @bar = 1 end def bar @bar endend
    35. 35. Javaclass Foo { private int bar; Foo() { bar = 1; } public int bar() { return bar; }}
    36. 36. 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; }}
    37. 37. Ruby Syntax+ Java Types- Runtime Modification+ Type Inference
    38. 38. Macros
    39. 39. For Convenience & Awesomeness.
    40. 40. Used by the compiler
    41. 41. For example,
    42. 42. puts =>System.out.println();
    43. 43. Macros:How each, map, ==, etc are implemented
    44. 44. Macro Basics
    45. 45. say you have code like:logger.debug( "this #{takes_too_much_time}")
    46. 46. runtakes_too_much_time in production?
    47. 47. No,it takes too much time.
    48. 48. Macros to the rescue
    49. 49. macro def debug debug_input quote do if logger.debugEnabled logger.debug `debug_input` end endend
    50. 50. macro def debug debug_input quote do if logger.debugEnabled logger.debug `debug_input` end endend
    51. 51. macro def debug debug_input quote do if logger.debugEnabled logger.debug `debug_input` end endend
    52. 52. macro def debug debug_input quote do if logger.debugEnabled logger.debug `debug_input` end endend
    53. 53. macro def debug debug_input quote do if logger.debugEnabled logger.debug `debug_input` end endend
    54. 54. debug( "this #{takes_too_much_time}")
    55. 55. if logger.debugEnabled logger.debug("this #takes_too_much_time}" )end
    56. 56. debug( "this #{takes_too_much_time}")
    57. 57. So, Macros are nifty
    58. 58. Ruby Syntax+ Java Types- Runtime Modification+ Type Inference+ Macros
    59. 59. Oh, theres another thing.
    60. 60. No Runtime Library
    61. 61. You can do this:$ mirahc -e "puts hello BRG"$ java -classpath . DashE.class
    62. 62. No Runtime ==Small compiled footprint
    63. 63. Small Footprint ==good for mobile
    64. 64. For example, see Pindah
    65. 65. Ruby Syntax+ Java Types- Runtime Modification+ Type Inference+ Macros- Runtime Library
    66. 66. Get Started$ rvm jruby$ gem install mirah$ mirah -e "puts hello world
    67. 67. Mirah projects to check out: • Dubious - Rails-like web framework for Google App Engine • Pindah - Android App framework
    68. 68. Im Nick@baroquebobcat
    69. 69. I work at
    70. 70. Were Hiring.gnip.com/jobs
    71. 71. A couple links mirah.orggithub.com/mirah
    72. 72. Questions?
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×