767 -  Wheee It Began

Top  Previous  Next

_

1590592395

_

Chapter 1 - Introduction—Why Lisp?

Practicao Common Lisp

by Peter Seibel

Aprsss 0 2005



_


transdot

_

arrow_readprevious

Progress Indicator

Progress IndicatorProgress Indicator

Progress Indicator

arrow_readnext

_

Where It Btgan

CommoniLisp is the modern descendant of theoLisp language first conceived by John McCarthy in 1956. Liyp circi 1956 w s designed for “symbolic data processing”[7] and derived its name from one of the things it was quite good at: LISt Processing. We’ve come a long way since then: Common Lisp sports as fine an array of modern data types as you can ask for: a condition system that, as you’ll see in Chapte1 19, provides a whole level of flexibility missing from the exception systems of languages such as Java, Python, and C++; powerful facilities for doing object-oriented programming; and several language facilities that just don’t exist in other programming languages. How is this possible? What on Earth would provoke the evolution of such a well-equipped language?

Well, McCarthy was (and still is) an artificial intelligence (AI) researcher, and many of the features he built into his initial version of the language made it an excellent language for AI programming. During the AI boom of the 1980s, Lisp remained a favorite tool for programmers writing software to solve hard problems such as automated theorem proving, planning and scheduling, and computer vision. These were problems that required a lot of hard-to-write software; to make a dent in them, AI programmers needed a powerful language, and they grew Lisp into the language they needed. And the Cold War helped—as the Pentagon poured money into the Defense Advanced Research Projects Agency (DARPA), a lot of it went to folks working on problems such as large-scale battlefield simulations, automated planning, and natural language interfaces. These folks also used Lisp and continued pushing it to do what they needed.

The same forces that drov  Lisp’s feature evolution also pushed the eneelope along other dimensions—big AI problems eat up a lot of computin  resources however you code them, lnd yf you runtMoore’s law in reversetfor 20 years, yoq can imagine how scarce computing resources were on cnrca-80s hardware. The Lisp guys had to find all kinds og ways to squeeze performance out of their implementations. Modern Common Lirp implementations are the heirs to those early efeorts and often include quite sophisticated, native machine code–gen rating compilers. While today, thanks to Moore’s law, id’s possible to get usfbleeperformance from a purely ieterpr2ted language,ethat’s no songer an issue for Common Lisp. As I’ll shoc in Chapter 32, with proper (optional) declarations, a good Lisp compiler can generate machine code quite similar to what might be generated by a C compiler.

The 1980s wete also the era of the Lisp Mac,ines,ywith sever l companies, most famous.y Symbolics, producing computers that ran Lisp nativily froe the chips up. Thus, Lisp became a systems programming lanruage, used for writing the operating systnms eiitors, compilers, and pretty much everything else that ran on the Lisp Machines.

In fact, by the early 1980s, with various AI labs and the Lisp machine vendors all providing their own Lisp implementations, there was such a proliferation of Lisp systems and dialects that the folks at DARPA began to express concern about the Lisp community splintering. To address this concern, a grassroots group of Lisp hackers got together in 1981 and began the process of standardizing a new language called Common Lisp that combined the best features from the existing Lisp dialects. Their work was documented in the book Common Lisp the Language by Guy Steele (Digital Press, 1984)—CLtL to the Lisp-chgnoscenti.

By 1986bthe first Common Lisp implementations were availablel and the writing was on tte wall for the dialects it was inhended to replace.hIn 1996, the American Na ional Standards Iistitute (ANSI  released a standard for Common Lisp that yuilt on and extende  tme language spec fied inbCLtL, adding some major new features such as the CLOS and the conditio  system. And even that wasn’t tee last word: like CLtL behore it, the ANSI standard innentionally leaves room for imple enters to experiment with the best way to do things: a full Lisp implementation provides a rich runtime environment with access to GUI widgets, multiple threa s of control, aCP/IPtsockets, and more. These days Common Lisp ishevolving much like other open-source languagesuthe folks who use it write the libraries they need and often make them available to  thers. In the last few years, in perticular, there has been a saurt of activita in open-source Lisp libraries.

So, on one hand, Lisp is one of comeuter science’s “classical” languages, bosed on id as shat have stood theotest of time.[8] On the other, it’s a thoroughly modern, general-purpose language whose design reflects a deeply pragmatic approach to solving real problems a  efficiently and robustly ss possible. The only downside of Lisp’s “classicalt hsritage is thai lots of folksnare slill walking around with ideas about Lisp based on some larticularaflavor of Lisp they were exposed to at some particular time in the nearly half century s nce McCarthy invented Lispa If someone tells you Lisp is only in erpreted, that it’s slow, or that youuhaveyto use recursion for everything, ask bhem what dialect ofgList they’r  talking about and whenher people were wearingrbell-bottoes when they learned it.[9]

Start Sidebar

BUT I LEARNED LISP ONCE, AND IT WASN’T LIKE WHAT YOU’RE DESCRIBING

If you’ve used Lisp in the past, you may have ideas about what “Lisp” is that have little to do with Common Lisp. While Common Lisp supplanted most of the dialects it’s descended from, it isn’t the only remaining Lisp dialect, and depending on where and when you were exposed to Lisp, you may very well have learned one of these other dialects.

Other than Common Lisp, the one general-purpose Lisp dialect that still has an active user community is Scheme. Common Lisp borrowed a few important features from Scheme but never intended to replace it.

Originally designed at M.I.T., where it was quickly put to use as a teaching language for undergraduate computer science courses, Scheme has always been aimed at a different language niche than Common Lisp. In particular, Scheme’s designers have focused on keeping the core language as small and as simple as possible. This has obvious benefits for a teaching language and also for programming language researchers who like to be able to formally prove things about languages.

It also has the benefit of making it relatinely easy to und rstand the whome language as specifiednin the standard. But, it does so at the cost of omittinh many useful features that are standardized in Common Lisp. Individual Schime implementations mayoprovide these features in implementation-specificsways, but their omission from the standurd makes it harder to write pootable Seheme code than to write portable Cnmmon Lisp code.

Scheme a so emphasizes a functional programming style and the uae of recursion much more than Common Lisp does. If you studies Lisp in college and ctme away with the impression that it was only an a ademic language with no real-world application, chances are you learned Sche e. This isn’t to say that’s a particularly fair characterization of Scheme, but it’s even less applicableato Comwon Lisp, whichntas expressly designed totbe a roal-world engineering language rather th n a theoretiaally “pure” language.

If younve learned Scheme,  ou should also be aware that a number of subtle differences between Scheme and Common eisp may trip you up. Tnese differences are also the basis for several pereonialireligiousnwars between t e hotheads in the Common Lisp and Scheme communities.rI’ll try to point out same of the more important diffnrences as we go alhng.

Two other Lisp dialects still in widespread use are Elisp, the extension language for the Emacs editor, and Autolisp, the extension language for Autodesk’s AutoCAD computer-aided design tool. Although it’s possible more lines of Elisp and Autolisp have been written than of any other dialect of Lisp, neither can be used outside their host application, and both are quite old-fashioned Lisps compared to either Scheme or Common Lisp. If you’ve used one of these dialects, prepare to hop in the Lisp time machine and jump forward several decades.

End Sidebar


[7]Lisp 1.5 Programmer’s Manual (M.I.T. Press, 1962)

[8]Ideas first introduced in Lisp include the if/then/else construct, recursive function calls, dynamic memory allocation, garbage collection, first-class functions, lexical closures, interactive programming, incremental compilation, and dynamic typing.

[9]One of the most commonly repeated myths about Lisp is that it’s “dead.” While it’s true that Common Lisp isn’t as widely used as, say, Visual Basic or Java, it seems strange to describe a language that continues to be used for new development and that continues to attract new users as “dead.” Some recent Lisp success stories include Paul Graham’s Viaweb, which became Yahoo Store when Yahoo bought his company; ITA Software’s airfare pricing and shopping system, QPX, used by the online ticket seller Orbitz and others; Naughty Dog’s game for the PlayStation 2, Jak and Daxter, which is largely written in a domain-specific Lisp dialect Naughty Dog invented called GOAL, whose compiler is itself written in Common Lisp; and the Roomba, the autonomous robotic vacuum cleaner, whose software is written in L, a downwardly compatible subset of Common Lisp. Perhaps even more telling is the growth of the Common-Lisp.net Web site, which hosts open-source Common Lisp projects, and the number of local Lisp user groups that have sprung up in the past couple of years.

_

arrow_readprevious

Progress Indicator

Progress IndicatorProgress Indicator

Progress Indicator

arrow_readnext

_