SlideShare una empresa de Scribd logo
1 de 69
Descargar para leer sin conexión
Mirah &
                           Dubious
Tuesday, August 31, 2010
Mirah & Dubious
            A bold and beautiful way to write Java,
            plus a new framework for App Engine
            Charles Nutter
            John Woodell
            Aug 30, 2010




              2



Tuesday, August 31, 2010
Mirah
                           A pragmatic blend of Ruby and Java




Tuesday, August 31, 2010
Me
                    • Charles Oliver Nutter
                    • Engine Yard, Inc
                    • headius@headius.com
                    • @headius
                    • JRuby core developer
                    • Mirah creator
Tuesday, August 31, 2010
Ruby
                    • Beautiful language
                     • Clean syntax
                     • Easy-to-use closures
                     • Nice core libraries
                    • “Slow” language
                     • Very dynamic == hard to optimize
Tuesday, August 31, 2010
Java
                    • High-performance language
                     • Mostly static typing
                     • Full system optimizations
                     • Primitive math operations
                    • Ugly language
                     • (C++)-- of 1995
Tuesday, August 31, 2010
Mirah
                    • “Apparent features” of Ruby
                     • Syntax
                     • Closures and iterators
                     • Dynamic-feeling behaviors
                    • Performance, typing like Java
                     • As fast as Java for almost everything
Tuesday, August 31, 2010
What If This...
                           public class Foo {
                             private int a;

                               public Foo(int a) {
                                 this.a = a;
                               }

                               public void show() {
                                 System.out.println(a);
                               }
                           }

Tuesday, August 31, 2010
...Could Be This
                           class Foo
                             def initialize(a)
                               @a = a
                             end

                             def show
                               puts @a
                             end
                           end

Tuesday, August 31, 2010
Mirah
                           class Foo
                             def initialize(a:int)
                               @a = a
                             end

                             def show
                               puts @a
                             end
                           end

Tuesday, August 31, 2010
“Java’s Ruby”

                    • A nicer way to write Java
                    • Ruby syntax with modifications
                    • Feels like Ruby
                    • Compiles to Java/JVM
                    • No runtime library

Tuesday, August 31, 2010
Features From Ruby
                    • Optional arguments ✓
                    • Internal iteration ✓
                    • Closures ✓
                    • Literals ✓
                    • String interpolation ✓
                    • Mixins, “open” classes (soon)
Tuesday, August 31, 2010
Features From X

                    • (Coming Soon)
                     • Extension methods (C#ish, but nicer)
                     • Implicit type conversions (Scala)
                     • Pattern matching?
                     • Case classes?

Tuesday, August 31, 2010
Ruby


                           puts “Hello, world!”




Tuesday, August 31, 2010
Mirah


                           puts “Hello, world!”




Tuesday, August 31, 2010
Mirah

      // Generated from DashE
      public class DashE extends java.lang.Object {
        public static void main(java.lang.String[] argv) {
          java.io.PrintStream temp$1 = java.lang.System.out;
          temp$1.println("Hello, world!");
        }
      }




Tuesday, August 31, 2010
Ruby
                           def fib(a)
                             if a < 2
                               a
                             else
                               fib(a - 1) + fib(a - 2)
                             end
                           end



Tuesday, August 31, 2010
Mirah
                           def fib(a:int)
                             if a < 2
                               a
                             else
                               fib(a - 1) + fib(a - 2)
                             end
                           end



Tuesday, August 31, 2010
Mirah
        // Generated from DashE
        public class DashE extends java.lang.Object {
          public static void main(java.lang.String[] argv) {
          }
          public static int fib(int a) {
            return (a < 2) ? (a) : ((DashE.fib((a - 1)) +
              DashE.fib((a - 2))));
          }
        }




Tuesday, August 31, 2010
Ruby


                       def foo(a = 1, b = 2)
                         puts a + b
                       end




Tuesday, August 31, 2010
Mirah


                       def foo(a:int = 1, b:int = 2)
                         puts a + b
                       end




Tuesday, August 31, 2010
Mirah
             public static java.io.PrintStream foo(int a, int b) {
               java.io.PrintStream temp$1 =
                 java.lang.System.out;
               temp$1.println((a + b));
               return temp$1;
             }
             public static java.io.PrintStream foo() {
               return foo(1);
             }
             public static java.io.PrintStream foo(int a) {
               return foo(a, 2);
             }




Tuesday, August 31, 2010
Ruby

                           a = [5,4,3,2,1]
                           a.each do |x|
                             puts x
                           end




Tuesday, August 31, 2010
Mirah

                           a = [5,4,3,2,1]
                           a.each do |x|
                             puts x
                           end




Tuesday, August 31, 2010
Mirah
          // Generated from DashE
          public class DashE extends java.lang.Object {
            public static void main(java.lang.String[] argv) {
              java.util.List a =
                java.util.Collections.unmodifiableList(
                   java.util.Arrays.asList(1, 2, 3, 4, 5));
              java.util.Iterator __xform_tmp_1 = a.iterator();
              label1:
              while (__xform_tmp_1.hasNext()) {
                java.lang.Object x = __xform_tmp_1.next();
                label2:
                  {
                   java.io.PrintStream temp$3 = java.lang.System.out;
                   temp$3.println(x);
                }
              }
            }
          }



Tuesday, August 31, 2010
Ruby


                           t = Thread.new do
                             puts “in thread”
                           end




Tuesday, August 31, 2010
Mirah


                           t = Thread.new do
                             puts “in thread”
                           end




Tuesday, August 31, 2010
// Generated from DashE
                                   Mirah
 public class DashE extends java.lang.Object {
   public static void main(java.lang.String[] argv) {
     DashE.__xform_tmp_1 $binding = new DashE.__xform_tmp_1();
     $binding.x = "in thread";
     java.lang.Thread t = new java.lang.Thread(new DashE.__xform_tmp_2($binding));
   }
   public static class __xform_tmp_1 extends java.lang.Object {
       java.lang.String x;
   }
   public static class __xform_tmp_2 extends java.lang.Object implements
        java.lang.Runnable {
     private DashE.__xform_tmp_1 binding;
     public __xform_tmp_2(DashE.__xform_tmp_1 binding) {
        this.binding = binding;
     }
     public void run() {
        DashE.__xform_tmp_1 $binding = this.binding;
        java.io.PrintStream temp$1 = java.lang.System.out;
        temp$1.println($binding.x);
     }
   }
 }



Tuesday, August 31, 2010
// Generated from DashE
                                   Mirah
 public class DashE extends java.lang.Object {
   public static void main(java.lang.String[] argv) {
     DashE.__xform_tmp_1 $binding = new DashE.__xform_tmp_1();
     $binding.x = "in thread";
     java.lang.Thread t = new java.lang.Thread(new DashE.__xform_tmp_2($binding));
   }
   public static class __xform_tmp_1 extends java.lang.Object {
       java.lang.String x;
   }
   public static class __xform_tmp_2 extends java.lang.Object implements
        java.lang.Runnable {
     private DashE.__xform_tmp_1 binding;
     public __xform_tmp_2(DashE.__xform_tmp_1 binding) {
        this.binding = binding;
     }
     public void run() {
        DashE.__xform_tmp_1 $binding = this.binding;
        java.io.PrintStream temp$1 = java.lang.System.out;
        temp$1.println($binding.x);
     }
   }
 }



Tuesday, August 31, 2010
// Generated from DashE
                                   Mirah
 public class DashE extends java.lang.Object {
   public static void main(java.lang.String[] argv) {
     DashE.__xform_tmp_1 $binding = new DashE.__xform_tmp_1();
     $binding.x = "in thread";
     java.lang.Thread t = new java.lang.Thread(new DashE.__xform_tmp_2($binding));
   }
   public static class __xform_tmp_1 extends java.lang.Object {
       java.lang.String x;
   }
   public static class __xform_tmp_2 extends java.lang.Object implements
        java.lang.Runnable {
     private DashE.__xform_tmp_1 binding;
     public __xform_tmp_2(DashE.__xform_tmp_1 binding) {
        this.binding = binding;
     }
     public void run() {
        DashE.__xform_tmp_1 $binding = this.binding;
        java.io.PrintStream temp$1 = java.lang.System.out;
        temp$1.println($binding.x);
     }
   }
 }



Tuesday, August 31, 2010
Open Class (proposal)
    interface StringFunc
      def apply(str:String)
    end

    extend class String # java.lang.String
      def each(func:StringFunc)
        # String#split call from Java
        lines = split

        # like “for (String str: strArray)”
        lines.each do |str|
          func.apply(str)
        end
      end
    end

Tuesday, August 31, 2010
Open Class (Java side)
    public interface StringFunc {
      public void apply(String str);
    }

    public class StringExtension {
      public void each(String str, StringFunc func) {
        for (String s: str.split()) {
          func.apply(str);
        }
      }
    }




Tuesday, August 31, 2010
Open Class (usage)


    str = “hellongoodbyenworld”

    str.each {|s| ... }




Tuesday, August 31, 2010
Open Class (Java usage)

    String str = “hellongoodbyenworld”;

    StringExtension.each(str, new StringFunc() {
      public void apply(String s) {
        ...
      }
    });




Tuesday, August 31, 2010
Open Class (Java usage)

    String str = “hellongoodbyenworld”;

    StringExtension.each(str, new StringFunc() {
      public void apply(String s) {
        ...



                           YUCK!
      }
    });




Tuesday, August 31, 2010
Type Conversion

    str = “hellongoodbyenworld”

    # no “map” method on String...
    str.map {|s| # ERROR




Tuesday, August 31, 2010
Type Conversion
                              (by hand)

    str = “hellongoodbyenworld”

    # without type conversion
    Arrays.asList(str.split).map { ...




Tuesday, August 31, 2010
Type Conversion
                              (by hand)

    str = “hellongoodbyenworld”

    # without type conversion
    Arrays.asList(str.split).map { ...




Tuesday, August 31, 2010
Type Conversion
                              (proposal)
    conversion(String => List) do |str|
      Arrays.asList(str.split)
    end

    conversion(List => String) do |list|
      list.join(‘n’)
    end


Tuesday, August 31, 2010
Type Conversion
                               (usage)

    str = “hellongoodbyenworld”

    # with type conversion!
    str.map { ... # OK!!




Tuesday, August 31, 2010
It’s Not Ruby

                    • Using Java’s libraries and type system
                    • No “eval”
                    • No runtime-mutable classes
                    • Ruby libraries will not work

Tuesday, August 31, 2010
But It Feels Like Ruby!

                    • Clean, lightweight syntax
                    • Iteration, closures
                    • Far less “ceremony” than Java
                    • Performance equivalent to Java

Tuesday, August 31, 2010
mirah.org



Tuesday, August 31, 2010
Tuesday, August 31, 2010
Dubious
                           Dubious Mirah Web




Tuesday, August 31, 2010
Me

                    • John Woodell
                    • Web developer at Google
                    • Dubious creator
                    • App Engine JRuby maintainer
                    • @JohnWoodell

Tuesday, August 31, 2010
Thank you for using
                            "AppEngine/Java”
                              "AppEngine/Java"




             47



Tuesday, August 31, 2010
Spin-up time can make scaling “painful”
            • The most critical issue to be resolved is spin-up time,
               App Engine scales by adding new application instances.
            • Even if initialization could happen without affecting users
               some apps will need to scale instantly.




             48



Tuesday, August 31, 2010
Spin-up?
                           Yes, this is a problem...



             49



Tuesday, August 31, 2010
...but now you can use
                              Mirah and Dubious

                                "Mirah/Dubious"


             50



Tuesday, August 31, 2010
Dubious is Web framework for Mirah
                           Dubious Mirah Web

                            *du    bi   ous[ djbis | dj- ] [         ]
                     [1] ((       ))           …
                                                ((of, about, as to ...)).
                      [2]


                              >
             51



Tuesday, August 31, 2010
Write Rails-style code,
                           it runs on Google App Engine



                                       GoogleAppEngine
                             Rails

             52



Tuesday, August 31, 2010
Benefits of Mirah on App Engine
            • Ruby syntax & apparent features + Java type system
            • Use Java or Ruby when Mirah lacks features you require
            • The generated Java source can be inspected at any time
            • Macros and plugins can be written in Ruby or Mirah
            • New instances always spin-up in about a second




             53



Tuesday, August 31, 2010
Working with Dubious
            • Dubious framework uses familiar Rails conventions
            • Generate JSONs or work with ERb templates
            • MirahModel syntax is similar to DataMapper
            • Developers can create apps entirely in Rails,
               then refactor URLs that need to scale quickly
            • Some important features are currently missing,
               but “you” could have fun contributing them




             54



Tuesday, August 31, 2010
Here’s code from Dubious
                                (this is not Rails)

                                      Rails
                            Dubious

             55



Tuesday, August 31, 2010
Dubious controllers will be familiar




Tuesday, August 31, 2010
Mirah can use ERb templates




Tuesday, August 31, 2010
The generated Java source can be inspected




Tuesday, August 31, 2010
The ERb is transformed into method calls




Tuesday, August 31, 2010
Your model definition is very concise




Tuesday, August 31, 2010
Code generation based on defined properties




Tuesday, August 31, 2010
All the basic methods you need are generated




Tuesday, August 31, 2010
It really works,
                           and spins-up in ~1sec


                                         Spinup.

             63



Tuesday, August 31, 2010
It isn’t "Dubious"


          http://dubious-demo.appspot.com

             64



Tuesday, August 31, 2010
The Framework
                           (coding in Mirah)



Tuesday, August 31, 2010
Method signatures enforce types




Tuesday, August 31, 2010
Return type can be enforced also




Tuesday, August 31, 2010
Code is very concise




Tuesday, August 31, 2010
Thank You

Tuesday, August 31, 2010

Más contenido relacionado

Más de John Woodell

Deploying and Maintaining an Enterprise OpenLDAP Directory
Deploying and Maintaining an Enterprise OpenLDAP DirectoryDeploying and Maintaining an Enterprise OpenLDAP Directory
Deploying and Maintaining an Enterprise OpenLDAP DirectoryJohn Woodell
 
Enterprise Mail and Calendaring with Open Software
Enterprise Mail and Calendaring with Open SoftwareEnterprise Mail and Calendaring with Open Software
Enterprise Mail and Calendaring with Open SoftwareJohn Woodell
 
Aloha on-rails-2009
Aloha on-rails-2009Aloha on-rails-2009
Aloha on-rails-2009John Woodell
 
Red Dirt Ruby Conference
Red Dirt Ruby ConferenceRed Dirt Ruby Conference
Red Dirt Ruby ConferenceJohn Woodell
 

Más de John Woodell (10)

Deploying and Maintaining an Enterprise OpenLDAP Directory
Deploying and Maintaining an Enterprise OpenLDAP DirectoryDeploying and Maintaining an Enterprise OpenLDAP Directory
Deploying and Maintaining an Enterprise OpenLDAP Directory
 
Enterprise Mail and Calendaring with Open Software
Enterprise Mail and Calendaring with Open SoftwareEnterprise Mail and Calendaring with Open Software
Enterprise Mail and Calendaring with Open Software
 
Jrubykaigi 2010
Jrubykaigi 2010Jrubykaigi 2010
Jrubykaigi 2010
 
Railsconf 2010
Railsconf 2010Railsconf 2010
Railsconf 2010
 
Rubypalooza 2009
Rubypalooza 2009Rubypalooza 2009
Rubypalooza 2009
 
Aloha on-rails-2009
Aloha on-rails-2009Aloha on-rails-2009
Aloha on-rails-2009
 
RubyConf 2009
RubyConf 2009RubyConf 2009
RubyConf 2009
 
JRubyConf 2009
JRubyConf 2009JRubyConf 2009
JRubyConf 2009
 
App Engine Meetup
App Engine MeetupApp Engine Meetup
App Engine Meetup
 
Red Dirt Ruby Conference
Red Dirt Ruby ConferenceRed Dirt Ruby Conference
Red Dirt Ruby Conference
 

Último

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 

Último (20)

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 

Appengine ja-night-10

  • 1. Mirah & Dubious Tuesday, August 31, 2010
  • 2. Mirah & Dubious A bold and beautiful way to write Java, plus a new framework for App Engine Charles Nutter John Woodell Aug 30, 2010 2 Tuesday, August 31, 2010
  • 3. Mirah A pragmatic blend of Ruby and Java Tuesday, August 31, 2010
  • 4. Me • Charles Oliver Nutter • Engine Yard, Inc • headius@headius.com • @headius • JRuby core developer • Mirah creator Tuesday, August 31, 2010
  • 5. Ruby • Beautiful language • Clean syntax • Easy-to-use closures • Nice core libraries • “Slow” language • Very dynamic == hard to optimize Tuesday, August 31, 2010
  • 6. Java • High-performance language • Mostly static typing • Full system optimizations • Primitive math operations • Ugly language • (C++)-- of 1995 Tuesday, August 31, 2010
  • 7. Mirah • “Apparent features” of Ruby • Syntax • Closures and iterators • Dynamic-feeling behaviors • Performance, typing like Java • As fast as Java for almost everything Tuesday, August 31, 2010
  • 8. What If This... public class Foo { private int a; public Foo(int a) { this.a = a; } public void show() { System.out.println(a); } } Tuesday, August 31, 2010
  • 9. ...Could Be This class Foo def initialize(a) @a = a end def show puts @a end end Tuesday, August 31, 2010
  • 10. Mirah class Foo def initialize(a:int) @a = a end def show puts @a end end Tuesday, August 31, 2010
  • 11. “Java’s Ruby” • A nicer way to write Java • Ruby syntax with modifications • Feels like Ruby • Compiles to Java/JVM • No runtime library Tuesday, August 31, 2010
  • 12. Features From Ruby • Optional arguments ✓ • Internal iteration ✓ • Closures ✓ • Literals ✓ • String interpolation ✓ • Mixins, “open” classes (soon) Tuesday, August 31, 2010
  • 13. Features From X • (Coming Soon) • Extension methods (C#ish, but nicer) • Implicit type conversions (Scala) • Pattern matching? • Case classes? Tuesday, August 31, 2010
  • 14. Ruby puts “Hello, world!” Tuesday, August 31, 2010
  • 15. Mirah puts “Hello, world!” Tuesday, August 31, 2010
  • 16. Mirah // Generated from DashE public class DashE extends java.lang.Object { public static void main(java.lang.String[] argv) { java.io.PrintStream temp$1 = java.lang.System.out; temp$1.println("Hello, world!"); } } Tuesday, August 31, 2010
  • 17. Ruby def fib(a) if a < 2 a else fib(a - 1) + fib(a - 2) end end Tuesday, August 31, 2010
  • 18. Mirah def fib(a:int) if a < 2 a else fib(a - 1) + fib(a - 2) end end Tuesday, August 31, 2010
  • 19. Mirah // Generated from DashE public class DashE extends java.lang.Object { public static void main(java.lang.String[] argv) { } public static int fib(int a) { return (a < 2) ? (a) : ((DashE.fib((a - 1)) + DashE.fib((a - 2)))); } } Tuesday, August 31, 2010
  • 20. Ruby def foo(a = 1, b = 2) puts a + b end Tuesday, August 31, 2010
  • 21. Mirah def foo(a:int = 1, b:int = 2) puts a + b end Tuesday, August 31, 2010
  • 22. Mirah public static java.io.PrintStream foo(int a, int b) { java.io.PrintStream temp$1 = java.lang.System.out; temp$1.println((a + b)); return temp$1; } public static java.io.PrintStream foo() { return foo(1); } public static java.io.PrintStream foo(int a) { return foo(a, 2); } Tuesday, August 31, 2010
  • 23. Ruby a = [5,4,3,2,1] a.each do |x| puts x end Tuesday, August 31, 2010
  • 24. Mirah a = [5,4,3,2,1] a.each do |x| puts x end Tuesday, August 31, 2010
  • 25. Mirah // Generated from DashE public class DashE extends java.lang.Object { public static void main(java.lang.String[] argv) { java.util.List a = java.util.Collections.unmodifiableList( java.util.Arrays.asList(1, 2, 3, 4, 5)); java.util.Iterator __xform_tmp_1 = a.iterator(); label1: while (__xform_tmp_1.hasNext()) { java.lang.Object x = __xform_tmp_1.next(); label2: { java.io.PrintStream temp$3 = java.lang.System.out; temp$3.println(x); } } } } Tuesday, August 31, 2010
  • 26. Ruby t = Thread.new do puts “in thread” end Tuesday, August 31, 2010
  • 27. Mirah t = Thread.new do puts “in thread” end Tuesday, August 31, 2010
  • 28. // Generated from DashE Mirah public class DashE extends java.lang.Object { public static void main(java.lang.String[] argv) { DashE.__xform_tmp_1 $binding = new DashE.__xform_tmp_1(); $binding.x = "in thread"; java.lang.Thread t = new java.lang.Thread(new DashE.__xform_tmp_2($binding)); } public static class __xform_tmp_1 extends java.lang.Object { java.lang.String x; } public static class __xform_tmp_2 extends java.lang.Object implements java.lang.Runnable { private DashE.__xform_tmp_1 binding; public __xform_tmp_2(DashE.__xform_tmp_1 binding) { this.binding = binding; } public void run() { DashE.__xform_tmp_1 $binding = this.binding; java.io.PrintStream temp$1 = java.lang.System.out; temp$1.println($binding.x); } } } Tuesday, August 31, 2010
  • 29. // Generated from DashE Mirah public class DashE extends java.lang.Object { public static void main(java.lang.String[] argv) { DashE.__xform_tmp_1 $binding = new DashE.__xform_tmp_1(); $binding.x = "in thread"; java.lang.Thread t = new java.lang.Thread(new DashE.__xform_tmp_2($binding)); } public static class __xform_tmp_1 extends java.lang.Object { java.lang.String x; } public static class __xform_tmp_2 extends java.lang.Object implements java.lang.Runnable { private DashE.__xform_tmp_1 binding; public __xform_tmp_2(DashE.__xform_tmp_1 binding) { this.binding = binding; } public void run() { DashE.__xform_tmp_1 $binding = this.binding; java.io.PrintStream temp$1 = java.lang.System.out; temp$1.println($binding.x); } } } Tuesday, August 31, 2010
  • 30. // Generated from DashE Mirah public class DashE extends java.lang.Object { public static void main(java.lang.String[] argv) { DashE.__xform_tmp_1 $binding = new DashE.__xform_tmp_1(); $binding.x = "in thread"; java.lang.Thread t = new java.lang.Thread(new DashE.__xform_tmp_2($binding)); } public static class __xform_tmp_1 extends java.lang.Object { java.lang.String x; } public static class __xform_tmp_2 extends java.lang.Object implements java.lang.Runnable { private DashE.__xform_tmp_1 binding; public __xform_tmp_2(DashE.__xform_tmp_1 binding) { this.binding = binding; } public void run() { DashE.__xform_tmp_1 $binding = this.binding; java.io.PrintStream temp$1 = java.lang.System.out; temp$1.println($binding.x); } } } Tuesday, August 31, 2010
  • 31. Open Class (proposal) interface StringFunc def apply(str:String) end extend class String # java.lang.String def each(func:StringFunc) # String#split call from Java lines = split # like “for (String str: strArray)” lines.each do |str| func.apply(str) end end end Tuesday, August 31, 2010
  • 32. Open Class (Java side) public interface StringFunc { public void apply(String str); } public class StringExtension { public void each(String str, StringFunc func) { for (String s: str.split()) { func.apply(str); } } } Tuesday, August 31, 2010
  • 33. Open Class (usage) str = “hellongoodbyenworld” str.each {|s| ... } Tuesday, August 31, 2010
  • 34. Open Class (Java usage) String str = “hellongoodbyenworld”; StringExtension.each(str, new StringFunc() { public void apply(String s) { ... } }); Tuesday, August 31, 2010
  • 35. Open Class (Java usage) String str = “hellongoodbyenworld”; StringExtension.each(str, new StringFunc() { public void apply(String s) { ... YUCK! } }); Tuesday, August 31, 2010
  • 36. Type Conversion str = “hellongoodbyenworld” # no “map” method on String... str.map {|s| # ERROR Tuesday, August 31, 2010
  • 37. Type Conversion (by hand) str = “hellongoodbyenworld” # without type conversion Arrays.asList(str.split).map { ... Tuesday, August 31, 2010
  • 38. Type Conversion (by hand) str = “hellongoodbyenworld” # without type conversion Arrays.asList(str.split).map { ... Tuesday, August 31, 2010
  • 39. Type Conversion (proposal) conversion(String => List) do |str| Arrays.asList(str.split) end conversion(List => String) do |list| list.join(‘n’) end Tuesday, August 31, 2010
  • 40. Type Conversion (usage) str = “hellongoodbyenworld” # with type conversion! str.map { ... # OK!! Tuesday, August 31, 2010
  • 41. It’s Not Ruby • Using Java’s libraries and type system • No “eval” • No runtime-mutable classes • Ruby libraries will not work Tuesday, August 31, 2010
  • 42. But It Feels Like Ruby! • Clean, lightweight syntax • Iteration, closures • Far less “ceremony” than Java • Performance equivalent to Java Tuesday, August 31, 2010
  • 45. Dubious Dubious Mirah Web Tuesday, August 31, 2010
  • 46. Me • John Woodell • Web developer at Google • Dubious creator • App Engine JRuby maintainer • @JohnWoodell Tuesday, August 31, 2010
  • 47. Thank you for using "AppEngine/Java” "AppEngine/Java" 47 Tuesday, August 31, 2010
  • 48. Spin-up time can make scaling “painful” • The most critical issue to be resolved is spin-up time, App Engine scales by adding new application instances. • Even if initialization could happen without affecting users some apps will need to scale instantly. 48 Tuesday, August 31, 2010
  • 49. Spin-up? Yes, this is a problem... 49 Tuesday, August 31, 2010
  • 50. ...but now you can use Mirah and Dubious "Mirah/Dubious" 50 Tuesday, August 31, 2010
  • 51. Dubious is Web framework for Mirah Dubious Mirah Web *du bi ous[ djbis | dj- ] [ ] [1] (( )) … ((of, about, as to ...)). [2] > 51 Tuesday, August 31, 2010
  • 52. Write Rails-style code, it runs on Google App Engine GoogleAppEngine Rails 52 Tuesday, August 31, 2010
  • 53. Benefits of Mirah on App Engine • Ruby syntax & apparent features + Java type system • Use Java or Ruby when Mirah lacks features you require • The generated Java source can be inspected at any time • Macros and plugins can be written in Ruby or Mirah • New instances always spin-up in about a second 53 Tuesday, August 31, 2010
  • 54. Working with Dubious • Dubious framework uses familiar Rails conventions • Generate JSONs or work with ERb templates • MirahModel syntax is similar to DataMapper • Developers can create apps entirely in Rails, then refactor URLs that need to scale quickly • Some important features are currently missing, but “you” could have fun contributing them 54 Tuesday, August 31, 2010
  • 55. Here’s code from Dubious (this is not Rails) Rails Dubious 55 Tuesday, August 31, 2010
  • 56. Dubious controllers will be familiar Tuesday, August 31, 2010
  • 57. Mirah can use ERb templates Tuesday, August 31, 2010
  • 58. The generated Java source can be inspected Tuesday, August 31, 2010
  • 59. The ERb is transformed into method calls Tuesday, August 31, 2010
  • 60. Your model definition is very concise Tuesday, August 31, 2010
  • 61. Code generation based on defined properties Tuesday, August 31, 2010
  • 62. All the basic methods you need are generated Tuesday, August 31, 2010
  • 63. It really works, and spins-up in ~1sec Spinup. 63 Tuesday, August 31, 2010
  • 64. It isn’t "Dubious" http://dubious-demo.appspot.com 64 Tuesday, August 31, 2010
  • 65. The Framework (coding in Mirah) Tuesday, August 31, 2010
  • 66. Method signatures enforce types Tuesday, August 31, 2010
  • 67. Return type can be enforced also Tuesday, August 31, 2010
  • 68. Code is very concise Tuesday, August 31, 2010