RailsConf Concert: _Why the lucky stiff and the thirsty cups

ODD. But really entertaining.

!http://static.flickr.com/52/173568804_1ec3016f85_m.jpg!:http://flickr.com/photos/kastner/173568804/

He talked as well as did music, and it was really cool!

RailsConf keynote: Paul Graham

His rapid-fire delivery made it hard to keep good notes (plus I was laughing too much)

!http://static.flickr.com/62/173548848_6e0018890a_m.jpg!:http://flickr.com/photos/kastner/173548848/

He started with a joke about Powerpoint

He went to visit the apple garage quite a few years back. His friend was amazed by how cold they must have been. Shaper delination between inside and outside in colder climates. A bunch of big time companies in the silicon valley started in garages. Jobs and Woz were marginal folks – hippies and dropouts. Their previous business venture was making and selling blue boxes – not only illegal but also unprofitable.

Poets and Painters – coders belong to this group.

h3. The Paradox: Great ideas come from the margin, but everyone (including the creators) look down on them

What kinds of ideas come from outsiders?

Can we encourage those ideas?

What would happen if the government wanted to write the great american novel? Nothing good. The writer would play it safe. He’d write about the Civil War. And it would toe the line about it being about slavery. Lots of diversity. I’d be a 900 page monstrosity that would take 9 years to write.

Don’t learn things from people that are bad at them.

I gave up a few minutes in. I didn’t want to miss anything. AWESOME keynote.

RailsConf Keynote: Martin Fowler

!http://static.flickr.com/73/173487461_f462e4297a_m.jpg!:http://flickr.com/photos/kastner/173487461/

Martin Fowler did the keynote at the end of the first day.

Quick Version: WOW. An amazing talk. Very funny, very engaging. He circles around a point, then re-enforces it several times.

He thought it was strange that he was asked to talk – since he’s never used Rails.

Then he went on to talk about what he thinks about “Opinionated software”. And how Rails is an example of that. ActiveRecord (a name He came up with!) has tradeoffs. Works great if you have control over the app, db, etc. If you have a DBA or anything like that, AR is not a good pattern for your situation. If you can make your world an ORM one, with an AR mapping, life is easy. That is the major design point behind Rails’ ActiveRecord.
Rails makes what you CAN do, that much easier.
Rails has taken AR much further then anyone imagined it could go. And it shows you what you can achieve when you have single-minded focus on a pattern / set of ideals.
The idea that one framework can solve everything, is insane. But there is a right architecture for each problem.

Rails has really shown Fowler that the AR pattern can be used in much more situations then he ever thought possible.

He also really likes the drive towards simplicity that Rails exemplifies. Java’s enterprise frameworks are hugely powerful, but total overkill. As a reaction to that, things like Springs and Hibernate grew as a response. What Rails has done is taken that drive towards simplicity and taken it further then any other framework has gone. The overriding question is “How can we make it simple?”. Simple, not applicable to all problems and situations.

h3. Rails Influence

All java groups are talking about how to make their frameworks more simple. Fowler truly believes that Rails will succeed, but even if it doesn’t it’s solved a problem that needed solving. It has lightened the other frameworks, and will keep future frameworks simple from the gate.

Something else that Rails has done is challenge the notion that Simple = “Quick and Dirty”. Previously, there was a continuum that ranged from a one week VB app, that is totally unmaintainable through to total overkill and huge framework that takes forever. Rails, on the other hand, is showing that quick can be maintainable. Smalltalk was the first language that showed that quick != dirty. Then what attracted Fowler to ruby was the greatness of Smalltalk. Speed of scripting language, but clean OO for future growth. Rails takes that to the next level – into a viable framework. Quick doesn’t have to be dirty.

Strong testing culture. Rails is very embracing of testing.

h3. The conversation between developers and clients.

Does a client give “A blue toss” what language or framework that you use to build their application? Probably not, but what rails has done is: It allows us to change the rules of how we converse with our customers. We can give them instant feedback, keep them engaged and get to the target together. You cut down the cycle time.

This is the major idea of the “Agile Manifest”:http://agilemanifesto.org/.

The essence of XP, to the creator of it, was to change the relationship between clients and coders. The hardest part of sofware development is building what people NEED, not what they want. How do you best explore what they need? Well, a quick-feedback loop. Conversations between all those involved and iterating with that in-mind.
“Conversational Software Development”
Fire, aim, fire, aim, fire, aim verses
aim, aim, aim, aim, aim, fire.

The more the customer is engaged in the process, the more able they are to express their true desires and needs. Rails helps to achieve that quick cycle time.

Rails is helping change requirements planing from a static, formal process to more of a conversation. The “Customer Engagement” Notion.

Instead of asking people what they want (because they don’t really know), just give them something, and let them see how they react. Taking the idea of requirements planing is turned all the way around in this case. This is “37s’”:http://37signals.com/ modus opperandi. Watch what people do, don’t listen to what they say they want.

Fowler is much more interested in business rules then how to make a database talk to a language. He got into software to learn more about businesses. Rails makes that “plumbing” stuff go away. You can focus on the business problem.

Rails is a shift away from the idea of a developer having to worry about plumbing first and business cases second.

On a personal note, the things he’s talking about – are really resonating with me. Business is interesting, rules on how things have to work are cool – things like writing drivers aren’t.

h3. Ruby

He has not used rails, but he has used ruby for a long time. He liked perl initially because it allowed him to write easier scripts then bash and c-shell. Then he got into Python and thought it was perfectly fine. Then he read the Pick Axe. What bothered him most about Java and Python was the libraries. He truly hopes that Ruby never has extensions that are nasty and not-cleanly designed. Blocks and closures also made him very happy. Therefore, the more Rails succeeds, the more Ruby love is out there. Then more libraries are written. Also, ruby is much more then rails.

He half-jokingly said that Rails has failed because there IS a conf for it. It’s so easy that it just disappears.

h3. Post-modern programming

The real world, both in software and nature, is a mess. Lispers look down their nose at the hodge-podge of the world, but they don’t really get to make “real” software. The real-life rules are what make software interesting.

RailsConf Panel: Overcoming Scaffolding Addiction with Amy Hoy

A funny panel on how to get past scaffolding.

!http://static.flickr.com/48/173439106_5b3fe1c6d7_m.jpg!:http://flickr.com/photos/kastner/173439106/

How do I do x,y and z with scaffolding? The answer is STOP, and learn rails. Scaffolding is a rusty spoon, not a swiss army knife.

A slow start, but Amy warmed up very quickly and her slides were VERY VERY funny.

Scaffolding is also WAY overbloated. 10+ files without tests.

It is also brain-numbing. She’s disagreeing with Dave Thomases’ idea of MORE scaffolding, she thinks that it leads to bad coding.

What you need is “Cold-turkey” from the scaffolding. She recommends that you start from scratch.

kittens:
* create
* view
* edit
* feed
* put to sleep (not implemented for good reason)

jars:
* create
* edit
* view

@script/generate controller kittens create view edit feed put_to_sleep@

@script/generate model kitten –skip-migration@
@script/generate model jar –skip-migration@

Her panel was VERY basic, but VERY VERY clear and great. Her book is gonna rock.

She likes to make data before anything therefore her create method is first. She overloads the create method by looking for a variable that was posted THEN saving it.
After this step, she goes and edits the view. With the view, she’s using start_form_tag – why not form_for?
@<%= debug(params) %>@ inside the .rhtml to see what’s going on.

She then went on to show how to make a whole association. Very good!

h3. more fun with forms

* Partials
sub templates use an underscore @_kitten_form.rhtml@
* Helpers

h3. Misc.

* before_filter
* layouts partials and views

“www.slash7.com”:http://www.slash7.com/

RailsConf Panel: Rails Application Optimization Techniques & Tools (With Stefan Kaes)

“www.railsexpress.de”:www.railsexpress.de

!http://static.flickr.com/75/173400476_35563faaf5_m.jpg!:http://flickr.com/photos/kastner/173400476/

Before the panel even started, the room was totally filled to capacity. I’m really looking forward to this talk. The other big one going on right now is “Monitoring Rails Apps in Production Environments with Steven Smith”

!http://static.flickr.com/59/173402175_7e76184fae_m.jpg!:http://flickr.com/photos/kastner/173402175/

*The short version:*
Great talk, but WAY TOO FAST. He had a TON of info, and not enough time.

h3. A tiny piece of history.

Stefen started by writing a recipe app (not sexy, but a good start). He wasn’t happy with the performance with the app, so he learned how to optimize it and that is what this talk is about.

Performance Paramaters:
* How fast can you answer a request
* Throughput – requests / second
* Utilization – Servers used enough, but not too much?
* Cost efficiencey

When you compute – get mean, min, max and standard dev.

Benchmarking Tools:
* Rails log files (debug level >= Logger::DEBUG)
* Rails Analyzer Tools (you have to be logging to syslog for this to work)
* Rails benchmarker script (script/benchmarker)
* Tools provided by your DB vendor
* Apache bench (ab)
* httpperf
* “railsbench”:http://rubyforge.org/projects/railsbench/

h3. Railsbench

This tool measures request processing.
Setup is easy – config/benchmarks.yml

default:
uri: /

all: default, empty, welcom, cat, letter@

config/benchmarks.rb


RAILS.BENCHMAKER = RailsBenchmarkWithActiveRecordStoe.new
require 'user'
RAILS_BENCHMARKER.session_data = {:user_id => 23}

@perf_run 100 “-bm=welcom options” [data_file]@

h3. Ruby Profiling

The best one is Ruby Performance Validator commercial and windows only.
with railsbench:
@run_ruls 100 -svlPV -bm=welcome …@
starts RPVL and run the named benchmark with the given options

RPV:
!http://static.flickr.com/66/173411504_6e270f7eda_m.jpg!:http://flickr.com/photos/kastner/173411504/

h3. Top Rails Performance Problems:

* show helper methods
Keep helpers short
* complicated routes
routes are a problem, keep them simple
* associations
The proxy object is expensive
* too much data from the DB
Get what you need!
* slow session storage
Using ActiveRecordStore is SLOW (humm..)

DB isn’t usually the problem in his experience. AR is more of a problem

h4. Session conatiners:

* In Memory – fast, but lose on restart
* File system
Easy setup, one file per session, scales in NFS, but slower then ar
* Database/ActiveRecordStore
* “Database/SQLSessionStore”:http://railsexpress.de/blog/articles/2005/12/19/roll-your-won-sql-session-store
Uses ARStore session table format but does all procession using raw SQL queries.
* memecached
Faster then SQLSessionStore. Should scale best. Very tunable – harder to get stats
* DrbStore
used where memcached isn’t an option

h3. Caching

* Pages
Fastest, complete pages are stored and served wholey
* Actions
Second fastest. Caches the RESULTS of invoking actions on controllers
* Fragments
Useful for caching small fragments of HTML produced during request procession. They can be made user aware.

Action caching is just a special case of fragment caching.

h3. Components

Don’t use them. Not really any good uses (anybody?) Each embeded component is it’s own request (a whole process). And they can usually be rewritten using helper methods and partials.

h3. ActionView Issues

Instance variables
For each request, one controller instance and one view instance will be instanched
So avoid passing what you don’t need

h3. Slow Helper Methods

@pluralize(n,’post’)@
versus
@pluralize(n,’post’,’posts’)@
The first one instanciates Inflector. The second doesn’t.

link_to and url_for are slow. They have to do the whole route generation (which is a slow sub-process).
They are some of the slowest helper methods.
Either hand code when you need speed – or wait for his template optimizer!

h3. ActiveRecord Issues

* Associations
:include makes it faster
for has_one or belongs_to
@piggy_back :autor_name, :from => :author, :attributes => [:name]@
@article = Article.find (:first, :piggy => :author)@
(google search for “piggybacking with rails”)
piggy_back is an extension he wrote. It makes them strings – like article.author_name
Also, cache converted types. Converting is slow.

Cache textalize calls if you can (a second column would be a good idea)

h3. Ruby’s interpreter is slow

not JIT, no bytecode.

Therefore, complexity of ruby elements
Locals: O(1)
Instance vars: O(1)
Method call: O(1)
Don’t add methods that you don’t need.

Local vars are cheap

h3. Memory Managment

* Designed for batch scripts, not big server apps (bad for rails!)
* tries to minimize memory use
* simple GC (mark and sweep)
* uses malloc to manage contigous blocks of Ruby objects
* complex data structures

Ruby’s GC is not optimal for Rails
For rails, 4096 is too small for heap slots – 200,000 is a much better lower bound
@RailsFCGIHandler.process! nil,50@
will disable ruby gc and call gc.start after 50 requests.
However, small and large requests are treated the same :(

Patch Ruby’s GC (someone? please?)

h3. Template Optimizer

@< %= end_form_tag %>@ can be cached as </form>
even if you don’t know it all, it’s possible to cache some of it (what you DO know)

SICK speedup. Will be released later. He’s also releasing a book next year from Addison Wesley’s “Professional Ruby”

RailsConf Panel: Instant Rails with Curt Hibbs

h3. Instant Rails 1.x and Instant Rails 2.x

Before I get started, let me first stay that I ended up in this panel by accident. I was talking to someone in the room when the panel started. So I wasn’t 100% into the talk, but it was pretty good.

!http://static.flickr.com/65/173371111_ee725e6139_m.jpg!:http://flickr.com/photos/kastner/173371111/

“Chris Hibbs”:http://www.onlamp.com/pub/a/onlamp/2005/06/09/rails_ajax.html?page=1 started in 1975 in asm on IBM mainframes. His big breakthrough came with “Macros”
84,85,89, lots off great stuff for users. In 1990 was smalltalk.
1993 was the first VB – and that was great for developers (I agree, as much as VB is derided, It is very good.)
In 1995 things got bigger.
’96 brought us Java things were better.
’95 is also the first Ruby release in japan.
’01, complex web apps
Complex Java frameworks came out to help. Ended up being MORE complex.
in 2000, Dave thomas and andy hunt found ruby and brought them to america.
In 2004, RoR came on the scene and showed us how much pain were in without even knowing it.
2005 – Instant Rails.
Gives you a FULLLL Rails stack, without installing anything. No registry changes or anything.
Even with apps – cookbook, typo, etc. Typo is a GREAT resource for reading source code (I’ve been getting started doing this).

h3. Problems with Instant Rails

* Only runs on Windows
* Old versions of apache 1.3 and mysql 4.1
* Ui SUCKS

The reason for all these problems: It’s a fork of EasyPHP.
Instant Rails 2.0 is going to be addressing all of these issues.

[Demo of running instant rails]

h3. Instant Rails 2.
based on XAMPP

* Total re-write
* XAMPP
* Web based admin
* Cross Platform
* Apache 2
* MySQL 5

RailsConf panel: AC/DC, Stravinsky and Rails

Well, this is pretty cool. The first thing I got to see at my first panel was the famous “Accordion Guy”:http://accordionguy.blogware.com/blog
!http://static.flickr.com/60/173287100_f1ae408843_m.jpg!:http://flickr.com/photos/kastner/173287100/

That’s an awesome start to this panel, Let’s see where it goes from here.
(I posted this early, there will be updates)

Then Joey performed “All night long”!http://flickr.com/photos/kastner/173292403/

!http://static.flickr.com/60/173292403_ecdec3a0af_m.jpg!

“How software can better be constructed”

h3. AC/DC “Black in Black”. One of their best albums, good throughout.

1. Discover yourself
Adam’s law of AC/DC: You know the title, you know the chorus.
Adam’s law of Rails: If you know the url, you know the controller – and possibly the model. Convention over configuration.

Let’s listen to “Back in Black” (the song) – what isn’t there? Notes. Lot’s of space in-between notes. Most programmers fill all space with code. Rails is the opposite of that.
One example is not writing code just because you think someone WILL want it down the line.

2. Consistent
AC/DC is consistent, it’s hard rock, and it’s about sex, drugs or rock-and-roll.
Rails is consistent with MVC, always. You need data – Model. You need front-end stuff – Views.
Rails pushes you to be consistent

3. Intuitive (GREAT slide of a t-shirt about the how to do devil-horns)
AC/DC is there to ROCK OUT.
Rails helps you ROCK OUT, in a web-way. By using conventions, you know what to do and where to do it.
“Why dig, when you can just Know?” — Bruce Williams

4. Bus Factor – How many people need to get hit by a bus before your app dies.
AC/DC has a bus factor > 1. Their lead singer died, and they continued to rock. (another great slide – from zoolander)
If DHH died, would Rails? No.

Have your own core, like Rails. Everyone should know the code and be able to have access to it. Write comments, write a journal, write a blog. Explain your decisions.

5. Easy
AC/DC’s music is VERY easy, and that’s why some people don’t like it. He then showed a tablature for Back-in-black, it’s very simple.
Rails – your apps should be just like it. Very simple, very clear and using conventions (i.e. Patterns will save your soul)

Is there something like tablature that you can use for your code to have a high-level overview of your choices

6. Flatten the cost curve
AC/DC – you could write, record and release your very own AC/DC song in about a day.
Rails can reduce the cost function of software. If you stay “in the lines” it goes even lower. Automated tests, automate deploy, etc. It discourages you from doing bad stuff like tons of code in yoru view.

Keep your app aesthetically pleasing.

h3. The Rite of Spring

1. You and one hundred of your closest friends
Stravinsky – it takes a LOT of people to play The Rite of Spring. Much like J2EE
With Strav, requirements never change.

2. You ain’t seen complexity
Some software has to be complex – Banks, Laws, etc etc. But too often, developers impose it on themselves unnecessarily.
Now a slide from the Rite of Spring. It’s VERY complex

3. Non-conformist expression
The 11 / 4 bar. Most music is 4 / 4 time, one bar of The Rite of Spring has 11 notes. That is nuts. Why didn’t he make it simple and idiomatic? B/C it’s art. In your own time, on your own projects, go for it. Do whatever you want. But when you’re doing something enterprise or even maintainable – it sould be more like a nursery rhyme then The Rite of Spring. Also, don’t be more clever then your peers.

We just heard a small section of the piece. It is very hetic and difficult.

4. How do you get to Carnegie Hall?
The training for being able to play the Rite of Spring is huge. Somewhere around 8 years of a single instrument. To conduct is even more.
Somewhere around 1100 years of training for one orchestra to be able to play the piece all the way through.

h3. Rails

1. Different Flavors
AC/DC is two ways – two different singers
Rite of Spring has two different formats, the orchestral version and a two piano version.
Rails has the ability to drop parts like ActiveRecord, or add parts like plugins.

Don’t think of your rails app as just a DB on the web. Mashups, widgets, embed in an executable.

2. Fight!
All three have the propensity to cause riots. The Rite of Spring caused an actual riot when it premiered. AC/DC has caused more then a few fights. As has Rails. Passion is the common thread.

In your apps, passion is important, and moves you above and beyond the pack.

3. Aesthetic
All three are an expression of a particular aesthetic.
Aesthetic in software is under-rated. Marketing shouldn’t be the driving force behind software choices.
And taking a journey through choosing what you find beautiful in code. After you pick it, you need to…

4. Evolve
The first versions of Back-in-black, the Rite of Spring and Basecamp (rails) are different then the versions we have today.
Change IS going to happen, optimize to have it.

5. Create!
Rails lets us create. Be intuitive, be creative. Software is a craft.

This was an awesome panel. Very funny. Very enlightening.

Dave Thomas’ RailsConf Keynote (the first day)

Dave Thomas is a VERY smart man. His keynote, after a big rah-rah startup, was a breakdown of the three big problems facing Rails adoption into the “real-world”.
* Data Integration
Things like foreign-key support, reading more into the schema and breaking-out Active Record into two parts (one not reliant on a DB)

* Real-world CRUD
Making the scaffold 2.0ish. Doing more towards making the scaffold “smart”

* Deployment
Lots and lots of great capistrano ideas.

Then he went into “Why” we should care about these things.
Once you use Ruby and Rails, you are spoiled, and don’t want to go back to Java / enterprise development.

The “Why”:
“All developers deserve to be happy.” – That’s the “why” he ended with. Great great keynote!

First day at RailsConf

“RailsConf”:http://www.railsconf.com/ doesn’t start until friday, but don’t tell everyone here that. There was a ton of laptops out with people showing each other stuff. I have to say that the general vibe here is *amazing*. Tons of cool people, everyone drinking the same Kool-Aid and lots of ENERGY!

I’ve already learned a lot of cool stuff. One thing is
require ‘active_support’
This gives you access to all kinds of neat Rails stuff from within ruby – without loading up script/console.

I’ve also meet a TON of cool people already. One guy’s whole job is to make proof of concept sites for his company while pitching to clients. What does he do with the apps when he’s done? Throw them out! Wow.

I’m enjoying the hotel room, my only beef is with the WiFi – it was OF COURSE over-extended.

More from the Conf tomorrow.