[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

What is a lightweight language



   > From: cbarber@curl.com
   > > I have one definition. A LL is one that you can design & implement with
   > > not too much work -- two, three days to get a really good
   > > implementation. That means you can afford to build a purpose-directed
   > > language for a single task or a small set of tasks. Got a problem?
   > > Build a language... then solve your problem.
   > >
   > > Scheme & Lisp macros are the only existing technology that provides
   > > this. Thus the talks that Shriram & I gave.
   >
   > Clearly by this definition, Scheme and Lisp are not themselves lightweight
   > languages.  

Full Common Lisp? No, not lightweight. A simple Scheme? Definitely
lightweight. All you need to write is a simple s-exp parser, a simple GC,
and implementations of the "big five" basic forms:
   LAMBDA
   QUOTE
   IF
   DEFINE
   SET!
Scheme is a very small language! Its power comes from the way you can
compose the parts in general ways, not from the baroque addition of 
features. Well, that, plus the ability to layer a full-featured language
on top of the primitive core using macros. (The general-composability-of-
a-simple-core property is also true of Smalltalk. The *language* is tiny,
but you can build up really complex artifacts with it... because of the
everything-is-an-object universality of its underlying primitve semantic
construct.)

There's a Scheme interpreter called "siod" which nicely illustrates what I
just outlined above, written in C. The entire interpreter is just a couple of
pages of code.

This has given rise to the observation that "you can implement a Scheme
system in an afternoon, but doing it right then takes the rest of your
life." The wording is due to Matteo Frigo, but it's a well-known trap.

"Lightweight" means multiple things to me. 
  - I think of Scheme itself as being lightweight because its core is so 
    small & simple. Now, a major, full-featured system like PLT Scheme
    is a big, powerful, feature-laden heavyweight thing. But the weight is
    in the libs, not in the language core. That's the way I like it.

  - I think of Scheme's macro technology as enabling me to build many 
    purpose-directed lightweight languages, as I described. In which case, 
    *those* languages would be lightweight, not the underlying Scheme system.

   > Furthermore, if your embedded macro language makes use of any features of
   > Scheme or Lisp, then wouldn't it then also have to be considered
   > non-lightweight? 

Well, as I said, you don't really get that much when you embed Scheme inside
your lightweight language -- "just" the core five things... and everything
that can be built from them. Which is a lot. Not much; a lot. That's the
magic of choosing your primitive forms well.

   > I think this definition is too narrow to be interesting.

Yes, I am in partial agreement. Since the only way I know to implement
"little languages" so easily is Scheme & Lisp macros, that kinda rules out
other languages I'd like to think of as lightweight.

That's why I proposed multiple definitions of the term lightweight. I'm
not looking for a single definition, just trying to use the term to shed
light on things.
    -Olin