Nathan's Lucubrations

16 05 2012

Wed, 16 May 2012

Please . . .

Lately, there's been a spate of writings in response to a controversial one entitled "Please Don't Learn to Code". People have been exhorted to "Please Learn to Code", "Please Don't Become Anything, Especially Not A Programmer", etc, etc. While I'd be loathe to tell anyone what to do (anarchists never ruling and all that), I would like to offer some friendly advice to those willing to take it: learn.

Learn something, anything, just don't sit still. Those who don't learn history are doomed to repeat it, and if you're learning something, it's probably already history (of which I'll get more into in a bit).

In particular on programming: it couldn't hurt to know how to slap together a bit of code to quickly solve a problem. That's how a lot of great programmers got started. I'd also like to think that the original article is not discouraging people for fear of competition; he actually makes it quite clear that what he would like to discourage is more bad code coming into existence, and he thinks that by discouraging non-programmers from learning to code that this will help. That's where I think he goes wrong.

If anything, the people who should either learn how to code properly or not even bother are the ones who are already writing software. You think I'm joking? I've seen enough bad code to realize where Atwood is coming from. I'd rather that when someone wants a problem solved, they don't dredge up something entirely inappropriate and unmaintainable, but actually ask to have something designed properly from the get go. If someone has tried to learn how to write good software, but can't (or worse, won't), then they should stop giving their code to others. Please note that I didn't say they should stop coding, just that they shouldn't let their little monstrosities into the world.

And here's where we have the dichotomy. Should people, in general, have a better understanding of computers and how they work, even being able to program them, so that they can solve problems on their own? Most definitely yes. Programming is an incredibly liberating and empowering experience. You can create whole worlds, universes even, while programming. I can't recommend it strongly enough to everyone.

Now comes the other side of the coin: good software is hard to get right. It takes practice, perseverence, study and discipline. Should people release their dirty little one-off hacks, just to try to be helpful? I appreciate the sentiment, but that kind of thinking got us PHP. Programming is fun, and can be extremely useful in solving problems. But not all code is created equal.

Code to be released to others has to have some sort of value. If it only solves your problem, who cares besides you? It might be able to be worked into something more flexible, more reusable, possibly even something bug free. But is it really worth the effort? Especially when designing something properly from the start would get you the same results with less overall effort?

Again, I don't want to discourage anyone from learning, and here's where history comes in. You need to read. Sure, you may have written a script to automate some dreary task, and now you want to do more. Great! Pick up the classics. Read "Mythical Man-Month" and learn not just why planning is important, but why throwing more monkeys at the code won't help, and maybe most importantly, learn what we've lost. You do know that it used to be standard practice to have a fully working emulator for hardware before the hardware existed so that the systems programmers could work in parallell with the hardware guys, right? Or did you know that the mouse and teleconferencing have been around longer than most people think? Those nifty features in your current favorite programming language? Already in LISP fifty years ago.

The computing industry is full of history lessons that have been forgotten. It's also full of untold wonder. My advice is to learn, whether you are a new or old programmer. Learn to write good code; be a net positive and create gloriously beautiful works of art that solve incredibly hard engineering problems. When someone says it can't be done, ignore them. When someone says you shouldn't learn something, learn that thing.

And look at code, good code. How do you know good code? It's been around a while and people are still working on it. This might seem counterintuitive, but if it's so bad that it's unmaintainable, people will start over from scratch with something else. Granted, this is a pretty low bar, but if you look around at things like the Linux kernel you can learn all sorts of things. Don't be afraid to go on sites like GitHub and just start clicking on things. Find your favorite piece of software and download the source code, see if you can get it to compile.

Sure, you may not write practical code right away. You may be (rightfully!) shouted down for the first crummy patch you submit to an open source project. Just take your licks, learn from the experience, and improve your code. These things don't come overnight. And don't be ashamed if you can't learn how to code. Some studies suggest that a large percentage of the population can't learn to program. At that point you might want to move on to something else, so as not to slow down others by creating code they will have to fix. It's also okay if you don't like programming; there are enough of us who do. You don't have to be an expert at everything. You can't either.

I guess ultimately my practical advice would be to pick up Python and go through one of the many tutorials or books online. Why Python? It runs everywhere and is fairly easy to start with, but has enough power and extensions to make it applicable to just about anything. Plus it's not PHP or VisualBasic.

One last thing: that whole thing about Python having tons of extensions was a subtle hint. Don't reinvent the wheel. Sure, it's good practice to write code, maybe perform some katas, but don't create a piece of software that already exists unless you can do it better. Keep an eye out for libraries, extensions, toolkits and frameworks that will make your programming sessions that much more powerful.

posted at: 03:22 | path: | permanent link to this entry

powered by blosxom