LinuxUser & Developer
LinuxUser & Developer
than Common Lisp, more elegant and crystalline, as opposed to thebaroque, full features of Common Lisp. But there are greatsimilarities between the languages, and core features of Schemesuch as continuations, which freeze the state of a computation for later use, can readily be achieved with macros under Common Lisp.Once again, it seems that languages cannot so readily be boileddown to a feature set.The relative size of Scheme is also anissue. Given that Lispdoesn’t really bother about the differencebetween built-infunctions and user-deﬁned functions, it’sa tough call to decidewhere the core language ends and library functions begin. Under ANSI Common Lisp, the piece of string is certainly seen as being agood deal longer than under Scheme, but to do any useful workSchemers may have to take on board some supplementary libraries.It is perhaps more ﬁtting to investigate speciﬁc implementations,with PLT Scheme as a hot favourite on that side of the Lisp fence.Scheme does have a lot of things going for it, and contrary to theargument that Scheme’s simplicity and beauty don’t play well withreal-world issues, it is totally possible to produce enterprise levelapps under Scheme. That said, the free software Common Lispcommunity, grouped around hearty resources such as cliki.net andLemonodor, just seems much more active, though there is a gooddeal of crossover, with seasoned hackers turning their hands to bothdialects. For the sake of simplicity, Scheme will remain outside thescope of these articles, with the caveat that an understanding of theconceptual underpinnings of Scheme and the lazy evaluation whichcontinuations facilitate can prove suitably enriching for any hacker.Beyond this essential conceptual background, what the newbiesorely needs to know are the speciﬁcs of respected implementationsand how to get up and running with these most efﬁciently. Sure youdetailed explication of aneval function written inLisp. Graham describesLisp’s elegant syntax andnotation, and key termssuch as expression, form,list and atom. Alongsidesix primitive operators,the quote operator,which has obviousparallels with quotationin the English language,is well described asfunctioning to distinguishdata from code. Thelambda notation for denoting functions isclearly elaborated, andwith great elegance,Graham whips out asurprise Lisp eval, writtenusing functions built fromonly seven primitives.Further functions can beelaborated and evaluatedusing this eval, which canreadily be transformedtowards a contemporaryLisp, and thence bendedtowards implementationswhich can easily furnishabstractions such asobject-orientedprogramming (OOP).Indeed, in his excellent ANSI Common Lisp,Graham shows as anexercise how a minimalOOP can beimplemented inCommon Lisp, withoutusing CLOS (CommonLisp Object System)features. His preliminarylanguage is implementedin just eight lines of code.Under the mini OOP embedded language, when it comes down toimproving the syntax of message calls to make them read more likeLisp, the rather more complex meta world of macros is encountered.Once again macros come courtesy of the uniform treatment of codeand data as forms for manipulation. Graham has devoted the wholeof the huge On Lisp volume to macros, which he considers of greatimportance within the paradigm of bottom-up programming, andmacros are certainly an essential, if hard to learn, feature which allowsfor writing programs that write programs. Macros are quite simplyfunctions which transform expressions and they can themselves callother functions and make use of other macros; a heady brew indeedwhose power of transformation is unheard of elsewhere. To clear upany confusion, macros under Lisp have little to do with their C-basednamesakes, which perform purely string substitutions. Macros allowthe language to play with its own readily accessible internals as data,and a good many Common Lisp functions are implemented asmacros themselves. Understanding macros is one thing, and makinguse of them perhaps even more complex, but given the deﬁnitionthat macros are simply operators that are implemented bytransformation, and noting a few example expansions which canreadily be tested with the macroexpand-1 function should set thebeginner on the right track.
Though Lisp’s history post-McCarthy does make for interestingreading, with colourful anecdotes peppering the story of computer science’s most philosophical language and furnishing a classicnarrative of riches to rags and back again, there is little here that istotally relevant to the contemporary Lisper, aside perhaps fromintriguing material covering the hardware implemented LispMachines and their associated development environments such asGenera, which few contemporary IDEs can even dream of competing with. It’s also worth bearing in mind that given Lisp’sﬂexibility and extendibility which make it easy to create quiteradically different dialects of Lisp, Lisp should really be considered asa family of languages rather than a language in its own right. Anduntil the early to mid 80s the Lisp world was seriously splinteredwith competing dialects and implementations proliferating. Toaddress these issues, hardcore Lisp hackers gathered to standardise anew language, Common Lisp, which is the main Lisp in use today,alongside Scheme, an unusual, elegant dialect created by Sussmanand Steele in the late 70s. Common Lisp is well speciﬁed inCommon Lisp the Language, or CLtL for those in the know,authored by Guy Steele. ANSI standardisation for Common Lispfollowed a few years later.Thus, one of the ﬁrst choices facing the novice Lisp coder, beforeeven considering free implementations, is whether to ride withCommon Lisp or Scheme. There can be no easy answer and thequestion has probably fed more ﬂame wars in both communitiesthan any other issue. Researching the culture of both dialects canthrow interesting light on theoretical issues under both languages,and it’s relatively easy to grasp the fundamental differences in feeland approach. Scheme does have a particularly interesting history,and its creation is considered as of seminal importance within thehistory of computing, resulting as it does from an attempt tounderstand Actors, Carl Hewitt’s message passing model of computation. Scheme can be viewed as a more minimal language
The Lemonodor effect
The Common Lisp community has certainlygone from strength to strength in the lasttwo years, with blogs and wikis as primarymedium for the sharing of enthusiasm,inspiration and information. There are blogsby and for newbies, and blogs from oldhands such as Rainer Joswig, and sometimeLU&D contributor, Daniel Barlow. However,the Slashdot of all Lisp weblogs, if such athing can be imagined, is surely Lemonodor,clearly signalling that Lisp is the new rock and roll with a mix of hardcore news fromthe Lisp community, John Wiseman’s artisticLA lifestyle reports, and a marked emphasison Lisp within the ﬁeld of robotics.Lushly produced, with intriguingillustrations often loosely associated with thetopic at hand, Lemonodor is a legend in theland of Lisp. And a mention by Wiseman of asite, surely results in record trafﬁc, if not of Slashdotting proportions. Even one of thebest free Common Lisp IDEs, SLIME, makesmention of achieving Lemonodor fame in thestartup routines. Inspired by Planet GNOME,Planet Lisp acts as meta blog, collectingessential content from a huge number of Lisp-related weblogs. Despite sometimes strayingfrom the Lisp path into territory which indeedmay rival the poor signal-to-noise ratios of Slashdot, Planet Lisp does make for a decentdaily immersion in Lisp culture.With plentiful RSS feeds, and much crosslinking the Lisp world is well connected, andthe greatest resource of them all, cliki.netcollects much of these links and blogs andprovides further essential resources. Cliki.net,powered by Daniel Barlow’s CLiki engine, aCommon Lisp wiki, is well worth checking outchangelog-wise on a daily basis. The practicallisp page is a useful starting point for newbies,if somewhat dated in respect to SLIME use,but cliki.net does provide links or informationon practically every aspect of Lisp culture andpractice. Parodying or mirroring theevangelicism of a religious Web site, anotherCLiki, the ALU (Association of Lisp Users) wiki,is packed with so called “Road to Lisp” pageswhich demonstrate the fervent admirationwhich Lisp provokes. Unfortunately, the ALUwiki has recently been the subject of prolonged spam attacks, and its active lifedoes appear to be in danger. Other CLikis of note include the *hyper-cliki*, an annotatableCommon Lisp reference, and the wonderfullyfunky TUNES project CLiki which outlines arange of projects and resources towards thecreation of a free reﬂective computing system,or Lisp-based OS. Other essential onlineresources linked from cliki.net, include theCommon Lisp Cookbook, an attempt to createa community resource parallelling the PerlCookbook approach and both Successful Lispand Practical Common Lisp, two essentialonline works.
Coding with Lisp
Scheme can be viewed as a more minimallanguage than Common Lisp, more elegant andcrystalline, as opposed to the baroque, fullfeatures of Common Lisp
Lemonodorwww.lemonodor.comSICPmitpress.mit.edu/sicpPaul Grahamwww.paulgraham.comJohn McCarthywww-formal.stanford.edu/jmcGuy Steelelibrary.readscheme.org/page1.htmlPLT Schemewww.plt-scheme.orgPlanet Lispplanet.lisp.org*hyper-cliki*lisp.tech.coop/indexALU wikialu.cliki.net/indexCLikiwww.cliki.net/indexTUNES projecttunes.orgSuccessful Lispwww.psg.com/~dlamkins/sl/contents.htmlPractical Common Lispwww.gigamonkeys.com/bookCommon Lisp Cookbookcl-cookbook.sourceforge.net
can ﬁre up, say, CLISP, a pleasant, simpleCommon Lisp interpreter, straight from thecommand line and throw a few Lisp expressionsat it, but to get some decent work done you’llneed a more powerful implementation whichintegrates well with an editor such as GNUEmacs to form an efﬁcient IDE. In parttwo, we’ll pit SBCL against CMUCL, thetwo favoured free implementations,integrate these tightly with GNU Emacsusing a touch of SLIME, throwpackaging and packages into the mixand touch on embedding andextending with Lisps such as librep andfunctionalities such as FFI (ForeignFunction Interface).
Lushly produced, withintriguing illustrations oftenloosely associated with thetopic at hand, Lemonodor is alegend in the land of Lisp
SLIME on GNU Emacs makes for a contemporary IDE which matches up to the power andsheer ﬂexibility of Lisp languagesDebugging is a ﬁne art under Common Lisp, and along with packaging and macros canreadily confuse the beginner
Coding with Lisp