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)

PDF
Appengine ja-night-10
PDF
Ruby & Machine Vision - Talk at Sheffield Hallam University Feb 2009
PDF
The Enterprise Strikes Back
PDF
Class 1 blog
ZIP
Meta Programming in Ruby - Code Camp 2010
PDF
Ruby — An introduction
PDF
Metaprogramming
PDF
JDK7: Improved support for dynamic languages
PDF
Over 9000: JRuby in 2015
PDF
Accelerating Ruby with LLVM
PDF
Using Java from Ruby with JRuby IRB
PDF
Class 1
PDF
Class 1
PDF
Rejectkaigi 2010
PDF
Writing mruby Debugger
PDF
mRuby - Powerful Software for Embedded System Development
PPTX
Simple insites into JVM
PPTX
INTRODUCTION TO JAVA
KEY
PDF
Introduction to JRuby
Appengine ja-night-10
Ruby & Machine Vision - Talk at Sheffield Hallam University Feb 2009
The Enterprise Strikes Back
Class 1 blog
Meta Programming in Ruby - Code Camp 2010
Ruby — An introduction
Metaprogramming
JDK7: Improved support for dynamic languages
Over 9000: JRuby in 2015
Accelerating Ruby with LLVM
Using Java from Ruby with JRuby IRB
Class 1
Class 1
Rejectkaigi 2010
Writing mruby Debugger
mRuby - Powerful Software for Embedded System Development
Simple insites into JVM
INTRODUCTION TO JAVA
Introduction to JRuby
Ad

Recently uploaded (20)

PDF
A comparative analysis of optical character recognition models for extracting...
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Empathic Computing: Creating Shared Understanding
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PPTX
Machine Learning_overview_presentation.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
A comparative study of natural language inference in Swahili using monolingua...
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Getting Started with Data Integration: FME Form 101
PPTX
Spectroscopy.pptx food analysis technology
PDF
Heart disease approach using modified random forest and particle swarm optimi...
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Machine learning based COVID-19 study performance prediction
A comparative analysis of optical character recognition models for extracting...
NewMind AI Weekly Chronicles - August'25-Week II
Empathic Computing: Creating Shared Understanding
Building Integrated photovoltaic BIPV_UPV.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Per capita expenditure prediction using model stacking based on satellite ima...
Group 1 Presentation -Planning and Decision Making .pptx
Machine Learning_overview_presentation.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
A comparative study of natural language inference in Swahili using monolingua...
Digital-Transformation-Roadmap-for-Companies.pptx
Getting Started with Data Integration: FME Form 101
Spectroscopy.pptx food analysis technology
Heart disease approach using modified random forest and particle swarm optimi...
Mobile App Security Testing_ A Comprehensive Guide.pdf
Encapsulation_ Review paper, used for researhc scholars
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Machine learning based COVID-19 study performance prediction

Mirah Talk for Boulder Ruby Group

Editor's Notes