Kid's Programming Language
| |
Kid's Programming Language (KPL) is a language modeled on the simplicity and readability of BASIC, but it is a structured rather than linear programming language. KPL lets kids see eye-catching and immediate results from their programs, while teaching them fundamental concepts like variables, data types, loops, decision structures, methods and functions. |
Difficulty: Intermediate
Time Required: 3-6 hours
Cost: Free
Hardware:
|
Coding4Fun is the point, right?
I bet if you took a poll, a lot of coders were gamers before they were coders—and that they got started by coding games. The cool thing is, after you learn to code and start making stuff work in the real world—stuff that isn't games—it's still fun! People reading this at Coding4Fun obviously think so, right?
So we all learned how to code and we know coding is fun, what do we do with that? Well, I think we want to give other people a chance to try coding, see what it's like, and figure out whether it's as fun for them as it is for us. If it is, they'll be coders too, and glad they are.
So how do we help them try coding? And when? We think kids can learn coding as early as they can learn reading and typing and math, and that learning coding helps with and complements other learning—so the sooner the better. Kids are all about fun, too: Harry Potter, Nintendo, Legos... So if you want kids to learn to code, make it easy. Make it fun. Help them make it a game.
Those are some of the things we were thinking about as we came up with KPL—our Kid's Programming Language. Coding4Fun makes a lot of sense to us, and is about a lot of these same thoughts, so we're very glad to have the chance to write an article introducing KPL here.
Kid's Programming Language
KPL is composed of:
- a readable and modular programming language
- a kid-usable but functionally complete integrated development environment
- a growing collection of fun sample programs and games
- an experience designed to make it fun for kids learning to code
KPL is available as a freeware download from http://www.ms-inc.net/kpl.aspx. The default KPL download is English-language, but a Polish-language download is available now, and Spanish, Swedish, Hebrew, Norwegian, German and Romanian translations are under way.
The Programming Language
KPL's language is modeled on the simplicity and readability of BASIC, but it is a structured rather than linear programming language. KPL lets kids see eye-catching and immediate results from their programs, while teaching them fundamental concepts like variables, data types, loops, decision structures, methods and functions. KPL's data types include integers, decimals, strings, booleans, arrays, and user-defined structures.
Here is a representative KPL method, which draws a parabola on the screen:
Method DrawParabola()
Var X As Decimal = -199.0
Var Y As Decimal = -200
Color( Blue )
Var LastX As Decimal
Var LastY As Decimal
While X < 200
LastX = X
LastY = Y
Y = (X * X / 200) * -1
X = X + 3
DrawLine( LastX, LastY, X, Y )
Trace( "X = " + X + ", Y = " + Y )
//Want to watch it draw slowly? Uncomment the next line:
//Delay( 1 )
End While
End Method
The IDE automatically applies color to code based on language syntax as shown. Other language features this example shows include built-in support for run-time trace messages, the use of code commenting, and the use of system methods like Color() and Delay().
The Integrated Development Environment
KPL presents a modern and full-featured Integrated Development Environment with features including:
- Windows-standard menus, toolbars and mouse-over tooltips
- Code editor features such as syntax color coding, bookmarking, indent/outdent and comment/uncomment
- Informational tooltips on mouse-over of variable or method names
- Multiple program files presented on tabs and shortcutted on the Window menu
- A program explorer pane for viewing and navigating the code hierarchically
- Dockable and pinnable IDE panes
- Collapsible and expandable code regions for all methods and functions—on mouseover, collapsed regions show underlying code in a tooltip
- Message pane for trace, debug and status messages
- C# and VB.NET code can be generated from the KPL source
The KPL IDE offers many productivity and usability features. Its visual design and feature set are specifically built to prepare a user to 'graduate' to Visual Studio.NET.
Figure 1. A screenshot of the KPL Integrated Development Environment
In this screenshot, the mouse is over the method call to ColorRGB and a tooltip describing that system method is displayed. Also, the right-side pane has been unpinned, and is collapsed to the edge of the window. The program has just been checked for errors, as is shown in the Messages pane.
Fun Sample Programs and Games
Helping kids code games, and showing them immediate graphical results from their coding—these are great ways to get them and keep them excited and interested in coding. This is the idea behind the sample programs and games included with KPL.
Of the many fun graphics capabilities KPL supports, Sprites offer the best graphical bang for a kid's coding buck. Graphics files in lots of different formats can be used to create a Sprite, which can then be displayed, moved, animated, rotated, scaled, and can interact with other Sprites. This allows someone to create an interactive program without having to learn the usual technical details of window creation, file handling, device contexts, alpha blending, collision detection, etc...
In our experience, starting off a new coder with their first program displaying a spaceship or other Sprite running around the screen—in only a few lines of code!—is a great way to catch their interest, make them believe they can program, and make them want to learn more.
Figure 2. Screenshot of a running KPL sample program
The sample program shown in Figure 2 is a fully functional game, with a scrolling screen, animated target Sprites moving at varying speeds, and a keyboard-controlled spaceship. This particular sample game, as functional as it is, is a KPL program of only 210 lines of code. Such a small but functional game demonstrates the graphical leverage and power offered by KPL—and it provides a game example and working code that a kid can modify and expand on to build more complex games.
KPL and its graphical engine can be used for more than just games, of course. Fractals are fun, too, right?
Figure 3. A KPL-rendered Mandelbrot set, plotted with 70 lines of KPL code
Do you want to play a game?
If you know any kids who might have fun coding games, KPL is as free as it is fun. Check it out, and tell us what you and they think?
We will also be working on a series of articles about coding games in KPL. Keep an eye out for them here on the Coding4Fun site. Some of them may remind you of arcade hits from oh so long ago...