litany against fear
RailsConf 2009 Robert Martin Keynote
This is part of my series of notes on RailsConf 2009. Check them all out here.
What killed Smalltalk and could it kill Ruby?
Is Smalltalk dead yet? It was the language that only a few dabbled with in the 70s and also quite a few huge projects written. Why did Smalltalk just keel over? Squeak has become an academic language mostly, no one is doing anything serious in it.
Smalltalk really was the pinnacle of what object-oriented design was all about. There were some good languages around though…C++ is man’s language, Java is more of an estrogen language. Objective-C was really influenced from Smalltalk though. Smalltalk had a huge advantage over C/C++ in productivity. Smalltalk also had a lot of powerful IDE tools, especially for refactoring. But, it still died. It was mostly…non-hormonal. It makes stuff happen.
Ward Cunningham is pretty much a badass. He’s come up with or kickstarted tons of great ideas: design patterns, FIT, the wiki, the list goes on and on and on. According to Ward: clean code is when you look at a routine, and it’s pretty much what you expected. Clean code has a metric of zero WTFs/minute.
According to Ward: what killed Smalltalk was that it was just too easy to make a mess. This didn’t happen in C++ because it punished you for creating a mess. Smalltalk didn’t complain much about this, and messes could pile up fast and without consequence.
Ruby has this same problem. Happens with many projects: it’s just a tangled mess eventually and you have to dive into the framework to see what’s going on. Apply the Boy Scout Rule to code: random acts of kindness for every checkout. This doesn’t happen though…cleaning code is risky. The messes are easy to make, but hard to clean…it becomes your mess if you break it!
There’s a way out of this: TDD! Ruby has this built in, but he’s afraid that the discipline won’t grow with the community. The rules of TDD:
- Don’t write a line of code without writing a failing unit test
- Not allowed to write more of a unit test when they’re failing. (Make it green!)
- No writing of production code without writing another failing test.
The cycle might seem pointless to those outside…but it really prevents the horrible timesink that is debugging. Having a test suite really helps with refactoring. Tests eliminate fear! A suite of tests removes fear when trying to change things.
TDD never became part of the culture in Smalltalk…it has become part of the Ruby culture, but is it enough? Without tests, you are not in control of your codebase. There was a certain air of arrogance in the Smalltalk community that seemed to keep people away from it. They felt their tools and languages were just better, and they ended up building a wall around themselves.
Dynamic languages won the language wars, even the static languages have adopted some dynamic principles. There was a certain lack of professionalism that the community just lacked. Smalltalk died since it just refused to address the general problems of the enterprise: parochialism.
What might save Ruby and Rails, etc from this demise? It’s not headed in this direction yet. The following must happen to prevent the downfall:
- Discipline. TDD. It’s HARD.
- Humility. There are good laughs to be had, but don’t build the wall (or force them to!)
- Solving the dirty problems. Bad database schemas, for example. Someone’s got to deal with it.
Don’t ignore the enterprise.