Learning to Program

by Alan Gauld

Stop Press!

The Web Site

This is the original version of my web tutor featuring Python, Tcl and QBASIC as learning languages. It is only maintained as an historical document, no new fixes will be introduced. The official tutor now features Python, VBScript and JavaScript as languages and has greatly enhanced explanations, examples and material. Thanks to all the original readers for their valuable feedback, I hope you find the new version even better than this one.

The Book

Latest news on my book is that it has moved to print-on-demand. Basically this means that copies are only printed when firm orders are received from retailers. Logically this means you are less likely to see it in the shops but you can still place an order and it will be delivered, it just takes a little longer is all.

The book significantly improves on the the explanations in the web version, albeit only in Python. It also has extra examples and several completely new chapters compared to the web site. These include a brand new case study for an OO games framework. (A fully commented version of the framework is available on the Useless Python website as hmgui.zip.)

You can order the book on Amazon by clicking here. Most of the other online bookshops have it in stock too.

There is also a Japanese version available from the Japanese branch of my publishers.

I now have a web site set up listing errata and providing opportunities to send feedback and questions. Please pay a visit, especially if you've bought the book!

The Future

As I said above the Web vesion is currently undergoing a major revamp. If enough folks buy the book I hope to do a second edition to bring the two back in line including the version updates and new material.

Non English Editions now available!

Martin Pozzi was the first to translate the tutor (into Spanish) and he has now been followed by several others. The following versions are available:

Czech Petr Přikryl
German Bruno Schaefer
Korean johnsonj
Italian Luca Fini
Portuguese Wilson Edgar
Spanish Martin Pozzi

The tutors above are nearly complete. The original Czech one was translated by Soňa Reisnerová and had a different style to the others but only worked in Internet Explorer. The website which hosted it is currently unavailable so I have removed it and the links above now point to a more recent Czech version, which should display better on non IE browsers. I was so impressed with the style that I have used Petr's stylesheets in the new English version.

Hopefully I'll get round to changing the other language editions too. Petr is also updating his translation to keep in step with my updates so when the new version goes live there should be a Czech version very soon after. This has the huge advantage that Petr is effectively doing a very thorough review of the new version too, which should mean the quality is pretty good! A big vote of thanks to Petr.

Note that for the most part the translations are frozen at the time the translation was done. This means that the English version is diverging further and further from the translations. Nonetheless I think all of the translators deserve a vote of thanks for their efforts in putting this together. Its always better to read a translation of an old tutorial than to struggle reading a new one in a foreign language! If anyone else wishes to do a translation, or update any of the existing ones, just send me an email.

As mentioned above there is a Japanese version of my book available too.

New Stuff

As already mentioned the site will slowly migrate to a new updated version over the next few months. I'll do updates on a section by section basis to minimise inconsistencies, so the next visible changes will be the Concepts and Basics topics all being updated, then the advanced and finally the Case Study etc.

Download Archive Format Change

There are still problems with the archives. The files seem to get corrupted from time to time and different users have problems regardess of which format I use. The only solution seems to be to post both zip and tgz formats. Hopefully this will keep everyone happy! While the upgrade is going on I will not be posting updated zip or gzip files even when I fix typos etc. Bear with me on this one...

Linux users can download the tar/gzip version.

Windows users should be able to use that version too since winzip and the freeware archiver Quick Zip by Joseph Leung can both cope with tgz format. I'll also be using tgz format for the non English versions, just look at the bottom of the contents frame for a link.

The zip version can now also be obtained, just in case...
You'll find it here and linked to the contents frame.

This way everyone is happy - I hope!

And Palm Users Too...

One Palm user has created a Palm doc file. I haven't had a chance to try it yet but offer it here for those who want it. If anyone has problems with this one then you're on your own, it's unsupported. But hopefully it will be useful to someone.

Introduction - What, Why, Who etc.

Why am I writing this?

The reason I am creating this tutorial is that there seems to be very little for the absolute beginner to programming on the Web. Yet the Internet and the Web encourage interest in computers and that interest naturally leads to a desire to "take control", which means learning to program!

Why me? Well I am a professional programmer who came to programming from an electronic engineering background. I have used (and continue to use) several computer languages and don't have any personal interest in promoting any particular tool or language. Oh, and when I started, nobody else seemed to be doing it! Since then several other tutors for beginners have appeared, but this one seems to have acquired enough of a fan base that I'll keep it going.

What will I cover

As much as I can. I will cover the basic theory of computer programming - what it is, some of its history and the basic techniques needed to solve problems. I will not be teaching esoteric techniques or the details of any particular programming language, in fact I'll be using several different languages, since I believe its important to realize that different languages do different things well. That said, the majority of the course will be in the language called Python.

Who should read it?

Put another way: what do I expect the reader to know already?

I expect the reader of this tutorial to be an experienced user of a computer system, probably MS DOS, Windows or Unix although others should be able to cope too. I also expect them to understand some very basic mathematical concepts such as geometric coordinates, sets, and basic algebra. These are all important in todays programming environments, and many programming concepts are based on these ideas. However the depth of knowledge needed is very low and if you do find the math getting too hard, you can usually just skip over a few paragraphs, try the code as it is and hopefully the penny will drop even if the math still confuses you.

One thing you should know is how to run commands from your operating system's command prompt. In Windows this is variously known as a DOS box, the MS DOS Window or MS-DOS Prompt. Basically it's a black window with a white text prompt that usually says C:\WINDOWS> and you can start it by going to the Start->Run dialog and typing COMMAND into the entry box and hitting OK. If you use Linux then you should know all about terminal windows and on MacOS you can run the Terminal program under Mac OS X (which is found in the Applications->Utilities folder).

I will not be covering issues like how to create or copy text files, how to install software, or the organization of files on a computer storage system. Frankly if you need to know those things you probably are not at the stage of being able to program, regardless of your desire to do so. Find a tutorial for your computer first, then when you're confident with the above concepts revisit this site.

Why Python?

Python happens to be a nice language to learn. Its syntax is simple and it has some very powerful features built into the language. It supports lots of programming styles from the very simple through to state of the art Object Oriented techniques. It runs on lots of platforms - Unix/Linux, MS Windows, Macintosh etc. It also has a very friendly and helpful user community. All of these are important features for a beginner's language.

Python however is not just a beginner's language. As your experience grows you can keep on using Python either as an end in itself or as a rapid prototyping language. There are a few things that Python is not well suited to, but these are comparatively few and far between.

I will also use VBScript and Javascript as alternatives. The reason for this is to show that the same basic techniques apply regardless of the language details. Once you can program in one language you can easily pick up a new one in a few days. Why those languages? Well, for a start they have very different styles to Python so form a yusefull contrast, and more prosaically if we accept that most Web surfers who are also beginners are using PCs with Microsoft Windows installed, there is a programming environment built in to the operating system called Windows Scripting Host which has support for VBScript and JScript (which is Microsoft's variant of Javascript). In addition anyone using Microsoft's web browser can also use these languages within their browser, and in fact Javascript should work in almost any browser. We'll only look at how to run VBScript and Javascript inside a browser, investigating WSH I'll leave as an excercise for the interested Windows user!

Other resources

There are other Web sites trying to do this in other languages (and in the time since I originally created this site a few other Python sites have appeared). There are also lots of tutorials for those who already know how to program but want to learn a new language. This section contains links to some of those that I think are worthwhile!

Next  Contents

If you have any ideas on how to improve this tutorial
please feel free to contact me