SlideShare a Scribd company logo
Mirah Talk for Boulder Ruby Group
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 write
Java code in Ruby
Wanted to write
Java code in Ruby
Wanted to write Java
code 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
Mirah's got the sugar.
How Mirah Differs
   from Ruby
1. It’s statically typed
     and compiled
Basically,
No Runtime
Object/Class
Modification
2. It uses Java’s type
        system
It has slightly different
semantics than Ruby's
e.g.,
Mirah has interfaces
So, what’s it look like?
Fibonacci
Example
Ruby
def fib(a)
  if a < 2
    a
  else
    fib(a - 1) + fib(a - 2)
  end
end
Mirah
github.com/mirah/mirah/examples/fib.mirah
def fib(a:int):int
  if a < 2
    a
  else
    fib(a - 1) + fib(a - 2)
  end
end
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?
Java
class Foo {
  private int bar;
  Foo() {
    bar = 1;
  }
  public int bar() {
    return bar;
  }
}
Mirah Talk for Boulder Ruby Group
Ruby
class Foo
  def initialize
    @bar = 1
  end
  def bar
    @bar
  end
end
Mirah
class Foo
  def initialize
    @bar = 1
  end
  def bar
    @bar
  end
end
@bar is inferred to be
     an Integer
Mirah
class Foo
  def initialize
    @bar = 1
  end
  def bar
    @bar
  end
end
Java
class Foo {
  private int bar;
  Foo() {
    bar = 1;
  }
  public int bar() {
    return bar;
  }
}
Mirah        Java
// Generated from foo.mirah
public 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}"
)
run
takes_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
  end
end
macro def debug debug_input
  quote do
    if logger.debugEnabled
      logger.debug `debug_input`
    end
  end
end
macro def debug debug_input
  quote do
    if logger.debugEnabled
      logger.debug `debug_input`
    end
  end
end
macro def debug debug_input
  quote do
    if logger.debugEnabled
      logger.debug `debug_input`
    end
  end
end
macro def debug debug_input
  quote do
    if logger.debugEnabled
      logger.debug `debug_input`
    end
  end
end
debug(
  "this #{takes_too_much_time}"
)
Mirah Talk for Boulder Ruby Group
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, there's 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
Mirah Talk for Boulder Ruby Group
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
I'm Nick
@baroquebobcat
I work at
We're Hiring.

gnip.com/jobs
A couple links
    mirah.org
github.com/mirah
Questions?

More Related Content

PPTX
Building native Android applications with Mirah and Pindah
ODP
AST Transformations
ODP
Ast transformations
ODP
AST Transformations at JFokus
ODP
Groovy Ast Transformations (greach)
PDF
Java Full Throttle
PDF
Introduction to clojure
PDF
A Re-Introduction to JavaScript
Building native Android applications with Mirah and Pindah
AST Transformations
Ast transformations
AST Transformations at JFokus
Groovy Ast Transformations (greach)
Java Full Throttle
Introduction to clojure
A Re-Introduction to JavaScript

What's hot (20)

PPT
ODP
Clojure: Practical functional approach on JVM
PDF
Frege - consequently functional programming for the JVM
PDF
Fundamental JavaScript [UTC, March 2014]
PPT
JavaScript Basics
PPTX
iSoligorsk #3 2013
PPT
Advanced JavaScript
PDF
P6 OO vs Moose (&Moo)
PPT
Java Intro
PDF
Kotlin advanced - language reference for android developers
PPT
A Deeper look into Javascript Basics
PPTX
Kotlin
PPT
Advanced Javascript
PDF
JRuby @ Boulder Ruby
PDF
ADG Poznań - Kotlin for Android developers
KEY
Alfresco the clojure way
PPTX
Making Java more dynamic: runtime code generation for the JVM
PDF
Develop your next app with kotlin @ AndroidMakersFr 2017
KEY
Javascript tid-bits
PDF
Kotlin Developer Starter in Android projects
Clojure: Practical functional approach on JVM
Frege - consequently functional programming for the JVM
Fundamental JavaScript [UTC, March 2014]
JavaScript Basics
iSoligorsk #3 2013
Advanced JavaScript
P6 OO vs Moose (&Moo)
Java Intro
Kotlin advanced - language reference for android developers
A Deeper look into Javascript Basics
Kotlin
Advanced Javascript
JRuby @ Boulder Ruby
ADG Poznań - Kotlin for Android developers
Alfresco the clojure way
Making Java more dynamic: runtime code generation for the JVM
Develop your next app with kotlin @ AndroidMakersFr 2017
Javascript tid-bits
Kotlin Developer Starter in Android projects
Ad

Similar to Mirah Talk for Boulder Ruby Group (20)

ODP
KEY
JRuby: What's Different (RORO Melbourne October 2011)
PDF
Monkeybars in the Manor
PDF
Introduction to JRuby
PPT
XRuby_Overview_20070831
PDF
Intro to J Ruby
PDF
Java 8 Lambda
PDF
Ruby for C#-ers (ScanDevConf 2010)
PDF
Quick Intro To JRuby
KEY
Plataforma java
PDF
Ebay News 2001 4 19 Earnings
PDF
Ebay News 2000 10 19 Earnings
PDF
P4 P Update January 2009
PDF
Middleware as Code with mruby
PPT
Practical JRuby
PDF
The Enterprise Strikes Back
PDF
Developing cross platform desktop application with Ruby
KEY
Jruby synergy-of-ruby-and-java
PPTX
Ruby -the wheel Technology
JRuby: What's Different (RORO Melbourne October 2011)
Monkeybars in the Manor
Introduction to JRuby
XRuby_Overview_20070831
Intro to J Ruby
Java 8 Lambda
Ruby for C#-ers (ScanDevConf 2010)
Quick Intro To JRuby
Plataforma java
Ebay News 2001 4 19 Earnings
Ebay News 2000 10 19 Earnings
P4 P Update January 2009
Middleware as Code with mruby
Practical JRuby
The Enterprise Strikes Back
Developing cross platform desktop application with Ruby
Jruby synergy-of-ruby-and-java
Ruby -the wheel Technology
Ad

Recently uploaded (20)

PDF
Encapsulation theory and applications.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Approach and Philosophy of On baking technology
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Cloud computing and distributed systems.
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Empathic Computing: Creating Shared Understanding
PPTX
MYSQL Presentation for SQL database connectivity
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Encapsulation theory and applications.pdf
MIND Revenue Release Quarter 2 2025 Press Release
Advanced methodologies resolving dimensionality complications for autism neur...
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Programs and apps: productivity, graphics, security and other tools
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Spectral efficient network and resource selection model in 5G networks
Approach and Philosophy of On baking technology
Understanding_Digital_Forensics_Presentation.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Reach Out and Touch Someone: Haptics and Empathic Computing
Cloud computing and distributed systems.
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Review of recent advances in non-invasive hemoglobin estimation
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Empathic Computing: Creating Shared Understanding
MYSQL Presentation for SQL database connectivity
The AUB Centre for AI in Media Proposal.docx
Agricultural_Statistics_at_a_Glance_2022_0.pdf

Mirah Talk for Boulder Ruby Group

Editor's Notes