Next page | Contents page |

Start here

Part 1 - Jumping straight in

The sub-text

Many programmers in the UK got started around 1980 in a wave of enthusiasm inspired by the availability of novel machines such as the Sinclair ZX's and the BBC Micro. Today such computing as is taught in schools seems mainly to comprise the use of standard applications such as word processors and spreadsheets. This is sad because a great potential creative resource is going undeveloped. Instead we are increasingly sub-contracting programming to other countries. We are losing the skills in this country.

We want to demonstrate that every computer user has a powerful programmable machine in their hands and that it is not hard to use it. Can we not reignite the programming spark?

Sorry, not in this browser

← ( A bit of JavaScript program )

Programming is not necessarily mathematical but it does often give opportunities to apply simple mathematical thinking and therefore should help school pupils to see the usefulness of maths.

So you would like to learn how to program.

Those three things are all you need for this course. You don't have to go and buy any compiler or IDE (Interactive Development Environment), such as you may have heard people talking about. They are just trying to make it sound more daunting. Really it isn't!

All browsers understand a programming language called JavaScript. So by using a browser you do have the capability of running programs written in that language. All you need to find out is how to write a simple program in such a way that the browser can see it and run it.

That's what these pages are about: getting started with JavaScript using completely free tools that anyone with any kind of computer will have.

In earlier times the best programming language to start with would have been BASIC because all personal computers were based on it. Today JavaScript is the language available to everyone.

JavaScript programs will run in any browser and so by programming in this language you are not limiting your audience to one type of computer. Furthermore distribution is easy: just publish a web page. Your program will then run even on smart phones.

JavaScript is not only used in browsers. For example you can use it to automate your photographic workflow in Adobe PhotoShop (using the Adobe ExtendScript Toolkit). It is also the basis of ActionScript, for programming Flash. And there are many other uses.


One factor that has limited the appeal of JavaScript in HTML as a language for starting programming is that until recently it had no facilities for drawing graphics. It could be used for loading images and animating a sequence of images but not for creating an image by drawing lines and shapes. That is now changing as a result of the HTML5 initiative, so that browsers now recognise the HTML tag, <canvas>. JavaScript can now be used for drawing on such a canvas. Here is an example:

Sorry, this browser does not recognise HTML5 <canvas> elements.

The earliest versions of browsers that can use <canvas> are:

Android 1.0, Chrome 3.0, Firefox 3.0, Internet Explorer 9.0, iPhone 1.0, Konqueror 4, Opera 10.0, Safari 3.0


A much more interactive example, a drawing application written entirely in HTML5/JavaScript can be seen here.

And here is a more serious example:

A camera field of view calculator

(eg, converter or extender lens)


By the way

There is another programming language called Java. It is just a historical accident that JavaScript and Java share four letters in their name. It is quite unfortunate because it makes people think the two are related. They are not. Some statements written in either language look similar but they are fundamentally different languages.

You may be able to catch your teacher or project manager out by asking them what the difference is between Java and JavaScript. You see programming can be fun even before you write a line!

Seriously though, how can project managers deploy the right resources if they don't realise that a real expert in Java may know nothing at all about JavaScript, or vice versa?

Bad naming can have unfortunate consequences, and that is something that programmers should bear in mind when thinking of names for things in their programs.

This introduction includes many hands-on exercises to give real programming experience. Do make time to do the exercises rather than merely reading through this text. Practice is the only way to make it stick.


If you extend the examples and publish your own programs derived from them, please do the decent thing and mention the originator of this course:

In this first section you will work with some complete examples. Feel free to try to extend them to do other things. That can be a useful way of learning. You will make mistakes but also discover ways out of them. However, if you want to go on and do serious programming of your own you should then work through the second part of this course, to learn how it really works, in a logical way.

Model answers for almost all of the exercises can be downloaded as a zip file from here (save the target of that link as file and then unzip it). It is not possible to learn to program in any language without doing such exercises to find out what really happens, so please do not be tempted merely read the answers. Use them to compare against your own efforts after you have got something working.

Next page | Contents page |