Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Symbolic: code example

Author: Tord Romstad

Date: 09:44:47 01/23/04

Go up one level in this thread


On January 23, 2004 at 09:27:53, Robert Hyatt wrote:

>On January 23, 2004 at 03:37:46, Tord Romstad wrote:
>
>>On January 22, 2004 at 22:58:00, Robert Hyatt wrote:
>>
>>>you know, when I was first introduced to Lisp a _long_ time ago, I looked
>>>the person right in the eye and said "that is a write-only language."
>>>
>>>My opinion has not changed.
>>
>>Then just go ahead and hack the readtable to your liking.  Lisp is not called
>>a "programmable programming language" for no reason.  The syntax, like most
>>other aspects of the language, is fully programmable.  Readtables are
>>first-class objects and can be copied, manipulated, passed to and returned
>>from functions.  You can even change it at runtime if you want.  It won't
>>even break your macros.
>
>Why not also hack the BNF grammer for C to fix the things I don't like there?

But then you are no longer programming in C.

>oops.  <portability>  :)
>
>That is _still_ an important concept.

It is.  That is one of the many reasons your analogy is flawed.  There is
no loss of portability if you define a new readtable.  Your code is still
perfectly portable ANSI Common Lisp.  The READ function and
readtables as first-class objects is not only part of the ANSI Common
Lisp standard, they are so fundamental that they could arguably be
said to be the defining feature of the language.

Lisp has no fixed syntax.  It is all fluid, and can be changed from
*within* the language.  There is no way you can do anything even
remotely similar in C.  Most (though not quite all) Lispers prefer to
keep the flexibility of the s-expression syntax, but it is not because
they are forced to do so.

>>You may wonder why hardly anyone uses anything except the default s-expression
>>syntax.  The reason is that all experienced Lisp programmers learn to love the
>>syntax, and find it to be one of the main attractions of the language.  It is
>>not at all difficult to read, once you get used to it.  I read Lisp code
>>much more easily and fluently than any of the more mainstream languages.
>
>I have done lots of lisp programming in the past.

Considering your apparently very limited knowledge of Lisp, I would
assume that this was in the very distant past.  Otherwise, your
instructors and/or books must have been very poor.

>However I would never
>say that ((((((((((x))))))))))) is easier to read than well-written C that
>is indented reasonably...

Comparing well-written C to horrible Lisp is not quite fair, is it?
your "code" above couldn't possibly occur in any well-written Lisp
program.

>>>:)
>>>
>>>Thank goodness vi supports the % key. :)
>>
>>The editor friendlyness is one of the benefits of the syntax.  Thanks to
>>the syntax, Lisp code is much easier and faster to write, manipulate
>>and navigate than code in other languages.  When writing C code, I am
>>forced to take a very low-level approach to editing, and move around,
>>copy and delete code on a line or character basis most of the time.
>>When writing Lisp code, I can navigate by expressions rather than by
>>lines and characters.
>
>If you write C properly, moving stuff around is very easy.  I do this all
>the time with no problem.  It just requires some discipline in indenting so
>that when you move a block, you only move a block...

To some extent it works, but it is too limited to be really useful.
Consider one of the simplest possible examples:  If my cursor is at the
beginning of the C expression 3*a + 2*b + 4*c, and I try to execute a
keystroke which is supposed to delete (or copy, or mark, or whatever) the
expression directly following the expression, it is not possible for the
editor to know whether I want to do the operation on 3*a or the sum of all
the three terms.  For the equivalent Lisp expression
(+ (* 3 a) (* 2 b) (* 4 c)), the behavior is perfectly well-defined.

I have thousands of hours of programming experience in C as well as Lisp.
I read, write, debug and edit Lisp code several times faster than C code
for all non-trivial programming tasks.  And this is *not* because I am
good, rather the reverse.  I am a mathematician, not a programmer.
Experts like you might be able to write complicated programs in low-level
languages like C.  Lisp is a tool which makes it possible for
uneducated amateurs like myself to make the computer do really
amazing things.

Tord





This page took 0.01 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.