The Importance of Graphics
Posted by Peter on March 12, 2006
Students learn best when they have something they want to do on the computer. Usually this means some kind of personal project. For example I bet many beginning programmers learned how to write network code not in a class, but because they wanted to make an online game or a chat program. Beginning programmers are often intrigued by the idea of making their own games, no matter how simple. Thus introducing them to the graphics libraries, or at least some limited subset of them is a good idea. For Scheme the best graphics for beginners are the viewport graphics. Nice features of the library include built-in ways to draw most simple graphics as well as a fairly straightforward interface for getting user keyboard and mouse input (although it could be simplified a bit). There are a couple of disadvantages to using this library however. One is that if the window is closed by using the operating system close commands (such as clicking the X in the upper right) the program has no way of determining this, and will continue indefinitely until the programmer manually breaks its operation. Another is that the drawing commands are implanted in an object oriented system (and usually one doesn’t talk about object oriented concepts until much much later). For example you don’t draw a line with
(draw-line viewport pos1 pos2 color) instead you must write
((draw-line viewport) p1 p2 color). Admittedly I could eliminate some of this with wrapper functions, but students seem to be able to use the library well enough without them, even if they don’t understand it fully. Despite my satisfaction with it I may still write my own graphics library for beginners, simply because of the bug where the program will continue to run even though the viewport is closed, and if I do I promise to post it here.
One closing remark: As their first project I have students write a version of the snake game, and it seems to be fairly effective in sparking their interest in learning more on their own.