Scotland On Rails 2008 - Day Two
Today was the second day of Scotland On Rails which I was visiting courtesy of a free ticket from EngineYard.
Update: They had tea, maybe all conferences should do this!
Here’s a run down of the talks I went to:
Keynote – David A Black
Despite having been ill the day before, David provided a talk on the similarities between programming and music. I’m sure other people will provide more on this, but one difference is that musicians don’t hate those who play different instruments, unlike coders ripping on other coders due to their choice of tools.
Rails Patterns – Jonathan Weiss
Jonathan gave a talk on some common rails patterns, here’s a rundown:
- Long running tasks, video/audio processing etc: Break these off into separate jobs, and run them later.
- Lots of data: Use a background process to push to a service such as “Amazon S3”:, and use your local disk as a cache in case of downtime or for popular content.
- Plugins: Don’t blindly use them, always look over the code. A lot of plugins are poorly or infrequently maintained.
- Dependencies: Vendor everything, Gems, Rails. Saves your developers a lot of time in getting up and running when they join the team.
- DOS avoidance: Split up your Mongrels into groups, that way multiple slow downloads or uploads don’t consume all your resource. Don’t use sendfile, use xsendfile, free’s up the Mongrels faster. Maybe use another tool to deal with uploads, Merb or CGI.
Collective Intelligence: Leveraging User Data to Create Intelligent Rails Applications – Paul Dix
Paul of Mint Digital gave a great talk on how you can mine your user data to provide them with recommendations. Using the “Netflix challenge” data, he showed an example using Ruby and some C libraries. Very clever stuff, I’ll probably be digging into this more later.
Advanced Ruby Class Design – Jim Weirich
Jim gave a great talk on designing Ruby classes in a Ruby way. He highlighted some cool tools, including the BlankState class, which undefines all the Object/Class methods normally attributed to a Ruby class. In 1.9 there will be a version of this called BasicObject, from which Object inherits, thus creating fewer problems for classes doing clever things like DSLs where namespaces may collide.
Domain Specific Languages: Molding Ruby – Joe O’Brien
Today Joe presented a talk on DSLs. So what is a DSL? Well, you know the absurd nomenclature Starbucks use for their coffees? Venti, Grande, etc. Well, that is a DSL, designed so that when a customer makes an order, the chance of the barista getting the order wrong is pretty wrong, as everything is ordered so that nothing can be missed out. I essence, as someone pointed out, the barista is a compiler.
A DSL is a mini language, if you will, with “Rake” being one of those that Rails developers will be most familiar with. When designed well, a DSL will bring methods calls and operations up to the level of natural language. Image the benefits of a well designed DSL in showing implementations and getting approval from clients. So, bring your code up to the client, not the client down to the code.
JRuby on Rails: Up And Running – Charles Oliver Nutter and Thomas Enebo
Charles and Thomas (THE JRuby guys) presented what was for me, the best talk of the entire conference. Not only in it’s revelations, but the enthusiasm they brought to the subject of JRuby.
The last time I played with JRuby was a year ago, when it was pre 1.0, and a bit buggy. During the talk the guys officially released 1.1, despite it being available for over a week. To save me a lot of effort I’m just going to list some of the facts regarding it:
- JRuby is just Ruby.
- Has a Java port of the Oniguruma regular expressions library, like Ruby 1.9.
- Compatibility is key in it’s development, Rails, Rake, RSpec etc all run. Full ruby 1.8.6 compatibility. 42k assertions in tests.
- Java 6 over 30% faster than 5, all good for JRuby.
- JRuby 1.1 is 2-5x faster than Ruby 1.8.
- Dynamic optimization makes programs run faster as they run longer.
- JRuby almost twice as fast as Ruby on a single thread. Threads in JRuby are real, so near-linear scaling across cores!
- Can take advantage of different profilers available to Java, the guys showed a live profiler demo inside NetBeans using fractal benchmark.
- Can call Java APIs/classes from within Ruby. Showed off a Swing example where the interface was build through Ruby methods, much nicer than the horrible Java methods.
- Can dynamically add methods to Java classes, Java won’t see them though.
- NetBeans supports JRuby and Ruby. Command completion, method completion, method jumping, regexp completion, % completion. Shows RDoc for methods as you type them. Auto complete require classes and subclass completion.
- Example of Processing , run Ruby algorithms, through the Java lib, hardware accelerated on OpenGL. Games, Nick? These guys reckon someone will do it soon.
- JRuby database support through activerecord.
- Package your Rails app as a WAR file, everything in 1 process. Throw into GlassFish, done, instant scaling across multiple processors.
- JRuby runs in asynchronous mode, can spin off new processes.
- Ruby 1.9 support on the way, maybe in the next major release.
Awesome stuff, expect an article on getting up and running with Rails on GlassFish here soon.
Wrapup
All in all, it has been a fantastic few days. I’ve learnt lots of stuff and met some great people. Roll on next year.
Thanks very much to the SoR Team for all their organisation.