Your SlideShare is downloading. ×
0
JRuby and Sinatra
JRuby and Sinatra
JRuby and Sinatra
JRuby and Sinatra
JRuby and Sinatra
JRuby and Sinatra
JRuby and Sinatra
JRuby and Sinatra
JRuby and Sinatra
JRuby and Sinatra
JRuby and Sinatra
JRuby and Sinatra
JRuby and Sinatra
JRuby and Sinatra
JRuby and Sinatra
JRuby and Sinatra
JRuby and Sinatra
JRuby and Sinatra
JRuby and Sinatra
JRuby and Sinatra
JRuby and Sinatra
JRuby and Sinatra
JRuby and Sinatra
JRuby and Sinatra
JRuby and Sinatra
JRuby and Sinatra
JRuby and Sinatra
JRuby and Sinatra
JRuby and Sinatra
JRuby and Sinatra
JRuby and Sinatra
JRuby and Sinatra
JRuby and Sinatra
JRuby and Sinatra
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

JRuby and Sinatra

3,559

Published on

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

No Downloads
Views
Total Views
3,559
On Slideshare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
9
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Singing Java with JRuby Sinatra A melodious song on JRuby K.Gautam @gautamNitish
  • 2. Ruby the languageCreated byYukihiroMatsumoto
  • 3. JRuby Developers: Ola Bini, Nick Sieger, Charles Nutter, Thomas Enebo.
  • 4. SinatraBlake Mizeranyand Many otherConrtibuters
  • 5. So Lets look at Ruby
  • 6. Hard Facts onDynamic
  • 7. Hard Facts onInterpreted
  • 8. Hard Facts onReflective
  • 9. Hard Facts onObjectOriented
  • 10. Implemented in C Hard Facts on
  • 11. So what is JRuby ? + =Isnt that obvious from the name ?So JRuby is just another Ruby interpreter.
  • 12. Why JRuby?
  • 13. Why JRuby?True Multi-threading
  • 14. Why JRuby?A well tuned Virtual Machine
  • 15. Why JRuby?Simple and Easy Language
  • 16. Why JRuby?Ruby was designed to make programmersHappy
  • 17. Why JRuby?Fewer Bugs with Ruby
  • 18. So Lets compare Java and Ruby ....And Why its better to combine them
  • 19. Java vs Ruby The Minimum Program 1 class Foo{ 2 public static void main (String []args){Java 3 } 4}Ruby
  • 20. 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
  • 21. 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#"
  • 22. 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
  • 23. Meta Programmingjruby-1.6.5 :002 > eval("puts I can Program Myself")I can Program Myself => nil
  • 24. If Ruby is so good then why Java ?
  • 25. If ruby is so good then why Java ?● Java wins hands down in the Performance department
  • 26. If ruby is so good then why Java ?● True Multi-Threading
  • 27. Getting JRubyMethod 1:● Install MRI and RVM from ○ Package manager (Linux only) ○ ruby-lang.org● Then do "rvm install jruby"
  • 28. Getting JRubyMethod 2 :● Get it Directly from jruby.org
  • 29. Running JRuby Programs● jruby Foo.rb● java -jar jruby-complete.jar Foo.rb
  • 30. AOT compilation of Jruby● jrubyc Foo.rb● java -jar jruby-complete.jar foo.class
  • 31. 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 }
  • 32. Now onto Sinatra● Sinatra is a DSL for quickly creating web- apps with Ruby● http://sinatrarb.com● Best Installed as "gem install sinatra"
  • 33. 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
  • 34. Thank You

×