Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Looking for (c)lisp examples of mini-languages, that is, DSLs [closed]

Reading well-written code seems to help me learn a language. (At least it worked with C.) [deleting the 'over-specified' part of the question]

I'm interested in particular in lisp's reputation as a language suited to creating a mini-language or DSL specific to a problem. The program ought to be open-source, of course, and available over the web, preferably.

I've Googled and found this example:

http://lispm.dyndns.org/news?ID=NEWS-2005-07-08-1

Anybody have another? (And, yes, I will continue reading "Practical Common Lisp".)

After 11 hours (only 11 hours!): Thanks, everyone. What a wonderful site, and what a bunch of good answers and tips!

like image 906
behindthefall Avatar asked Jun 25 '09 03:06

behindthefall


People also ask

Is Python a Lisp language?

Basically, Python can be seen as a dialect of Lisp with “traditional” syntax …

What is Lisp in C?

Lisp, an acronym for list processing, is a functional programming language that was designed for easy manipulation of data strings. As one of the oldest programming languages still in use, Lisp offers several different dialects and has influenced the development of other languages.

What specific features of dynamic languages make them useful as DSLs?

Other features that usually appear in dynamic languages are also useful when building DSLs: closures, macros, and duck typing. The major advantage of an internal DSL is that it takes on all the power of the language it's written for.

What is Lisp used for today?

At present, the best-known dialects are Common Lisp, Scheme, Racket and Clojure. Lisp became the “pathfinder” for many ideas which found application in the modern programming languages: tree-like structures, dynamic typing, higher-order functions and many others.


3 Answers

I'm kind of lazy to find the links, but you should be able to 'Google'/'Bing' it. The following list mentions very different ways to embed languages and very different embedded languages.

  • ITERATE for iterations
  • System/Module/File description in 'defsystem's, an example would be ASDF
  • infix readmacro
  • define-application-frame in CLIM for specifying user interfaces
  • embedded Lispified SQL queries in LispWorks and CLSQL
  • Knowledgeworks of LispWorks: logic language with rules, queries, ...
  • embedded Prolog in Allegro CL
  • embedded HTML in various forms
  • XMLisp, integrates XML and Lisp
  • Screamer for non-deterministic programming
  • PWGL, visual programming for composing music

Note that there are simple embedded languages and really complex ones that are providing whole new paradigms like Prolog, Screamer, CORBA, ...

like image 45
Rainer Joswig Avatar answered Oct 30 '22 21:10

Rainer Joswig


If you haven't taken a look at it yet, the book Practical Common Lisp is available free online and has several example projects.

like image 30
totorocat Avatar answered Oct 30 '22 21:10

totorocat


I feel your constraints are over-specified:

small enough to comprehend, varied enough to show off most of (c)lisp's tricks and features without being opaque (the 'well-written' part of the wish), and independent of other packages.

Common Lisp is a huge language, and the power set that emerges when you combine the language elements is much larger. You can't have a small program showing "most tricks" in CL.

There are also many concepts that you will find alien when you learn CL coming from another language. As such CL is less about tricks but more about its fundamental paradigms.

My suggestion is to read up on it a bit first and then start building your own programs or looking into open source code.

Edi Weitz for example usually writes good code. Check out his projects at http://www.weitz.de/.

And now go read PCL. :)

like image 111
Leslie P. Polzer Avatar answered Oct 30 '22 22:10

Leslie P. Polzer