Learning to program: A brief introduction
SEE THIS EXCELLENT W/U: Learn to Program
Learning to program can be daunting
, and many people give up early because they have difficulties getting themselves set up, or difficulties finding help
once they are set up.
For a complete newbie, it's hard to know where to start. If you don't know your compilers from your linkers from your C++s, you're in trouble. Hopefully this guide will help clear up some confusion and stop the potential Codeheads of tomorrow bailing out too early.
What makes a good programmer?
- Someone with a creative mind makes a good programmer. Don't get the idea that programming is all about cold logic and math - it's about ideas, and it's about fun.
- Someone who enjoys exploration and discovery makes a good programmer. There's so much to learn about the topic, and if you're interested in computers, then there's likely to be much more interesting stuff to learn than anyone could ever manage.
- Someone who likes fiddling with their computer makes a good programmer. Programming is the ultimate tool for doing things with your computer.
Your choice of language
Computer programs are written in a "language". A language is neither English nor is it binary; it's something that's inbetween to allow you to give your computer instructions in a way you can both understand (with a little practice).
If you speak to any professional programmer, they'll tell you any incarnation of BASIC sucks. They're right, in a sense - they suck for experienced programmers. You're not an experienced programmer, and BASIC is actually an ok place to start.
Many fundamental programming concepts can be explored with QBASIC, without having to deal with the complexity of a language like C. If you don't know what a subroutine, array or data type is, then download a copy of QBASIC and find some tutorials.
Although QBASIC is fine for the newbie, please don't think that it's all there is to programming. The delicious complexity and power of a language like C or Perl is what programming is really about, and you should be looking to move onto the fun stuff as soon as you can. That's not to say you shouldn't linger on QBASIC for a while, but once you find yourself getting bored with it, it's time to move on.
The reason I've grouped these two together is because one is a superset of the other - C++ does everything C does (this isn't 100% strictly true, but you don't need to worry about that), and a whole lot more. When you're ready to start having some real fun with programming, and have a fair amount of time to devote to it, it's probably time to take a look at this pair.
So, which of the two should you go for? This actually depends more on the quality of the explanatory material you can get your hands on than anything else. Try to find a C++ book at your local library (My personal recommendation is Practical C++). When looking for a book on C++, make sure you find one that says something like "No previous programming experience required". A lot of C++ books are designed for Codeheads that are seasoned C veterans - and you're not.
If you can find a book on C++ that speaks to you well, then go for it - especially if it comes with a CD that has a compiler on it. Otherwise, look for a newbie-level book on C - these are guaranteed to not expect you to have any previous experience. You can move onto the complexities of C++ and Object-oriented programming later.
Java is considered by many experienced programmers to be what C++ should be, and is seen as much cleaner and friendly, especially in the manipulation of strings of text. One of the main features of C/C++ are pointers, which the Java language does not use. This can be a big relief to many newbies, as pointers are a very delicate and complex subject, even for experienced programmers!
Another of the good things about Java is the relative simplicity with which you can set up a web-based GUI for your programs. Web applications can be very satisfying for the newbie to work with, and Java allows you to create them relatively simply.
Perl is not a newbie-friendly language in some respects, and it is in others. The advantages of Perl is that it isn't as syntactically rigorous as other languages - it's not as pedantic, and mistakes are harder to make. There are some Perl idioms that will seem natural to the newbie programmer; but Perl is also capable of being one of the most confusing languages on Earth. And guess what way most explanatory texts like to be.
QuakeC is a language that was used in id software's game Quake to control many things such as the monster AI and object placement in the game. id software have released compilers and their QuakeC code, which allows people to write MODs (more on this below) for Quake, such as Capture the Flag. QuakeC is syntactically similar to the C language, and may be a good place to start for a gamer who wishes to learn to program.
IF, or Interactive Fiction is often actually a fantastic way to begin programming. Languages such as Inform and TADS teach you basic concepts and let you produce an output at a fair speed, giving you a lot of satisfaction. If you enjoy writing stories or adventures, then you can combine your creative flair and wish to program. You'll learn the basics of programming and writing good code, and exercise your artistic talents.
MUDs are another good place to learn to program. There are plenty of MUDs on the internet that want new programmers, and many have excellent resources for teaching you languages. LPC is a C-like language used on many MUDs, including the very popular Discworld MUD. If you want to combine your programming, artistic talent and find a great new hobby, MUD programming might just be for you.
Getting and editing the code of other programs
Many programs - especially thanks to the open source movement - now come complete with the computer code that drives them. Others, particulary games like Half-Life and Quake II, allow you to expand them through the programming of MODs (modifications to the game). This sort of programming can be very satisfying for the newbie, as he can fiddle with the code and see the changes he has made take effect in the game instantly.
Another advantage of this is that the game's code is a working system - and will often be well commented (comments are English statements written in the code that explain what the program is doing). By studying this system, one can learn a lot about how to program well (presuming the program is written well!), and then play about with it and add to it.
Games of note for which source code is available are Quake, Marathon 2, Angband and Nethack. The game with the most active MOD community - and many sites dedicated to helping people make MODs for it - is Half-Life.
One of the crucial aspects of learning to program is being able to ask for help when you need it. It's hard to learn in an isolated environment, and smart friends can boost your ability and confidence by transferring their knowledge.
Luckily for you, the Internet is full of smart people that want to give you knowledge - that's what the place is built around. There are hundreds of FAQs, Newsgroups, bulliten boards and sites covering all aspects of programming in all languages. If you have a problem, remember that someone else has probably had the same problem before, which means someone somewhere knows how to solve it. Don't be afraid to ask.
I don't have any cash! Can I still learn?
The internet has been a great equaliser in the provision of information, and as I mentioned above all the tutorial information you need is on the web. Although it's hard to beat a good solid book, online resources and smart friends are almost as good.
One of the most common problems newbies have is not knowing what applications they need to get programming. Of the languages I mentioned above, it is possible to download a version of them all somewhere online. Not all of these free compilers are newbie-friendly, especially in the case of C++. It is much better to buy a proper IDE such as Virtual C++, or Metroworks Codewarrior.
I feel the Metroworks Programming Starter Kit is worth a mention - for £50, this package gives you a range of compilers for different languages, an excellent collection of reference and explanatory material, and a great IDE. While I am loathe to include non-noded for the ages information, I feel not mentioning this package in any text purporting to tell the reader how to learn to program would be a crime. Go look at this package - it's how I learnt.
Programming resources on everything
As an endnote, I'm including a list of resources on everything that may help you in your quest for programming prowess. Although the concepts section is somewhat random, it might be interesting for a newbie to click on the various links and find out a bit more about the different nuances of programming.
Binary | Octal | Hex | Memory | Linked lists | Binary tree | Array | for loop | foreach | ADT | Stack | abstract data type | Object-Oriented Programming | Polymorphism | Abstract base class | Structured programming | flow control | conditional branching | recursion | pointer | reference | iteration | iterator | associative array | event-driven object-orientation