Ruby on Rails Thor Marius Henrichsen Frode Nerbråten Outline

• Ruby • • JRuby • BEKK on Ruby on Rails What is Ruby?

A dynamic object oriented with: • elegant and natural syntax • focus on productivity • roots from Lisp, Perl and SmallTalk

Written by Yukihiro Matsumoto, or just “Matz” Elegant syntax

Ruby on Rails

• Open source MVC-based web framework • Well suited for database-backed applications • Rails gives you a pure-Ruby development environment Rails highlights

• Convention over configuration • Flexibility • Clean and DRY code • High productivity Blog with comments

• Existing blog application without comments • We will add • a new table • a new model and controller • view markup

JRuby The old Java platform

Java JVM

Libraries

The new Java platform

Java DSL Jython JVM JRuby

Javascript

Libraries Ruby Limitations

• Green Threading - No scaling across processors/cores • Unicode support - Partial and inconsistent • Memory management - Simple design - Stop the world GC Ruby Limitations

• C Language extensions - C is difficult - Often needs recompilation • Politics - You want me to run what?

Why JRuby

• Scalability through native threading • Better memory and GC management • Native unicode support - A must for web applications • Enterprise acceptable - It’s just a Java library Why JRuby

• Faster than MRI on most benchmarks • Java can call Ruby • Ruby can call Java • Open java classes and add - Methods - Fields

JRuby on Rails • Deployment on most Java servers - A simple servlet container will do • Java is a proven web application platform - Addresses a bunch of difficult issues • WAR deployment - Transparent for sysadmins - Easy distribution • Utilizing server features - Scaling, Connection pooling JRuby Limitations • Native libraries - But decent ports exists • Startup - Use MRI for development • Missing File operations - Limited to what’s provided by the JVM • Maturity - Version 1.0 released June 2007 Ruby @ BEKK Ruby @ BEKK

• Completed 2 Ruby on Rails projects • Dedicated competency group • Contributers to Ruby open source projects • Rails, JRuby, Rspec, Cucumber, +++ • Represented on Ruby/Rails conferences worldwide Why Ruby

• Ruby on Rails is over the hype • JRuby makes Rails an eligble alternative for some of our customers • Growing interest among employees • Happy developers write better code! • Ruby lends it self to practices of agile development • Testing at all levels is easy and fun! Project Experience - Background

• Rewrite project for long term customer • Java based legacy solution • Huge code base • Duplicate code • Modified over 10 years • No automated test suite • Frequent change requests • Regressions Project Experience - Technology

• MRI Ruby in test/development environments • JRuby on Glassfish Application Server in production environment • Rails 2.1 • Legacy database with a view layer to support Rails conventions • Rspec, RubyFIT, Watir Project Experience - Outcome

Result Language: Java Norway: 50 000 LOC Language: Ruby Denmark : 50 000 LOC Total: 3 835 LOC Automated tests: 0 LOC Total : 100 000 LOC Automated tests: 10 418 LOC Total: 14 253 LOC Originally

4 developers approx. 6 months Ruby on Rails makes developers happy and happy developers write better code Where can I learn more?

http://ruby-lang.org http://jruby.org http://rubyonrails.org