Which kid's beginners programming - Python or Forth?

Rocco Moretti roccomoretti at hotpop.com
Tue Jun 28 19:41:18 EDT 2005


BORT wrote:

> I am toying with the idea of teaching my ten year old a little about
> programming.  I started my search with something like "best FREE
> programming language for kids."  After MUCH clicking and high-level
> scanning, I am looking at Python and Forth.  Both have advocates that
> say each is a great approach to learning computers.

Call me biased, but I'd recommend Python, and it all comes down to a 
single concept: Transferability.

As others have mentioned, Forth programming is in somewhat of it's own 
class. It's not really imperative, object oriented, or declarative. It's 
based on an interesting, but rarely used, principle of stack programing. 
Great for someone who is expanding their horizons, but not a lot of 
value for a beginning programmer who might want to branch out to 
C/Visual Basic/Java/etc.

Also, due to the stack-based nature of the beast, the base way of 
specifying mathematical operations doesn't transfer to/from elsewhere, 
unless you're talking about old HP calculators. Python uses the standard 
mathematical notation, and even uses mathematical precedents (i.e. 
multiplication before division).

So for Math you'd do something like:

y = b + mx + cx^2

(Where ^2 is a superscript 2)

For Python it would be:

y = b + m*x + c*x**2

IIRC, for Forth it would be something like (please excuse the mistakes 
in operator notation):

x 2 ^ c * m x * + b + 'y' setvar

Where you read from left to right, and imagine pushing items onto a 
stack, and when you encounter an operator, you pop the appropriate 
number of items, act on them, and push the result back onto the stack.

Granted, you can get Forth dialects with the ability to do infix 
(mathematical) notation, but that leads to another transferability 
issue, that between interpreters. There is one "official" Python 
interpreter, and the developers work dang hard to make sure it runs on 
every commonly used platform. The other interpreters are usually special 
purpose, and tend to be up front about where they differ from the 
"official" Python. Thus, if you see Python code somewhere, it is highly 
likely it will run on your Python interpreter

Forth, as it has been around much longer, is a much more fragmented 
community, with many more interpreters. What works on one may not work 
on another, and a particular interpreter is likely to be available only 
for a single platform. With Forth it is *very* easy to extend the 
language, and so an interpreter-specific piece of code that someone 
posts may not work for you on your interpreter, especially if you're 
using a free interpreter for Windows, which tends to be the bastard step 
child of free stuff.

There are ANS and IEEE standards for Forth, but official standards tend 
to leave things implementation dependent, especially in platform 
specific things like file access. To further compound the issue, a Forth 
system tends to be self contained and insular - interaction with the 
surrounding environment may be minimal at best. Python, where possible, 
tries to shield the user from platform specifics, while still allowing 
full access to the environment. There are a number of Python bindings to 
C libraries which give near complete control to the desktop/screen/sound 
system, etc. Forth-bound libraries will likely be rarer, and again, 
interpreter specific.

It's been quite some time since I've looked at Forth, and the reference 
material that I used then was probably outdated anyway, so someone with 
more recent experience can correct me if I'm wrong. However, I would 
think it's highly likely that the experience you receive with Forth is 
going to depend heavily on which interpreter you choose to use.

P.S. Any 10 year old getting into programing would likely love a library 
like PyGame (www.pygame.org) - I'd suggest seeing if the Forth you're 
considering has something similar before deciding.



More information about the Python-list mailing list