SV-Ruby Meetup, 2009-03-19
Yehuda Katz talked about Rails 3
Rails API should not change! It’s a mistake to change the API and the implementation at the same time (think Ruby 1.9 language and VM).
ORM Agnisticism
With for_for @obj, @obj can be an ActiveRecord, DataMapper, CouchDB, SimpleDB, Sequel object. Two interfaces are now support for ORM objects, ActiveRecord/DataMapper style: errors, #each, #join and Sequel style: errors, #to_str.
Under the covers: Works with any ORM that codes to the interface:
1 2 3 4 5 | ActionORM::Drivers::AbstractDriver initialize new_record? errors valid? |
Sequel will provide a proxy for their users, an adapter to ActiveRecord API. Inside Rails, the only line that changed is:
objects.map! { |o| ActionORM.for(o) }
Makes writing plugins easier.
Rack
- Is an abstraction between servers (Mongrel Thin Webrick IRB CGI Runner Eb FCGI) and Rails/Merb.
- Prefork – efficient parallelization.
- Middleware: build up pipes of stuff between the server and Merb/Rails
- Rails 2.3: Sessions is middleware, Failsafe is middlware. To use in Rails 2.3, do: config.middlware.use Foo
Router can now route to RailsController or MerbController or RailsRouter or SinatraApp, it really doesn’t matter.
AbstractController
A pluggable API for building controllers. Add what you want: dispatch, callbacks etc, leave out what you don’t want.
Public / Private / Plugin API
Rails had a public API and everything else was :nodoc:. Trouble with that was that there was no stable interface for plugin writers to implement against.
Rack::Bug
Debug toolbar based on Django Debug Toolbar. Made pluggable with Orchestra – a pub/sub framework for streaming instrumentation events that Yehuda just started. Lower impact. Will work for New Relic, Five Runs, etc.
Exception Middleware
JavaScript
<form class="remote" method="post", ...
Then in rails.jquery.js
$("form.remote").live("submit", function() { $this.ajaxSubmit(); })
Replace it with rails.you!.js
Performance
Ruby 1.9 is now 2nd fastest dynamic language at 50x slower than C++. Python2 is the fastest (40x), PHP is the new loser (100x) now that Ruby 1.8.6 (150x) is gone.
Rails Boost
Build you own custom rails stack. Pick templating language, pick javascript framework…
Competition
Plugin APIs allow everyone to compete in the area they are interested in, without having to write an entire framework.
Schedule
Alpha for Railsconf. Need something to give to plugin writers. Would like to get it released by EOY.
