In this first section of the course we will present some fairly simple examples for you to try. The primary concern is for you to get something working without necessarily understanding every detail of how it works.
If, in this section, you find yourself asking questions like "How on earth could anyone know that you could write that?", just don't worry about it for now. We want you to experience the satisfaction of getting the examples to work.
We could have started in a much more logical but dry way from the very basics of the language and built up step by step. However, that could have meant reading dozens of pages before you saw any results in action. We might easily have lost you along the way. So instead we will start that more thorough process in a subsequent section.
In the next few pages we will look at the examples shown here and how to program them.
First we will see how to display the current date and time, from your computer's internal clock:
The second example will animate that, so it runs like a very wordy and rather inelegant clock:
Those two examples showed how to output text from a program for the user to see. Next we look at getting input from the user. First a very simple example (try it now, on this page):
Then something slightly more complicated: getting numbers rather than just any text from the user, to do some simple arithmetic. It's like a calculator:
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
Note that versions of Internet Explorer earlier than 9 required a plug-in to make it work and it was not to HTML5 standard as we are using here.
We will then move on to some graphical applications, if your browser permits (if not, please install a more suitable one). We will first draw some static shapes:
The text that constitutes a program is often referred to as "code". That does not mean it is encrypted, though it can often prove hard to read.
In these pages you can learn to read and write "source code". Its grammatical rules are designed to enable human programmers to be able to define the required processing accurately in terms they can readily learn to write and to read. No hardware in a computer is able to execute such code directly.