3 ms·
I looked at a bunch of things for teaching and I settled on JavaScript. It's not ideal as a language, but it ticks enough of the required boxes. The primary b
by Lerc 12y ago
I looked at a bunch of things for teaching and I settled on JavaScript. It's not ideal as a language, but it ticks enough of the required boxes. The primary benefit was being able to teach someone without having to install any software. Quite often I would have to use locked down school computers, so doing everything from the browser was crucial.
I put together a simple library that has global functions to let the very first programs do interesting things while remaining simple.
I made a mediawiki Plugin so that I could have code examples that you can edit and run within the page. http://fingswotidun.com/code/index.php/Main_Page http://fingswotidun.com/code/index.php/Main_Page
Having simple examples that you can see,run and change helps a great deal.
This is my standard starter program.
http://jsbin.com/camocarohi/1/edit?js,output http://jsbin.com/camocarohi/1/edit?js,output
It does something, and the entire program can be viewed on the one screen, so you can keep it in one place and point to the parts to show what is happening. When that question comes "How can I write a game?" (and it _will_ come before the first lesson is finished, I can direct them to the list of available functions at http://fingswotidun.com/code/index.php/API http://fingswotidun.com/code/index.php/API point out the first entry "clear()" then put that in front of the fillCircle() call. The program goes from a drawing program to a moving dot game. From there you just go with the flow of "How do I make it do (X)?"
This is where a single hour lesson with my own daughter (age 11) ended up after starting with that base
http://jsbin.com/coguvokupu/1/edit?js,output http://jsbin.com/coguvokupu/1/edit?js,output
The single greatest downside to using JavaScript is that it is not preempting/blocking. A beginner will always assume that
var spaceShip=loadImage("myship.png")
will have the image loaded when the next line of code is reached. Events and callbacks are not principles you want to deal with as a first step. Similarly, you have problems when they try
while(true){drawCircle(rand(),rand(),rand())};
The reasons why they can't do things the way they assume are at a more advanced level.