A cousin of mine asked me for a good programming tutorial. Since I haven't learned to program in a number of years (a good decade and a half, actually) I did a bit of googling and thinking and came up with a couple of good resources. This page is here to link to them and provide a little advice.
Please note that the purpose of this page is not to teach, it is to show you where to look if you want to learn. Feel free to contact me if you have suggestions for stuff not on here. If you want any clarification about the stuff here I'll be happy to help, time permitting.
Why would anyone want to learn programming? Well, apart from the fact that picking up any kind of useful skill is a good idea, learning to tell a computer what to do and how to do it means learning a lot of problem-solving, logical ways of thinking about things, and clarity of expressing what you're trying to say. These are all worth knowing in the real world, even if you never write anything more complex than "hello world".
More directly, being able to hack up a quick program to automate some tedious task (be it adding all the marks in a set of tests, calculating how much interest you'll pay on the car you're about to buy, automatically generating Philosophy essays, etc.) can save a lot of time and, even if it doesn't, can turn a tedious job into something more interesting and creative. I originally taught myself to program so that I could make the TV do stuff, but I was about 8 years old at the time so that kind of reason was enough. Perhaps it's enough for you as well.
Which programming language should you use? Well, that depends on a number of things, including the type of problem you're trying to solve, the computing resources at your disposal, your own personal tastes and the marketing departments of the various compiler vendors. More to the point, which programming language should you start with? I have two theories on the matter (but they're just mine and there's no reason why they're better than anyone else's) which I shall refer to as bottom up and top down. I myself started somewhere in the middle and eventually branched out in both directions, but that was due due mainly to what I had access to. You're much luckier in the amount of choice available. Just stay away from Visual Basic whatever you do.
The bottom up method, as the name suggests, involves starting from the most basic elements and building up. It's the more difficult of the two methods but, in my opinion, leaves you with a far more complete understanding of what is actually happening. It also has the advantage that it (sort of) follows the way programming actually evolved. There aren't any links here, because I haven't had time to look yet but if there's enough interest in learning using this method, give me a shout and I'll see what I can dig up.
- Look at boolean algebra (basic logic, the building blocks of every computer) and basic digital electronics. Make sure you understand how logic circuits work.
- Get hold of the reference materials for a relatively simple microcontroller. I'm rather partial to the Atmel AVR series, but PICs and 8051s are also good. If you can work with actual hardware, even better, but at least try a simulator of some sort. Learn the assembly language for whichever device you choose and try write something non-trivial. The canonical example is a lift controller, which has about the level of complexity you'll need to learn without adding too much overhead.
- Once you have mastered assembly (preferably more than one, so you can compare how different micros do things differently) find a good book on C. Not C++, Java, or whatever, just plain C. Again, write something non-trivial in it. I don't think there is a canonical non-trivial example in C, but I'm sure you'll think of something.
- If you have followed the preceeding steps, you should now be able to write solutions to small problems. Now some programming theory would be a good idea. If you're not scared of technical stuff (which you aren't if you've made it this far) you should get hold of The Art of Computer Programming by Donald Knuth. It's well worth the effort of reading. The Mythical Man-Month by Frederick Brooks Jr. and The Cathedral and the Bazaar by Eric Raymond are also good, although they discuss the philosophy of programming rather than the practise.
- With a little theory under your belt, now is a good time to learn another language. A high-level language like Perl or Python would probably be best, or perhaps PHP if you want to do web stuff. A dialect of Lisp is probably also a good idea, especially if you want to bend your mind in new and interesting ways. A programmer with only one language at his disposal is like a builder with only one tool. You need both a hammer and a screwdriver to do most things worth doing.
Using top down method is easier than the bottom up, but people who have learned this way often make mistakes due to not understanding how the machine works. That said, there's nothing stopping you working all the way down, although it's more painful to learn assembly language when you already have the power of a language like C at your disposal.
The documentation I'm linking to uses Python as a teaching language. I chose this because Python is wonderfully scalable. Unlike Java or Pascal, you don't need all sorts of boilerplate code around a simple "hello world" program. Unlike most forms of BASIC, Python is entirely self-consistent and well designed. It scales easily from a one-line script that does something trivial (or non-trivial, possibly) to large distributed applications.
To start with, you'll need to install Python. If you're using a Linux system, chances are it's already installed. If it isn't, or if you're using a Windows system, you'll have to download and install it. http://www.python.org has a download section and also a collection of excellent documentation which is well worth perusing.
Probably the best resource for learning to program using Python that I have found is How to Think Like a Computer Scientist by Allen B. Downey, Jeffrey Elkner and Chris Meyers. If you don't want to read it online, you can download it as a pdf, in any of a number of other formats, or purchase a print copy. The book is also available in a number of other programming languages, but I recommend Python, mostly because the language is free and open and a pleasure to use.
Once you're comfortable in Python, I recommend learning at least one other language, preferably C. There are a number of good C tutorials and books out there, and I'll link to one when I get around to it.
Beyond the basics
You aren't going to become a good programmer overnight. Like most things, becoming good at programming requires practice. Lots of practice. Peter Norvig, Google's Director of Search Quality, has written a particularly good essay on this topic.
Although this page is far from complete, I hope it's useful. One day when I have time I'll improve it and add more links. Until then, "Google Is Your Friend".