Here is a first lesson on Lines using Pencil Code. It shows how to use functions by introducing five commands that can be used to create drawings by moving a turtle. It shows how to test functions and build them into a program, and it shows how to save them on your own website. It is about five minutes long.
You can teach by just showing the video, or by using the video for ideas on what to talk about in your class.
When teaching this material, expect it to take about an hour for first-time programmers to understand how to create a program and to create two or three of their own programs. Be sure to encourage students to draw out a plan ahead of time. Have them put in the effort to create a program that accurately follows their written plan. A sheet of graph paper can help.
Rachel Nicoll put together a terrific worksheet to hand out to kids that guides them through a few exercises. There is also an outline for teachers and a reference page to print out that you can use as a handy one-page guide.
Here is a lesson on Angles using Pencil Code. It talks about why a triangle can be made with 120 degree angles. Using concrete turtle programs, it teaches the mathematical concepts of exterior and interior angle, arcs, and regular polygons. And it provides a hint for exploring curves with winding number larger than zero.
No written companion materials yet, but when they are ready, I will update this blog post.
You can see in the thumbnails that it is a slim book that presents more than 100 short example programs, each one illustrated in color. There is very little text. This is a book for inductive learning: each important concept is illustrated by an example that is short enough to invite experimentation and exploration.
Run programs at pencilcode.net. There you will find an online help system as well as hundreds of other users' projects to explore and copy. Save your own projects on by creating your own subdomain there.
I am publishing the book today because I think it will make a good holiday gift for the daughter or son in your family who is just at the edge of being interested in programming computers. The illustrations are a way to invite a little interest, and the short pieces of code make a good project to sit down and work on together with Mom and Dad or brother or sister. Since there are more than 100 projects, there is a little something for everybody: art, games, puzzles, humor, or simulations.
Of course, you can program in Pencil Code without buying or waiting for the book - the online sandbox is free, open-source, and openly available. Here are a few projects to try:
Drawing a smile
Catalog of polygons
Guess my number
Orbit (click to move the sun)
Bizarro tic-tac-toe (try to lose)
Programming as an Artistic Pursuit
When I was growing up, my father brought home an Atari 800 and subscribed our family to COMPUTE! magazine. Like several other computer hobbyist periodicals of the era, every issue of the magazine was chock-full of source code for games, algorithms, and utility software.
The printed programs were magic. I would type these programs, not understanding much of how they worked, and I would be rewarded with an amazing piece of running software. Soon I recruited my Mom to type with me. She didn't understand much about the code either. However, she brought an essential skill to the table: she was a trained typist, and so she could help me enter pages of long mysterious code at more than 30 words per minute!
After days of typing and a lot of painstaking typo-checking, a little bit of computer programming wisdom would leak into our heads. Gems such as how the letter "O" works differently from the number "0" even though they look quite similar, or that the "REM" statement (a comment) doesn't actually do anything.
After typing many games that I didn't comprehend, the first program I actually understood was a 10-line prime number sieve. That kernel of knowledge let me build and modify many mathematical algorithms and graphing programs. Then I went back to steal techniques from the magazines to make my own games. Growing up in the era of printed source code was a formative experience. Freelance code published in a magazine made it obvious that programming was a creative, personal endeavor.
For me, the computer was a blank sheet of paper, and writing programs was an artistic process.
But the year I graduated from high school, the world also graduated from printed source code. In May of 1988, COMPUTE! announced that they would no longer print source code in their magazine. Their justification: "As computers and software have become more powerful... we also realize that you're less inclined to type those programs." So by the summer of 1988, the code was gone, and it was replaced by "a complete buyer's guide in each issue to help you find, and then buy, the right software for your computer."
The world had changed. Before that moment, programs were manifestations of personal creativity, distilled cleverness in the same way that poems or symphonies are specialized creative forms. After 1988, programs became industrial products, produced by highly trained professionals working in teams cordoned behind secure gates, and distributed to the public as sealed, shrink-wrapped products.
A Return to 1988
First, the economy has been profoundly transformed by the impact of software. There are no corners of commerce - from farming to medicine to manufacturing to retail to trade to finance to war - that have not been fundamentally restructured around the analytical and organizational power of automation. Software infuses everything. While in 1990 we imagined that it was important for the "Knowledge Worker" to be able to be creative with software, in 2013, it is becoming clear that almost all workers must spend some of their time being "Knowledge Workers."
So we cannot teach this generation of children to be afraid of writing programs. They must understand that code is an approachable tool - that it can be used, like a pencil, to do both utterly simple things as well as blindingly complicated things. Tomorrow's adults must have an intuition for how software is created, how it can work well, how it fails, and what role it should play. And they must know that, ultimately, they are capable of creating software. Whether they write a spreadsheet macro to fact-check a statistic, or whether they create an elaborate storefront app to automate their business, tomorrow's workers must be literate in code just as 20th century Americans learned English literacy. Computer code is becoming an essential tool for understanding, cooperation, and commerce.
The Rise of Pseudocode
The second trend is that computers have become faster than they need to be, and that is making them easier to program. In the old COMPUTE! magazines, the experts of the day proudly announced a highly tweaked assembly-language sorting program that was "Capable of sorting 1000 items in 2.1 minutes." (That is a millisecond operation for a mobile phone today.) With slow computers, programs needed to be absolutely optimized for the computer, even if that meant the code was incomprehensible to humans.
Today's computers are so fast that we must make the opposite choice. Most computers spend most of their CPU clock cycles idle, waiting for the user to decide what they want to click next. So when optimizing a system, the right design is to spend as much computer effort as possible to simplify and speed things up for the person. In particular that means that programming languages must be designed to be easy for people to read and write, even at the cost of making programs more difficult for computers to run.
A Holiday Activity
My hope, in working on Pencil Code, is to do a little bit to help bring these two trends together. Children should learn how to write programs. It is good for the world, and it is good for their personal education. But they should learn how to do it with authentic tools - the same ones used by professionals. Pencil Code helps you program in CoffeeScript. Modern languages like CoffeeScript make it easy to program, and they empower the programmer to do interesting things in the real world. And they let you see through straight though to the real concepts without getting hung up in the boilerplate details.
My wish is that, during the holidays, you will find a moment to play with Pencil Code together with somebody, and open their eyes to the world of coding as a personal and creative endeavor.
Upvote on Reddit.