The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Lisp and Lispworks?

Has anyone used Lisp before? Paul Graham has piqued my curiosity about it. Here's what makes Lisp different: other languages have syntax which the compiler parses into lexical trees & interprets. Lisp has no syntax: you program directlty in the lexical trees, and you can manipulate them. This makes metaprogramming easy (i.e. code that generates code). Lisp macros are not like C macros; they take code as an argument, perform arbitrary transformations on it, then evaluate the resulting code. This is unique to Lisp. There's even a cross-platform IDE/source debugger/GUI builder/install maker called LispWorks that looks mature & useable.

In other languages, you solve problems using whatever canned constructs the language syntax gives you, & if you need one you don't have, you're stuck & have to kludge your way around the problem (e.g. polymorphism in C, or containers that hold objects of different types in C++). In Lisp, you solve problems by (a) using the metaprogramming features to make a language that describes the problem, then (b) using that language to solve the problem.

I think it's cool as hell, & I like the elegance of programming in pure mathematical set theory. However, to my eye, Lisp code is hideously gruesome & unreadable. In a language w/syntax (say C or C++) I can write very clean, readable code that anyone can understand, incl. myself a year later when I've forgotten what I did & how.

Do I understand Lisp correctly? Has anyone here tried Lisp + LispWorks? Do all those awful parentheses become readable once you get used to looking at them? Is the code maintainable, or is it write-only code like Perl? Is the C interface any easier than it is in Python or Java?

Thanks in advance,
John Foxx
Friday, April 01, 2005
That sounds about right. That's the version I read about when I started with Common Lisp, and to my mind it was kind of technical, fancy and abstract. When I internalized these concepts, it became much simpler.

On "metaprogramming," it's just the observation that you should have the ability to operate on code just as if it were any other piece of data. After all, that's much of what we do as programmers! Why should it be hard to operate on code?

So Lisp code is stored in something like XML, but likely stronger. (Sexps.) As I understand XML, it only supports text. Sexps support numbers, characters, text, arrays, lists, etc. So while you may have code physically pickled in a text file, once Lisp reads it, it's converted into data structures.

Now, there is a sweet spot where doing this is very useful, but beyond that it starts being counterproductive. Lisp is multiparadigm, and once any single technique starts hogging the stage, that may become a bad thing:

Paul is interesting in that he probably obscures some of the best advantages of Lisp. I hear Lisp's OOP system is overall the most powerful of any known language. Lisp suppports multidimensional adjustable arrays with fill-pointers. It has an iteration form called "loop" which is like every for{;;} loop in every language rolled into one. (And it's a macro, which means that a normal Lisp user baked it into the language, and it eventually became accepted by others because it was so useful.) You can read more here:

As for liking parens... I don't know, that's a personal issue and maybe to you it won't be overcome. There's a relative of Lisp, called Scheme, which does a bit less with its parens, and so I look at its use of parens as a little silly. (But that's subjective and political of me. ;) I think parens need a reason for existence.
Tayssir John Gabbour Send private email
Friday, April 01, 2005

(please excuse my crude english)

back in University we had buil a CommonLisp (0) into C Compiler (google for CLiCC).

Lisp is a powerful language for its purposes.
It teaches functional programming.
(in difference to prodedural, imparative, massage related
and objectorientated)

You can see it in the real world (TM) in the wonderful
editor EMACS, which is highly configurable with Lisp.

It is very useful in scanning und parsing.

The language is NOT state of the art, because it has flaws like untypedness.

(0) a subset of CommonLisp (see the book by a guy named Steele) without the eval-function.
Peter Miehle Send private email
Friday, April 01, 2005
Python is getting more lisplike every day (and fewer people scoff if you say it's your favorite language), and Dylan may be an acceptable lisp derivative if you can't stand the paren nesting.
Art Send private email
Friday, April 01, 2005
Hey Art,

I guess you can get used to anything if you stare at it long enough... I'm just trying to get a feel for whether (a) it starts feeling natural as you work with it, or (b) as programs grow, they lose comprehensibility as they start to look like:
((((((((((((((((((((((((((((((my-stupid-function x y(z p(d (q))))

or something like that.  The truth is probably somewhere in between. I guess there's no substitute for downloading an interpreter & just playing with it. Even if I decide I don't like it, I still think it's cool.
John Foxx
Friday, April 01, 2005

That's the thing.  You're definitely going to learn to read the parens just through repetition, but you're also going to end up leaning heavily on your development environment to do formatting and structuring for you.  That editing environment is usually emacs or an emacs-alike, so if you hate emacs, you'll have one more annoyance to get over.
Art Send private email
Friday, April 01, 2005
A couple people I know swear by Lispworks, and it doesn't seem Emacs-like. In fact, one of them really doesn't want to learn Emacs, and he's productively developing AspectL. I've only used Lispworks a couple times, but I vaguely recall that you have to go into Preferences or something and specifically select that you want Windows/Mac hotkeys though.

You get used to reading Lisp; it's mostly:
(idea thing thing thing)

or, knowing code doesn't indent properly on this forum:
(idea thing
      (idea thing thing)

To me, Java is a verbose mass of semicolons, braces and parens. Even with Python, a lot of people had strong visceral reactions against its whitespace formatting. Then they used it for a while.
Tayssir John Gabbour Send private email
Friday, April 01, 2005
Actually, this reminds me of a talk a Schemer gave. The parens become thinner and less obvious, the more you use Lisp. Just a visual cue to hang structure on.

One guy waxed poetic and said "The journey of a thousand miles begins with an open parenthesis." I see an amoeba. Some see a semantic ball of mud. In one of my meaner moments, I joked, "Lisp is so old, those aren't parentheses, those are wrinkles." One artless fellow likened it to a toenail omelette. ;)
Tayssir John Gabbour Send private email
Friday, April 01, 2005
"...awful parentheses..."

No more awful than the parens/braces/brackets in just about other language.

I've tried writing the same code in Lisp and Java, and if you copy it line-for-line the Lisp actually has fewer parens than the Java does parens/braces/brackets.  And if you use the more natural Lisp idioms it's fewer *lines* even.

As a really simple example, write code to make a list of ints from 1 to n.  In Java, it takes me 4 pairs of ()'s (with generics I think it's only 3).  With Lisp it's only one pair of ().  So, sure, a relatively larger fraction of your code is parens, but you need less code to do the same thing.

If you write code that looks like "((((((((((((((((((((" in Lisp, you probably do the same in C or Java or anywhere else.  You've got programming issues, not language issues.  :-)

I've never used Lispworks.  For better or worse (probably worse), the C interface is probably implementation-specific, so you'll need to ask the Lispworks guys how that works.  I would guess it's probably not as messy as Java's, but maybe not as clean as Python's.

It does have perhaps the most powerful OO system ever created; I've never had to use it.  Not that it's bad (it's not), but Lisp doesn't force any particular style on you, and offers gobs of features (closures!), so I've never needed it.

"LISP is worth learning for a different reason — the profound enlightenment experience you will have when you finally get it. That experience will make you a better programmer for the rest of your days, even if you never actually use LISP itself a lot."
old-at-heart young'un
Friday, April 01, 2005
Hey young'un,

You're right, but I'll tell you what's hurting my eyes: the sample code in books is full of the kind of one-line compound statements which the language seems to encourage. I find that I have to READ these carefully: "Let's see, this inner bit here is a function call, it's nested in this array here..." I think that's a part of my trouble. Here's an admittedly contrived C++ example to show what I mean. Contrast this:

int RetCode, Index;
CSomeObject* pSO;

Index = MyObjectList.Get("unique_identifier");
pSO = MyObjectList[Index];

With this:


Ugh--Lord have mercy. Anyway, I will get into Lisp at some point just for the sheer hell of it, but I don't have much application for it right now & the learning curve seeems a bit expensive. I've downloaded some good books about it, though, and it has a tight community, so that should help.
John Foxx
Saturday, April 02, 2005
>  Do all those awful parentheses become readable
> once you get used to looking at them?

Never did for me.
son of parnas
Saturday, April 02, 2005
If decent metaprogramming's what you're after, there are PLENTY of alternatives to Lisp.  Nemerle, Dylan, Template Haskell, MetaOCaml (or just OCaml with camlp4, if you can cope with syntax extensions being outside your regular code)... all can do most of the useful things Lisp macros can do, and all have a much richer syntax.
Tuesday, April 05, 2005
Is there a freely available and good IDE/GUI builder and compiler for Lisp on Windows? Corman Lisp costs $$$.
Tuesday, April 05, 2005
"The language is NOT state of the art, because it has flaws like untypedness."

Agreed, in that Lisp is not state of the art.  But Lisp isn't untyped; it's dynamically typed.  "Untyped" is something like Forth, where you just manipulate bit patterns, and it's up to you how those patterns should be interpreted.

If you do mean that Lisp is dynamically typed then, well, that's a personal preference.  Some people love dynamic typing, other people hate it.  The favorite argument for people in the latter camp is that you can't write large systems without static typing, but then look at Zope and all othe other large systems written in Python.  And Ericsson writes million+ line telecom systems in a dynamically typed language.  There's a disconnect between what people want to be the case and what's actually the case.
Tuesday, April 05, 2005
Ericsson used Erland ( to develop one switch. They wrote cca 1 million lines in Erlang and another million in C. Main advantage of Erlang is its _superb_ support for concurent programming and handling of errors; its typeless nature is more-less accident of history. There is university project to add static checking into language. Tool to do as much static checking as possible is distributed together with Erlang.
Tuesday, April 05, 2005
Hey j.

I don't know whether I byt into THIS being a good thing:
  x = 5
  x = "billy bob"
but I can see a lot of value in having containers that can hold heterogeneous objects & let you call list[i].func() for each one, worrying only about whether each object has a function called func at call-time.

In C++ and Java, the first phase of a project is often the construction of a large class hierarchy, not for the sake of inheritance, but rather to satisfy the language's compile-time type checking.  These hierarchies are time-consuming to think out & not easy to refactor if you get it wrong.

I think it can be a significant advantage for the method & property info. to ride along w/the object so you can query it at run-time, as opposed to compiling the object into a shapeless bag of bytes, about which the caller must have perfect a-priori knowledge.
John Foxx
Tuesday, April 05, 2005
Reminds me of a real-world test of Erlang's static typechecking, where it uncovered no errors. The author surmised "it seems that good programmers don't make type errors." (I didn't yet read the original though, so it may be completely out of context.)

Numerous static typechecking systems have written for CL. Mark Tarver's SEQUEL, Qi, ACL2, TypeL, and whatever this thing is:

All probably just a bunch o' macros or something. I can't speak to their level of completeness, as I've never touched them.

Further, Lisp also supports optional type declaration so the compiler may optimize better. Right out of the box. One implementation apparently uses type inferencing to this end.
Tayssir John Gabbour Send private email
Tuesday, April 05, 2005
In VB, you could "dim x as type" or just "dim x" (or was it "dim x as variant"?).

So it gave you both static and dynamic typing, and you got to choose.

It also gave you "option explicit" and implicit type declarations.
i like i
Wednesday, April 06, 2005
Is there a freely available and good IDE/GUI builder and compiler for Lisp on Windows? Corman Lisp costs $$$.
Wednesday, April 06, 2005
Hey Editor Dave,

You might want to google "lispworks Lisp IDE". I haven't used it myself but it appears to be a cross-platform IDE with source-level debugger and GUI builder. It's not free, but things which are useable right out of the box are rarely free. The web site says it's "competitively priced" but doesn't list a price.

Mr. Gabbour,

Your comments have indeed been insightful, & I enjoyed the slideshow on your web site (in particular, ponting out that XML is essentially parenthetical syntax like Lisp). That was amusing, but note that XML is not human-readable, as anyone who has worked with Ant will tell you. Nested sets are just hard for humans to read, though it may be possible to develop the right kind of eyeballs for it.
John Foxx
Wednesday, April 06, 2005
Oh yeah, another thing I wanted to add; when working in C or C++ I DO frequently use the type checking to do work for me, and sometimes I goose the typechecker in the following manner;

Suppose you have an array (or other container) of Umpty objects. Each Umpty instance has an Umpty key (a meaningless number that uniquely identifies an instance) as well as an index (its location within the Umpty array). There are utility functions which take an Umpty key as an argument, and others whichh take an Umpty index as an argument, and you had better not confuse the one for the other because they're not the same thing.

Instead of making keys and indices both unsigned integers, you can use typedef struct or typedef enum to create two new types, UmptyKey and UmptyIndex. Both types are just dummy containers for an integer, but now the compiler will flag you if you accidentally try to pass a key to a function that takes an index, or vice versa.

So I like the notion of being able to specify static typing when it suits me, & dynamic typing when it does not...  Think there are any hotshot young language designers reading this thread? :-)
John Foxx
Wednesday, April 06, 2005
Not enum, that was a brain fart. Just struct. Sorry, it's been a long day & it ain't over yet.
John Foxx
Wednesday, April 06, 2005
Competitively priced? Lispworks Professional Edition is $1100. I'm not sure who exactly they are competing *with*.
Wednesday, April 06, 2005
Competetively priced since their main competition would be "Allegro Common Lisp". Try getting a price for a profesional edition of that. Hint: yes, it is oe of those packages where you will not get a price unless you talk to their sales which will try to figure out how much they can get out of your pocket. Count on several thousand $.
Just me (Sir to you) Send private email
Thursday, April 07, 2005
Plus you have to negotiate per-unit royalties if you sell a programm *written* with Allegro Common Lisp.  Wow, that's a throwback to a much earlier era.

As someone else mentioned, Corman Common Lisp is a good choice if you're Windows-only.  It's too bad there isn't a cross-platform Lisp that isn't priced through the roof.  ($400-$500 is top end for a development environment, IMO.)
Thursday, April 07, 2005
$1100 is in the same ballpark as Trolltech QT--not a lot of money if you have a company & the tool is critical to the success of your project, but if you don't really need to write your GUI in Lisp, Borland C++ Builder has the best bang/buck ratio IMHO, and supports Linux and Windows (but not Mac).
John Foxx
Thursday, April 07, 2005
A co-worker pointed this thread out to me. Just some random thoughts:

I use Lisp and LispWorks professionally.

I am not especially inclined towards Common Lisp, however, in my current development situation I realised that the application is too complex to be developed using C# or Java.  The end application is prone to extensive changes, and to meet profitability expectations, it was necessary to write it in such a way as to be quickly changed (I'm being vague, I know, but it's hard to explain).  De-composition of the problem into objects was greatly aided by CLOS and my code is quite tiny (less than 15.000 lines) due to the efficiencies present in the language.  There are more benefits such as the availability of a well-designed expert systems shell in the Enterprise Edition. My application is cross-platform - it runs on both Windows 2000/XP/2003 and Mac OS X (> 10.2). The application GUI uses native widgets on both platforms.

Some of the previous messages have noted that LispWorks is not free ($1000+ for professional edition and $4000+ for enteprise edition). That does not bother me since my product brings in a few million a year.  I recall that renting the parking lot adjacent to our place costs more than our collective development licenses.  Allegro is pricey - but you should remember that they have been in business for more than 25 years - I think they know what they are doing.

Before you embark on a project with Lisp and LispWorks, you should know that the language is fairly dense and abstract - it's okay to spend a couple of years playing around before doing something serious.
Wednesday, April 13, 2005
Get to your library & get "the little schemer".

2 or 3 weeks, an hour here & there & That'll get you THINKING appropriately.

listen to these - download & save to a DVD.

Maybe follow along, using the book (available free on the web)

I'm coming to Scheme after 10 years of
C, Delphi, VB, C++, PERL, Ksh, sh and a lot of other languages that were needed for one or 2 month projects.

It's clean and simple.  You learn the syntax in 5 minutes.
It's clean and simple. 
(relative to "normal" languages) no "put a semicolon here but not there" kind of thing.

Here's a list of a couple of things that are small things individually that are incredible to me, after the years & years of other "normal" languages.  Taken together with the entire language all these small things add up to an awesome package.

1. it's almost no work to write functions that take variable length argument lists.  Try that in Pascal, VB, Modula.  Impossible (at least when I used those languages).  C does it, but not easily.

2. Writing a func that answers a specific question?
This one little thing makes code so much easier to read.

3. the entire language is easy to understand.  Read Donald Norman (The Design of Everyday Things) to understand the importance of this.
Simplicity, simplicity, simplicity.    Many of the introductory Scheme textbooks have you write an interpreter for Scheme by the end of the textbook.  (Don't confuse "big" with "complicated".)  Or use Scheme, which is small AND simple.

4. No precedence table to learn.
Saturday, April 23, 2005
>> (Don't confuse "big" with "complicated".) 
>> Or use Scheme, which is small AND simple.

This was unclear. 
Lisp is big & simple.
Scheme is small & simple.
Saturday, April 23, 2005

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz