jruby - the perfect alternative

46
Ram Vijapurapu @rvijapurapu

Upload: ram-vijapurapu

Post on 15-Jan-2015

1.853 views

Category:

Technology


2 download

DESCRIPTION

This presentation was first presented at The Auckland Ruby Group - http://ruby.meetup.com/96/

TRANSCRIPT

Page 1: JRuby - The Perfect Alternative

Ram Vijapurapu@rvijapurapu

Page 2: JRuby - The Perfect Alternative

What is JRuby?

Its just RubyRunning on the JVM (Java Virtual Machine)

Page 3: JRuby - The Perfect Alternative

Conclusion

..I truly wish it is that simple.

Image credit: http://www.flickr.com/photos/hordurk/3204191929/

Page 4: JRuby - The Perfect Alternative

Social Context

Page 5: JRuby - The Perfect Alternative

Social Context

Page 6: JRuby - The Perfect Alternative

Social Context

Page 7: JRuby - The Perfect Alternative

Why do we want to go back to the Haunted House again?

● Reuse what's already built● Need of a Scalable Platform● Need for an inclusive Platform

–Ruby, Groovy, Python, JS, ..● Generally Love of Engineering Genius

^

Enterprise Ready

Page 8: JRuby - The Perfect Alternative

What is the first thing you hear about Java?

Image credit: http://bit.ly/btxcPf

Page 9: JRuby - The Perfect Alternative

Common Man! Java is Slooow

● Maybe... Maybe not!

ACHTUNG! Highly Unscientific Testing

Page 10: JRuby - The Perfect Alternative

Common Man! Java is Slooow

No Optimizations

Page 11: JRuby - The Perfect Alternative

Common Man! Java is Slooow

100

Page 12: JRuby - The Perfect Alternative

Common Man! Java is Slooow

1,000

Page 13: JRuby - The Perfect Alternative

Common Man! Java is Slooow

10,000

Page 14: JRuby - The Perfect Alternative

Common Man! Java is Slooow

100,000

Page 15: JRuby - The Perfect Alternative

Common Man! Java is Slooow

100,000

What's your Point?

See Java is sl0000w!

Page 16: JRuby - The Perfect Alternative

Common Man! Java is Slooow

1,000,000Fast

Page 17: JRuby - The Perfect Alternative

Common Man! Java is Slooow

1,000,000Fast

Fast

Clearly you

fudged it!

Page 18: JRuby - The Perfect Alternative

You fudged it!

● Maybe – but there is method in madness

Page 19: JRuby - The Perfect Alternative

You fudged it!

● Maybe – but there is method in madness

Performance Improvements in JVM from 1.5 to 1.6 have been significant. both are running i386

Moral: Focus on your code & JVM takes care of the rest– well into the future

Page 20: JRuby - The Perfect Alternative

What just happened?

● Magic – JVM/Hotspot (Dark Magic?)● JIT (Just In Time Compilation) – Optimization on the

Fly● Speaking further on this is beyond the scope of this

presentation _

Summary: Normal usage on Web you will find JRuby performs same as CRuby

Page 21: JRuby - The Perfect Alternative

As all good things in life........ there are few limitations

● You cannot use libraries which use CRuby Extensions

● Java Threads● Posix Methods● Does not support continuations/bindings.

(Feature Missing)http://docs.codehaus.org/display/JRUBY/Limitations

Page 22: JRuby - The Perfect Alternative

Same stuff – Different Different

● ruby● Irb● rake● gem

● jruby● jirb● jruby -S rake● jruby -S gem

Include jruby-complete.jar or jruby.jar in your CLASSPATH & PATH for the executable

Page 23: JRuby - The Perfect Alternative

Show me stuff... JRuby integration with JVM

Ruby'ized – by popular demand!

Page 24: JRuby - The Perfect Alternative

Choose your Hammer – Calling Ruby from within Java

Page 25: JRuby - The Perfect Alternative

Choose your Hammer – Calling Ruby from within Java

JSR 223

Page 26: JRuby - The Perfect Alternative

Choose your Hammer – Calling Ruby & Groovy from within Java

Page 27: JRuby - The Perfect Alternative

Choose your Hammer – Calling Ruby & Groovy from within Java

Why would we want to do

this? Because we can

Page 28: JRuby - The Perfect Alternative

Choose your Hammer – Calling JRuby file from within Java

Page 29: JRuby - The Perfect Alternative

Choose your Hammer – Calling JRuby file from within Java

Page 30: JRuby - The Perfect Alternative

Ruby > Java

Page 31: JRuby - The Perfect Alternative

Ruby > Java & Back

[SNIPPED]

Page 32: JRuby - The Perfect Alternative

Ruby > Java & Back

Page 33: JRuby - The Perfect Alternative

Performance & External Libraries

● For the sake of performance it would be better to use Java Libraries over JRuby at times.● Totally depends on your requirement.

● Including external Java libraries within your JRuby Code is fairly straightforward● You can also put the jar files in the rails lib directory

for getting access to them in your rails application

Page 34: JRuby - The Perfect Alternative

JfreeChart – Chart Generation

● All you need to do is either have the jars in your classpath

● Or include it in your libs folder in rails.

http://kfahlgren.com/blog/2007/04/13/jruby-jfreechart-sparklines/

Page 35: JRuby - The Perfect Alternative

JRuby & Library Jars

Page 36: JRuby - The Perfect Alternative

This guy is boring why doesn't he just show me rails

Page 37: JRuby - The Perfect Alternative

The Holy Blog

Page 38: JRuby - The Perfect Alternative

...

Page 39: JRuby - The Perfect Alternative

...

Page 40: JRuby - The Perfect Alternative

DB Stuff

Page 41: JRuby - The Perfect Alternative

Packaging...

Page 42: JRuby - The Perfect Alternative

Packaging & Deploying

config/warble.rb

Page 43: JRuby - The Perfect Alternative

Voila

Page 44: JRuby - The Perfect Alternative

In Summary

● I strongly believe JVM should be your platform Strategy ● This more or less comes out of my experience. ● JRuby will fit into many cloud architectures with little

effort (Not sure of Azure yet)– Portability from within

Page 45: JRuby - The Perfect Alternative

Useful Links

● http://jruby.org/● http://www.infoq.com/vendorcontent/show.action?vcr=940● http://code.google.com/p/appengine-jruby/ >

http://rails-depot.appspot.com/ ● http://en.wikipedia.org/wiki/JRuby#Performance

Page 46: JRuby - The Perfect Alternative

Ram Vijapurapu@rvijapurapu

thinkbelievedo.com