Lets begin by writing one line of what the cool people called ‘code’.
Open processing and you should be faced with a white blank area. This the text area where the text that makes up your program goes. Above it you should see a table and above that a tool bar with circlar and rectangular buttons.
Below the white text area is a grey message area and below that is the black ‘printing’ area. The white exiting area works like a basic wordproccessor one in which you can’t change the font or make things bold but you can type text and you can cut, paste and perform all the usual exotic stuff we have become familiar with when using a computer.
In the white area type the following line on its own.
println(“hello world!”);
Now press the first triangle in the round circle above the text area. Assuming you have typed it in exactly as you see it you should see a small window appear (it might be called sketch something ) and the message
Hello world!
Printed in white on the black background benith the text area. Quit the window you made ( we will cover this in a moment). Congratulations you have made your first program. Most programmers call this the hello world moment. If you can get this to appear on the screen then after that everything else is relatively simple.
Lets go through the program and see what you have done. It began with the command or procedure or message ( they are currently synonymous) called println. This is short for PRINT LINE, and reaches far far back into the dawn of computing. Many many years ago computers where attached to teletype printers, a sort of electronically controlled typewriter. For example the hot line between America and the USSR during the cold war was a teletype (literally far type) a set of wires connecting two teletypes. Typing the letter H at one would make letter H be printed on the remote machine. By typing at each other two people or presidents could have a conversation. Once you had written you would press the return button to send it. Later during the development of the computer someone had the idea of hooking up a computer to a teletype and programming it to send text to the ‘printer’. This concept while wildly primitive does sit at the heart of all erasable programming languages. Begin able to print line or ‘println’ a message to your self is one of the last ditch ways you can check to see how a program is working. So you can see for most programmers once they figure out how to do the back stop ‘println’ then they can figure everything else out them selves.
So much for the println after the command comes a rounded bracket this says ‘I’m about add some descriptive terms or adjectives to the command. For example of we had a command called ‘throw’ we might have adverbs like hard, soft, up, down. The brackets say Ok I’m about to tell you something. If you have ever used a DOS prompt you might have said throw \down where \down is the argument to the program this is very similar to processing. In processing most the additions to a command come in a round bracket. So in the case of println the thing in the round bracket is what we are about to print.
We could say println(23) to say print the number 23. But in this case we are adding a text and we describe texts in double quote. If you have written a story text you might be used to writing
Barnaby said “Today the moon looks like a Banana”.
Where the text you want said is in the double quotes. Saying things in processing is just the same except println replaces said and the arguments ( what is said) is placed in the rounded bracket. Notice that in processing the quotes are old fashioned single quotes not the more clever opening and closing quotes (99’s and 66’s) you get in most word processors so be careful. Finally the line ends with the semicolon. Some languages like python end an ‘argument’ on one line. Processing takes the humble semincolone as the marker.
No comments:
Post a Comment