Sharp Knives and Safe Handles
These knives all have handles
The first time I was in a programming debate that used the argument “I want a sharp knife”, my friend was arguing that real programmers wrote C and accessed memory directly. I was arguing for Java as the easier, if less flexible, solution.
One generation’s sharp knife is the next generation’s whirling machete blade.
The phrase “sharp knife” has been bouncing through the Rails community the last day or so. I don’t really want to talk about the latest Rails drama. That’s a lie — I’m dying to talk about the latest Rails drama, I just don’t think the world needs another 3000 word rant about how all the other 3000 word rants are wrong. This will only be a 700 word rant, and might allow for the possibility that some of the other rants are partially not-wrong.
I want to talk about sharp knives and safe handles. The best sharp knife tools are paired with handles that let you use them safely. Warning: this is not going to be a perfect analogy because in the real world you don’t use the handle without the blade unless you really can’t find a hammer…
Allow me to define my made-up terms.
A “sharp knife” is a tool that gives a developer flexibility that, in the wrong hands, can cause a lot of trouble. Pointer arithmetic in C or monkey patching in Ruby are both good examples. In my head, calling something a sharp knife is a little different than just saying that a tool is opinionated. RSpec is very opinionated, and very flexible, but there’s a limit to how much damage you can cause even if you use it badly.
A “safe handle“ is a tool that handles complexity for a developer in the name of allowing the developer to focus their attention on doing more than they’d otherwise be able to do. Garbage collection in Java, for example. Or ActiveRecord. I’d argue that some of RSpec’s DSL is targeted at this, too.
When somebody attacks a sharp knife, the argument generally boils down to “in the wrong hands, it could wreak havoc”. Fun fact: one of the first things I ever heard at a public Ruby event in 2008 was Dave Thomas saying that misusing monkey patching wasn’t a technical problem, it’s a people problem. So it’s not a new issue.
When somebody attacks a safe handle, the argument usually boils down to “you can’t build anything real without knowing the thing”. As in, “you can’t build a real app without knowing SQL.”
The arguments against knives and handles both boil down to a kind of sneering “I know the right way of doing things and you don’t”. That’s not a productive way of driving a debate. It’s similar to George Carlin’s quote that “anybody driving slower than you is an idiot, and anyone going faster than you is a maniac” — anybody using a tool more powerful than I like is going to cause chaos, and anybody using one more abstract than I like can’t build anything real.
Instead, we can talk about whether somethign is a useful sharp knife or a valuable handle. Just saying “my feature is a sharp knife” doesn’t automatically mean the benefit is worth the cost.
A good sharp knife:
- Offers real benefit in terms of power and flexibility when used well.
- Can safely be put in a drawer and ignored when not being used or is paired with a safe handle.
Jamie Lawrence made a useful distinction:
A good safe handle:
- Provides a useful abstraction for not thinking about implementation details or avoiding dangerous syntax
- Understands that the abstraction is not perfect and allows the developer to work around it when needed
SQL and ActiveRecord are great example of a knife and handle combination. SQL is very powerful, but dangerous, in an “oops, I just deleted that entire table” kind of way. ActiveRecord provides a useful abstraction, but also makes it easy to get at the underlying SQL. (Granting that ActiveRecord is still really complicated, and some of its features are its own sharp knives)
I’m glad that all these great sharp tools exist in our world. I use them. I mostly don’t cut my fingers. That said, as a community, I think we overvalue the knives and undervalue the handles. (I realize that we’re kind of back into I like pretty lies territory here). Rails doesn’t make it easier to build websites because it provides more and better ways to get myself in trouble, but because it provides a lot of ways for me to stay out of trouble that I don’t need to be in.
By all means, build the sharp knives for the times when we need their flexibility and precision. But lets also build the handles for when we just want to cook without hurting our hands.