How do I make Ruby safer? It’s a topic that people bring up on the mailing list every once in a while. People shouldn’t be able to open my classes. They need compile time type checking so the app doesn’t blow up. Extending system libraries is bad.
Concerns like these all seem to boil down to one major theme: The people I work with are stupid.
Seriously, browse through ruby-lang for threads where the starter needs Ruby to be more “safe.” A ruby hacker will cheekily ask, “Why do you need static type checking? Are you going to try to regexp match an Animal?” “Well, no, not ME of course, but somebody else might.” I don’t even know who “somebody else” is most of the time. Is it someone on your team? Is it someone from another department? Is it some random guy who downloaded your library?
I simply do not care about random people. I’ve shared plenty of code before, and will continue to do so. I’m not about to waste any energy protecting people from their own stupidity. Hell, I’m coding Ruby on a daily basis, clearly I have no interest in appealing to the common denominator.
That may sound like I don’t respect the average person, but in fact the opposite is true. I have faith that you’re smart enough to understand things on your own, to learn things on your own, to ask questions when you need help. I don’t assume that you’re a bumbling idiot who should use a compiler only under strict supervision, or at the very least wearing a helmet.
The more serious issue is when “someone else” refers to someone whose welfare you actually are interested in, or, god forbid, responsible for. If you need to protect someone on your team from code, there are two scenarios in play:
- The person is stupid
- The person is naive
Neither issue is really that difficult to handle. The first one has a very simple solution â fire them. You heard me. If you’ve determined that this person truly has no chance of learning how to judiciously use some piece of code, there’s zero chance they’ll had value to your project. Programming is a vigorous intellectual exercise, and I’ve never seen incompetence actually benefit such endeavors.
Fortunately for us, and for those less enlightened/experienced, very few people are truly hopeless. I’ve met a lot of programmers who were misguided, many of whom were also hardheaded (I’m certainly in that category), but not many who couldn’t learn a better way. In this case, the solution is pretty simple as well. You take the time to educate them. Clearly you know the right way to do something, otherwise you wouldn’t feel a need to protect them from themselves. Instead of spending all your energy limiting what people can do, direct your energy towards helping them empower themselves.
Ruby doesn’t need to be more safe. It certainly doesn’t need static type checking. What we need is to kick the idiots out, and educate those with less understanding. Doing so improves those individuals, ourselves, and our craft as a whole. It doesn’t take much more effort than trying to keep people from shooting themselves in the foot and performing damage control when they find workarounds. The benefits are obviously way better. So what’s stopping you?
note: Anyone reading this blog probably agrees with me on some level. So it may be pointless to write this. Maybe you can link to it on theserverside.com. I’ll take the heat.