Daily Static

Technology, Dynamic Programming and Entrepreneurship

This page is powered by Blogger. Isn't yours?
Sunday, February 23, 2003
Prefix Notation

I've been going through the Lisp tutorial provided with Emacs. It's
interesting how different prefix notation seems at first from the
algebraic notation more common with modern languages. To write the
expression 2 + 3 in lisp, you would write it as (+ 2 3). At first
this syntax seems clumsy and unfamiliar. However it quickly becomes
easy to read. One side effect that I've noticed in going through this
tutorial is prefix notation makes it immediately obvious that + is a
function. While this is obvious to many experienced computer
programmers, it's not always obvious to novices. I think the
algebraic syntax gets in the way of the learning process.

Everyone is introduced to algebraic syntax early in their schooling.
They are taught that 2 + 3 is equal to 5. The process of addition,
subtraction, multiplication and division become so ingrained and
automated that people no longer have to think about it.

Because the mechanics of mathematics are ingrained, when a budding
programmer is introduced to an mathematical statement in code, such as
2 + 3, they often miss the subtlety that + is actually a function
call. This problem is compounded by the fact that standard function
calls are completely different, they follow the form value>(), while the basic mathematical
operators follow the form . When I
began learning programming in the QBasic days, the fact that + was a
function completely escaped me. In fact this concept never became
clear to me until I began learning C++. It only became clear when I
learned about overriding this function call, that it was in fact a
function call. This caused some initial confusion, and it took some
time to get this concept straight in my head.

The prefix notation used by Lisp on the other hand is very different
than standard algebraic notation. As functions are introduced, it
becomes immediately obvious that +, -, *, / are function calls. This
of course is a very small thing, but it reduces the mystery of a
computer. It makes it more clear to a person what is happening.
This concept of understanding what the computer is doing is essential to
a successful programming career. From what I've seen so far of Lisp,
the syntax is pretty straight forward, and it only takes about 5
minutes to get used to it. It may however be a useful language for a
beginner to learn, rather than trying to introduce a concept that
looks identical to something the learner already knows but functions
slightly differently, it's sometimes easier to reduce the problem to
an abstracted form like the Lisp prefix syntax for teaching.

Comments: Post a Comment