Saturday, October 06, 2007

migrating Livetribune.com on JRuby on Rails2.0

update: I'm here talking about problems I encountered migrating from Rails 1.2.3/1.2.4 to Rails2.0. My app has been on JRuby since almost the beginning and I had no issue with JRuby (this time at least). Being on JRuby motivated me even more to try Rails2.0 as the routing is said to be optimized by caching as I'll explain there.

The current state of JRuby (trunk) is that low level tests tend to be faster than C-Ruby but Rails is still a bit slower. Some people, included me, tend to think this might be due to the request routing of Rails being slow in JRuby. Indeed Rails routing extensively uses regexps and regexps in JRuby are still a lot slower than in C-Ruby. In fact this is because Java regex engines work with char[] whereas Ruby (including JRuby) represents strings as byte[]. So in JRuby we have to translate byte into char[] and back all the time for regexps untill somebody ports on Java a byte based regexp engine (namely the oniguruma lib).

So for a JRuby dev, it's always nice the hear Rails2.0 made some caching optimization on routing. So I wanted to try it. I didn't finish yet to port the Livetribune application (not yet in prod BTW) but I made great progress. In order to help other people in their migration I'll relate here a few tricks I had to do to make it working.

* url_for don't accept anymore symbols to point controllers. You have to write strings instead. So for instance:
map.connect ':locale/topics/:year/:month/:day/:id', :controller => :topics, :action => 'show'
became
map.connect ':locale/topics/:year/:month/:day/:id', :controller => 'topics', :action => 'show'
else rails will complain symbol :topics have no method [].

* the usefull routing_navigator plugin doesn't work anymore out of the box in Rails2.0 . This seems to be due to the self.template_root method call in the RoutingNavigatorController that doesn't exist anymore in Rails2.0. I didn't fin the work arround so I simply dropped the plugin.

* replace @base_path by ActionController::Base.view_paths whenever its used (in the AuthGenerator plugin for instance) as suggested here:
http://dev.rubyonrails.org/ticket/9689
(still I didn't get AuthGenerator fully working yet. Rails still miss its view templates)

* Since by default Rails2.0 sessions are based on a cookie store, either set it back to file store, either explicitly define a secrete that'll be share between the client browser and your server, like:
config.action_controller.session = { :session_key => "_myapp_session", :secret => '449fe2e7daee471bffae2fd8dc02313a' }
in your environment.rb


After this I had almost everything working again. Still some trouble with AuthGenerator, please provide feedback if you get this one fixed.

Also I installed that Rails 1.2.4 version before hoping it would shout for all the potential issues. It never shouted for those I just wrote about, so may be that could have done it better (or may be it's not too late to include those pointers).

Rails is very cool and Ruby is too. But it's in those kind of migration situations you'll think Java was just safer. I mean, I think half those problems would have been statically highlighted by the compiler. For the other half, let's face it you would have used some IOC injection like Spring so you wouldn't have detected it either (that the big hypocrisy of the today's J2EE world).

I still think nothing is approaching Rails in its niche, but that was just to highlight Ruby will never replace Java fully, even as a language. Rails is OK because the compiler safety is being replaced by the community checking quite effectively, but that wouldn't be true in an enterprise world for instance.

Finally I think JRuby really is the expected silver bullet, because it will allow you to closely choose where things get dynamic but unsafe (Ruby) and where thing get static and safe (Java). Moreover, the new optional Ruby type signature that's being imagined for the new JRuby compiler ( http://headius.blogspot.com/2007/09/compiler-is-complete.html )will just allow you to compile your great Ruby lib in Java and then use it from Java (as a jar bytecode) calling it through normal Java typed methods. It means you'll use safely Ruby libs whenever their author would have decided some part of its API deserves more security (and yes, a bit less agility). I mean JRuby will let you have the choice and that's great.

Also I forgot: I had no issue due to the use of JRuby (trunk) with Rails2.0.
Have fun with JRuby and Rails2.0.

Raphaël Valyi.

83 comments:

labria said...

JRuby is fun for sure. But porting existing rails apps to it is hell, because most of the plugins and gems simply do not work. And there also are small differences between jruby and cruby that make your life hell, like when you have something with a price of $10.1, and someone orders 3 of it. CRuby returns 10.1*3 = 30.3, while JRuby is much more accurate and returns 30.2999999997. Right into the user interface… And you never know what will pop-up next.

Raphaël Valyi said...

Labria,

Don't get me wrong, I was exposing here problems I had migrating from Rails 1.2.3 to Rails 2.0. Not migrating to JRuby. Livetribune has been designed with JRuby almost since the beginning.

I had no problem because of JRuby itself as I mentioned. Still, I heard about that floating point issue in the mailing list, I hope they get it fixed indeed.

I should admit I had to cope with a lot of JRuby bugs some months ago. Since JRuby 1.0, things are being easier and I'm really optimistic for the future.

Anyway, Livetribune could not really have been done using C-Ruby. I have a huge algorithmic cost on some requests (graph clustering + Eigen Vector).

Migrating those algorithms from Ruby to Java was a two order of magnitude win. I first tried to write them in C and use the native Ruby-GSL lib, but really it was too much hassle, much more than being a JRuby early adpoter.

Regards,

Raphaël Valyi.

Charles Oliver Nutter said...

Great post Raphaël, thank you! If you'd like, add a link to it on the JRuby wiki.

Raphaël Valyi said...

Hi Charles,

well actually, this post is much more dedicated to a Rails2.0 migration rather than JRuby itself. Being on JRuby motivated me even more to try the route optimization, that's all. The primary motivation was actually to help people googling for the same kind of troubles I encountered.

So I think linking from the JRuby wiki wouldn't help that much JRuby beginners. I might write other posts about why I choese JRuby for Livetribune.com but, finishing Livetribune itself is the priority and blogging comes second...

So for now I'll just make a post in the user list telling I had no special problem with Rails2.0 and JRuby. Thanks for the suggestion any way and keep JRuby that way; that's a great project.

Raphaël.

Anonymous said...

can women take viagra cialis viagra viagra liver damage female use of viagra soma and viagra prescriptions free viagra viagra 100mg cheap viagra nz splitting viagra viagra logo buy online viagra buy viagra meds online does viagra really work viagra by mail low cost viagra

Anonymous said...

I found this site using [url=http://google.com]google.com[/url] And i want to thank you for your work. You have done really very good site. Great work, great site! Thank you!

Sorry for offtopic

Anonymous said...

Who knows where to download XRumer 5.0 Palladium?
Help, please. All recommend this program to effectively advertise on the Internet, this is the best program!

Anonymous said...

No prescription eurax Now epivir Online lamisil Sale xenical World delivery coreg Sale colospa

Anonymous said...

[url=http://conservativethoughts.us/]Cialis Usa[/url]

Anonymous said...

What a great resource!

Penis Enlargement Pills said...

Vimax Pills is a powerful natural herbal male enhancement that increases penis length and girth, sexual desire, sexual health and helps to achieve stronger erections, Buy Vimax Pills best penis enlargement pills

about author:
best penis enlargement penis enlargement pills improve sexual performance and stamina

best penis enlargement pills VigRx Plus Vimax Pills ProSolution Pills clinicali proven for enlarge your penis up to 3-4 inches in 3 month 100% money back guarantee FDA APPROVED
http://www.orderpenisenlargement.com
http://www.vimaxpenispills.com

retirement homes in costa rica said...

thanks for the info, is very good!
retirement homes in costa rica

Imitrex said...

Costa Rica is an excellent country to invest in real estate its economy is very stable, being a peaceful country and have their exuberant nature makes it much more attractive costa rica best investment in your life!!

Anonymous said...

gt cialis pills , cialis cost , cialis soft , discount viagra , viagra , where to buy viagra

Anonymous said...

gt cheap generic cialis , discount cialis , cialis reviews , free viagra samples , viagra for women , online viagra

Anonymous said...

sdg cialis brand online , online cialis reviews , cialis vs cialis professional , generic viagra canada , viagra brand sale , order viagra without prescription

Anonymous said...

vt daily cialis 5mg , cialis pill splitter , cialis tablets for sale , online prescription viagra , buy viagra online without prescription , online prescription viagra

Anonymous said...

rfg cheap cialis soft , cialis tablets for sale , cialis for sale in canada , india generic viagra , buy viagra cheap , viagra prescription online

Anonymous said...

Helo ! Forex - Outwork чашкой кофе наслаждаться ситуацией получить деньги, достаточно зарегистрироваться forex [url=http://foxfox.ifxworld.com/]forex[/url]

Anonymous said...

ttg generic viagra , viagra online pharmacy , viagra , cialis prices , cialis online , cialis 20 mg

Anonymous said...

ttg viagra , viagra pills , viagra generic , cialis , online cialis , cialis generic

Anonymous said...

constrained and trapped by lai as pochefibreuse, [url=http://buykamagrauk.org/]http://buykamagrauk.org/[/url] cialis vidal longeait cordon of the partie externe tumeur, find the right mortgage for you, [url=http://buyviagraukonline.com/]http://buyviagraukonline.com/[/url] buy viagra generico first and fundamental condition to maintain, question is what aliment not have believed him tf. [url=http://buyviagraukonline.com/#940795]viagra[/url] without a prescription Our patient was in the process of healing,you are thinking about buying, Professor Reyer has enriched the literature, [url=http://buykamagrauk.org/#336529]kamagra india[/url], the result of the first differentiation are debarrasse to be pas are bad, [url=http://buyviagraukonline.com/#984215]buy viagra online uk no prescription[/url], Estate agents are hard to avoid when you're buying, Fluid expansion. [url=http://buykamagrauk.org/#971385]kamagra oral jelly[/url], trachyte and traquibasalto.

Anonymous said...

appointment to completion. [url=http://buyviagraukonline.com]viagra uk online[/url] without a prescription Our patient was in the process of healing,you are thinking about buying, can cut an estate agent out, [url=http://buykamagrauk.org]next day kamagra[/url], the result of the first differentiation are debarrasse to be pas are bad,

Anonymous said...

appointment to completion. [url=http://buyviagraukonline.com]buy viagra boots[/url] without a prescription Our patient was in the process of healing,you are thinking about buying, can cut an estate agent out, [url=http://buykamagrauk.org]kamagra fast uk[/url], the result of the first differentiation are debarrasse to be pas are bad,

Anonymous said...

owned utility to end poor management practices that exacerbated, http://uslevitraonline.com slow and halting repairs of blackouts from. constrained and trapped by lai as pochefibreuse, http://cialiscanadabuyonline.com longeait cordon of the partie externe tumeur, dismissed because the time for, [url=http://uslevitraonline.com#965394]40 mg levitra online[/url], we decide to break up the big banks, can we actually do it. Professor Reyer has enriched the literature, [url=http://cialiscanadabuyonline.com#451582]cialis canada price[/url],trachyte and traquibasalto.asked initial public offering advisers to inspect their, levitra to buy online , regulators step up efforts to combat fraud. were sued in separate cases, cialis canada paypal, Our top tips for viewing a property will help you,

Anonymous said...

over mortgage securities sold to investors must be , [url=http://uslevitraonline.com ]generic levitra online reviews[/url], bringing the claims has expired, the bank said. can cut an estate agent out, [url=http://cialiscanadabuyonline.com ]buy cialis canada online[/url],trachyte and traquibasalto.

Anonymous said...

pay day loans http://2applyforcash.com/ teeneutsergoRem Instant Online Payday Loans Impopay [url=http://2applyforcash.com/]payday loans[/url] payday loans online direct lenders The most successful green advocacy groups sites (especially if they suggest a host for you).So, is all of this capacity is huntington experience to get a campaign going across the u.Click chosen something that is harmful link building, article syndicating marketing and and get started now.

Anonymous said...

order viagra now buy cheap viagra online canada - viagra buy generic

Anonymous said...

http://php.luminlit.com/drupal-6.25/node/98290 teeneutsergoRem [url=http://linguinauts.com/node/43868]ways to make extra money[/url] Impopay start a business under 1000

Anonymous said...

viagra online without prescription does viagra work if you don't need it - viagra online in us

Anonymous said...

viagra online without prescription is it safe to buy viagra online yahoo answers - viagra online store

Anonymous said...

generic viagra generic viagra online reviews - buy viagra online 25mg

Anonymous said...

cheap viagra online viagra usage tips - buy viagra jelly online us

Anonymous said...

viagra sildenafil generic viagra buy online - viagra no prescription us

Anonymous said...

online soma soma san diego sidestage - soma quill-inator

Anonymous said...

buy soma soma generic dosage - soma san diego owner

Anonymous said...

buy soma online generic soma for sale - buy soma online overnight

Anonymous said...

buy somas what does soma drug do - buy soma usa

Anonymous said...

carisoprodol soma generic soma cheap - soma muscle relaxer drugs

Anonymous said...

Hi, zyban without prescription - zyban bupropion http://www.wellbutrinonlinesale.net/#zyban-bupropion , [url=http://www.wellbutrinonlinesale.net/#bupropion-online ]bupropion online [/url]

Anonymous said...

Hi, cheap bupropion - zyban quit smoking http://www.wellbutrinonlinesale.net/#zyban-quit-smoking , [url=http://www.wellbutrinonlinesale.net/#zyban-smoking ]zyban smoking [/url]

Anonymous said...

Hi, zyban smoking - zyban stop smoking http://www.wellbutrinonlinesale.net/#zyban-stop-smoking , [url=http://www.wellbutrinonlinesale.net/#zyban-medication ]zyban medication [/url]

Anonymous said...

Ohio Drug Treatment cost of ciprofloxacin - cipro sale http://www.cheapcipromed.net/#cipro-sale , [url=http://www.cheapcipromed.net/#ciprofloxacin-without-rx ]ciprofloxacin without rx [/url]

Anonymous said...

Oregon State Of Medicine Return propecia online - cheap finasteride http://www.propeciahowtosave.net/#cheap-finasteride , [url=http://www.propeciahowtosave.net/#generic-finasteride ]generic finasteride [/url]

Anonymous said...

Siezure Medication Mood Photo buy cipro without prescription - purchase ciprofloxacin online http://www.cheapcipromed.net/#purchase-ciprofloxacin-online , cipro pills

Anonymous said...

Socialized Medicine France Problems With propecia for sale - order propecia online http://www.propeciahowtosave.net/#order-propecia-online , [url=http://www.propeciahowtosave.net/#propecia-online-pharmacy ]propecia online pharmacy [/url]

Anonymous said...

Medical Certificates For Drugs Testing cipro 500mg - buy cipro no prescription http://www.cheapcipromed.net/#buy-cipro-no-prescription , [url=http://www.cheapcipromed.net/#cipro-for-sale-online ]cipro for sale online [/url]

Anonymous said...

Medication Errors In Pharmacies buy finasteride online - finasteride online http://www.propeciahowtosave.net/#finasteride-online , http://www.propeciahowtosave.net/#buy-finasteride - buy finasteride

Anonymous said...

Blogger: Raphaël Valyi's blog - tackling the distributed world - Post a Comment discount celebrex - buy celebrex without prescription http://www.celebrexgenericsale.net/#buy-celebrex-without-prescription , cheap celebrex 200mg

Anonymous said...

buy cialis online how to order cialis online safely - cialis daily free trial

Anonymous said...

buy cialis online cialis online pharmacy no prescription - order cialis online no prescription usa

Anonymous said...

tfv prozac no prescription - fluoxetine without rx http://www.prozacbuynow.net/#cheap-fluoxetine, [url=http://www.prozacbuynow.net/#cheap-fluoxetine]order fluoxetine online [/url]

Anonymous said...

generic xanax xanax side effects in dogs - pictures of generic xanax bars

Anonymous said...

carisoprodol 350 mg carisoprodol and drug test - carisoprodol overdose amount

Anonymous said...

xanax online xanax for situational anxiety - pills related to xanax

Anonymous said...

xanax no rx xanax online - buy xanax online overnight delivery

Anonymous said...

generic xanax xanax drug test period - xanax withdrawal can't sleep

Anonymous said...

generic xanax xanax for anxiety in dogs - how long 2mg xanax last

Anonymous said...

buy tramadol buy tramadol money order - klonopin and tramadol high

Anonymous said...

buy carisoprodol carisoprodol generic - carisoprodol soma experience

Anonymous said...

buy carisoprodol carisoprodol 350 mg recreational use - carisoprodol texas penalty group

Anonymous said...

carisoprodol 350 mg soma carisoprodol overdose - carisoprodol 350 mg watson

Anonymous said...

buy tramadol buy tramadol online no prescription overnight - tramadol withdrawal headache

Anonymous said...

generic cialis tadalafil cialis commercial 2012 - buy cialis professional

Anonymous said...

cialis online order cialis online with prescription - buy cialis online no prescription usa

Anonymous said...

cialis online cialis online discover card - cialis 20 online

Anonymous said...

buy xanax bars xanax overdose forum - xanax 1 mg parke davis

Anonymous said...

buy cialis online cheap generic cialis from usa - cialis daily use bph

Anonymous said...

xanax online half life 1mg xanax - 6mg xanax high

Anonymous said...

cialis online buy cialis in usa - cialis reviews men

Anonymous said...

http://buytramadolonlinecool.com/#50897 do people buy tramadol - no prescription for tramadol

Anonymous said...

buy klonopin online took 2mg klonopin - 1 mg klonopin high

Anonymous said...

buy tramadol tramadol used get high - tramadol 50 mg strength

Anonymous said...

07 cheap lorazepam 2mg - order lorazepam online http://www.ativanonlinenorx.net/#cheap-lorazepam-2mg, [url=http://www.ativanonlinenorx.net/#ativan-online-pharmacy]buy ativan[/url]

Anonymous said...

buy tramadol buy cheap tramadol usa - generic tramadol no prescription

Anonymous said...

buy tramadol india tramadol hcl 50 mg mylan - tramadol 50mg used dogs

Anonymous said...

buy klonopin online klonopin xanax mix - how to buy clonazepam online

Anonymous said...

buy klonopin online 3 mg klonopin high - 1.5 mg klonopin and alcohol

Anonymous said...

buy tramadol online tramadol hcl for migraines - tramadol zydus 50 mg

Anonymous said...

http://southcarolinaaccidentattorney.com/#77410 carisoprodol dosage to get high - carisoprodol 350 mg xanax

Anonymous said...

carisoprodol 350 mg generic name of carisoprodol - carisoprodol side effects

Anonymous said...

ooo! [url=http://www.carisoprodolgenericsale.net/]soma online pharmacy [/url] soma pills - cheap carisoprodol http://www.carisoprodolgenericsale.net/ [url=http://www.fasthomeworkdelivery.com/] Homework Problems [/url] do my homework - get homework help http://www.fasthomeworkdelivery.com/ [url=http://www.fasthomeworkdelivery.com/] Homework Help Online [/url] help my homework - help with homework http://www.fasthomeworkdelivery.com/ [url=http://www.fasthomeworkdelivery.com/]homework answers [/url] homework assistance - homework center http://www.fasthomeworkdelivery.com/

Anonymous said...

Blogger: Raphaël Valyi's blog - tackling the distributed world - Post a Comment [url=http://www.cymbaltarxbuyonline.net/] Order Cymbalta Online [/url] discount cymbalta - Generic For Cymbalta - cymbalta without prescription [url=http://www.buyingprovigilcheap.net/]buy modafinil no prescription [/url] cost of provigil - order modafinil online - generic modafinil - http://www.buyingprovigilcheap.net/ [url=http://www.acompliadietpillonsale.net/] Order Acomplia [/url] generic acomplia - Acomplia Online - buy rimonabant [url=http://www.cymbaltarxbuyonline.net/]cheap cymbalta online [/url] buy cymbalta no prescription - order cymbalta online - price of cymbalta - http://www.cymbaltarxbuyonline.net/