Pencil Code Online Guide

This page collects together useful reference materials and examples. If you have ideas for other good material for this page, post them on the discussion group so that they can make their way into this area. Pencil Code is free to use, but there are some community guidelines. Check out the terms of service and privacy policy, and take a look at the overview video.

Many printable classroom materials are gathered on activity.pencilcode.net. Here is a Quick Reference Sheet summarizing Pencil Code functions, and here is a brief CoffeeScript Language Reference. When learning about angles and turtle graphics, print out these reference sheets on Measuring Distance and Angles and on Arcs and Circles.

This Learn to Program with CoffeeScript tutorial introduces the basic concepts of Iced CoffeeScript by working on a single project. At the end of the two-hour tutorial, you have built a hangman game that uses variables, computer arithmetic, looping and conditionals, graphics, synchronization, and networking.

For teachers using Pencil Code to provide a elements of a full introduction to programming, the Pencil Code Teaching Manual provides twelve chapters of examples, explanations, and sample lesson plans on how Pencil Code can be used to cover topics from I/O, to Netsted Loops, to Recursion, to jQuery. The manual is freely available as printable PDFs.

There are many other resources for learning about CoffeeScript. The book Smooth Coffeescript by E. Hoigaard is a good book oriented towards new programmers. If you would like a video lecture, here here is a video course from Code School that is oriented towards students who already know some programming. The O'Reilly book Little Book on CoffeeeScript by Alex MacCaw is a svelte 62 pages. This slide deck from Aseem Kishore covers the language pretty thoroughly. If you are looking for a cookbook with ideas for small pieces of code, take a look at the CoffeeScript Cookbook online, or explore the examples below.

The examples below are fit for brief explorations. A paperback guide that includes color illustrations for each example is available on Amazon or as a pdf.

  1. Lines. Programming with sequences and lines and curves. First Video, Worksheet. Angles video.
  2. Points. Dots, labels, variables and basic debugging techniques.
  3. Loops. Using the for statement to repeat code.
  4. Nesting. Nesting loops to build beautiful effects.
  5. Functions. Using -> to define your own functions.
  6. Parameters. More powerful uses of function parameters.
  7. Time. Repeating code using a simple tick timer.
  8. Output. Using write and HTML and CSS for output.
  9. Input. Using read and button for input.
  10. Numbers. How to use numbers for counting and calculation.
  11. Computation. Examples of more complex mathematical computations.
  12. Objects. Making and using objects with several properties.
  13. Arrays. Arrays are for sequences and vectors and stacks.
  14. Recursion. Recursive functions call themselves and can make amazing effects.
  15. Concurrency. Race conditions, shared memory, message passing.
  16. Sets. Multiple turtles and jQuery sets.
  17. Motion. Simulating motion with velocity, gravity, and physics.
  18. Networking. Using resources on the web.
  19. Intelligence. Artificial intelligence, reasoning, and backtracking.