JRuby and Sinatra
Upcoming SlideShare
Loading in...5
×
 

JRuby and Sinatra

on

  • 3,969 views

 

Statistics

Views

Total Views
3,969
Views on SlideShare
2,788
Embed Views
1,181

Actions

Likes
1
Downloads
9
Comments
0

9 Embeds 1,181

http://abstract2paradox.wordpress.com 552
http://wallwisher.com 475
http://padlet.com 136
http://legacy.wallwisher.com 7
http://fr.padlet.com 3
http://es.padlet.com 3
https://abstract2paradox.wordpress.com 3
http://next.wallwisher.com 1
http://de.padlet.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

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

    JRuby and Sinatra JRuby and Sinatra Presentation Transcript

    • Singing Java with JRuby Sinatra A melodious song on JRuby K.Gautam @gautamNitish
    • Ruby the languageCreated byYukihiroMatsumoto
    • JRuby Developers: Ola Bini, Nick Sieger, Charles Nutter, Thomas Enebo.
    • SinatraBlake Mizeranyand Many otherConrtibuters
    • So Lets look at Ruby
    • Hard Facts onDynamic
    • Hard Facts onInterpreted
    • Hard Facts onReflective
    • Hard Facts onObjectOriented
    • Implemented in C Hard Facts on
    • So what is JRuby ? + =Isnt that obvious from the name ?So JRuby is just another Ruby interpreter.
    • Why JRuby?
    • Why JRuby?True Multi-threading
    • Why JRuby?A well tuned Virtual Machine
    • Why JRuby?Simple and Easy Language
    • Why JRuby?Ruby was designed to make programmersHappy
    • Why JRuby?Fewer Bugs with Ruby
    • So Lets compare Java and Ruby ....And Why its better to combine them
    • Java vs Ruby The Minimum Program 1 class Foo{ 2 public static void main (String []args){Java 3 } 4}Ruby
    • Java vs Ruby Getters and Setters 1 class Foo{ 2 private int bar1 , bar2; 3 public int getBar1(){ return this.bar1; } 4 public int getBar2(){ return this.bar2; } 5 public void setBar2(int bar2){Java 6 this.bar2=bar2; 7 } 8 public void setBar1(int bar1){ 9 this.bar1=bar1; 10 } 11 } 1 class FooRuby 2 attr_accessor :bar1 , :bar2 3 end
    • Java vs Ruby Working with Lists 1 List<String> friends = new LinkedList<String>(); 2 List<String> enemies = new LinkedList<String>(); 3 friends.add("Java"); friends.add("JRuby"); 4 friends.add("Jython"); friends.add("Scala")Java 5 enemies.add("C#"); enemies.add("IronRuby"); 6 enemies.add("IronPython"); enemies.add("F#"); 1 friends=[] 2 enemies=[]Ruby 3 4 friends<< "Java" << "JRuby" << "Jython" << "Scala" enemies<< "c#" << "IronRuby" << "IronPython" << "F#"
    • Everything is an object (Literally !!)1 3.times { puts "Microsoft is Evil" }2 Microsoft is Evil3 Microsoft is Evil4 Microsoft is Evil5 => 3jruby-1.6.5 :011 > "Something".class => Stringjruby-1.6.5 :012 > 22.class => Fixnum
    • Meta Programmingjruby-1.6.5 :002 > eval("puts I can Program Myself")I can Program Myself => nil
    • If Ruby is so good then why Java ?
    • If ruby is so good then why Java ?● Java wins hands down in the Performance department
    • If ruby is so good then why Java ?● True Multi-Threading
    • Getting JRubyMethod 1:● Install MRI and RVM from ○ Package manager (Linux only) ○ ruby-lang.org● Then do "rvm install jruby"
    • Getting JRubyMethod 2 :● Get it Directly from jruby.org
    • Running JRuby Programs● jruby Foo.rb● java -jar jruby-complete.jar Foo.rb
    • AOT compilation of Jruby● jrubyc Foo.rb● java -jar jruby-complete.jar foo.class
    • Using java classes in Jruby1 include Java 2 java_import java.lang.Thread 3 java_import java.lang.System 4 class SomeClass 5 include java.lang.Runnable 6 def run 7 5.times do 8 System.out.println "Executing Thread : #{Thread.current_thread.get_id}" 9 end10 end11 end12 5.times{13 Thread.new(SomeClass.new).start14 }
    • Now onto Sinatra● Sinatra is a DSL for quickly creating web- apps with Ruby● http://sinatrarb.com● Best Installed as "gem install sinatra"
    • Sinatra saying Hello1 require rubygems2 require sinatra3 require data_mapper4 set :bind , 0.0.0.05 get / do6 "Hello there this is Frank Sinatra from beyondthe grave"7 end
    • Thank You