Practical Common Lisp 617
Practical Common Lisp | |
author | Peter Seibel, Gary Cornell (Editor) |
pages | 500 |
publisher | Apress |
rating | 8 |
reviewer | Frank Buss |
ISBN | 1590592395 |
summary | A book for learning and using Common Lisp |
Unlike other good books about Lisp, which are focused on a specific domain, like AI (such as Paradigms of Artificial Intelligence Programming ) or basic computer science (for example Structure and Interpretation of Computer Programs for the Lisp-like language Scheme), this book focuses on solving real-world problems in Common Lisp, like web programming, testing etc., after introducing the language by examples in the first chapters. I started with Lisp half an year ago, and it has helped me a lot in learning it. But even if you already know Lisp, this book may be useful for you, because it has a fresh view on the language and the examples in the later chapters are usable in your day-to-day work as a programmer.
The first chapter tells you something about the author (he was a good Java programmer before starting with Lisp) and the history of Lisp and Lisp dialects like Scheme. The next chapters are a tour through all Lisp features, written in easy-to-understand steps, beginning with the installation of a Lisp system and an introduction to the interactive REPL. You don't need any experience in other languages to understand it.
The general concept throughout is to explain a feature first, then show an example of how to use it, with detailed discussion of what the example does and possible pitfalls. A nice example is the APPEND function, which does not copy the last argument:
The reason most list functions are written functionally is it allows them to return results that share cons cells with their arguments. To take a concrete example, the function APPEND takes any number of list arguments and returns a new list containing the elements of all its arguments. For instance:(append (list 1 2) (list 3 4)) ==> (1 2 3 4)From a functional point of view, APPEND's job is to return the list (1 2 3 4) without modifying any of the cons cells in the lists (1 2) and (3 4). One obvious way to achieve that goal is to create a completely new list consisting of four new cons cells. However, that's more work than is necessary. Instead, APPEND actually makes only two new cons cells to hold the values 1 and 2, linking them together and pointing the CDR of the second cons cell at the head of the last argument, the list (3 4). It then returns the cons cell containing the 1. None of the original cons cells has been modified, and the result is indeed the list (1 2 3 4). The only wrinkle is that the list returned by APPEND shares some cons cells with the list (3 4). The resulting structure looks like this:
In general, APPEND must copy all but its last argument, but it can always return a result that shares structure with the last argument.
In chapter 9, the first larger practical example is developed, a unit testing framework (like JUnit), which is easy to use and to enhance.
Certain Lisp implementation behaviors can be confusing, such as those for for building pathnames. The pathname concept in Lisp is very abstract, leading to different choices in different implementations. This is no problem if you use only one implementation, but chapter 15 develops a portable pathname library, which works on many implementations. By doing this, it shows you how to write portable Lisp code, using different code for different implementations with reader macros.
After an introduction to the Common Lisp Object System (CLOS) and a few practical FORMAT recipes (the printf for Lisp, but more powerful), chapter 19, "Beyond Exception Handling: Conditions and Restarts", is really useful. The exception handling in Lisp (called "condition system") is more general than other exeption systems: In Lisp you can define restarts where you generate an exception and the exeption handler can call these restarts to continue the program. After reading this chapter, you'll never again want to use the restricted version of Java or C++ exception handling.
Chapters 23 to 31 show real world examples: a spam filter, parsing binary files, an ID3 parser, Web programming with AllegroServe, an MP3 database, a Shoutcast server, an MP3 browser and an HTML generation library with interpreter and compiler. If you ever thought that Lisp is an old language, only used for AI research, these chapters prove you wrong: Especially the binary files parser shows you, how you can extend the language with macros for implementing binary file readers, which looks nearly as clear and compact as the plain text binary file description itself. I'm using some of the ideas for a Macromedia Flash SWF file reader/writer I'm currently writing. Take a look at my Web page for my currently published Lisp projects.
The Web programming chapters demonstrates how to use a dynamic approach for generating web pages. You just start a Web server in your Lisp environment; then you can publish static Web pages or define functions, which are called when the page is requested by a browser. The author demonstrates how to define dynamic pages with formulars in Lisp and Lisp HTML generators.
After reading Practical Common Lisp, you will know most of Common Lisp and how to write real-world programs with it. Some special features, like set-dispatch-macro-character, or using one of the non-standard GUI libraries, are not explained, but it is easy to learn the rest of Common Lisp and to use other Lisp libraries, with the knowledge gained from this book.
You can purchase Practical Common Lisp from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page
I'm sorry, (Score:3, Funny)
Re:I'm sorry, (Score:4, Funny)
Things might have been different (Score:5, Insightful)
It is such a shame that C-based languages took over the computer world in the 1980's. If we had followed the Lisp path instead things might be so much better. C++ with all of the template, RTTI, and STL grunge is such a half-assed imitation of powerful Lisp constructs that have been perfected for 15 years. I won't even go into Java, Python, C#, PHP. What a waste. I suggest you non-Lisp programmers grab a copy of SICP [mit.edu] and start over.
My first exposure to list ( and a mirror of book ) (Score:4, Informative)
I never revisited Lisp. Perhaps now that I have the book, I'll give it a shot.
You can download a copy here [networkmirror.com] if the main site is too busy.
~
Re:My first exposure to list ( and a mirror of boo (Score:4, Informative)
Recent interest in Haskell has exploded because of the implementation of Pugs [pugscode.org] in GHC. Pugs is a compiler / interpreter prototype for Perl 6, which is also a functional language, borrowing many concepts from LISP and smalltalk (as well as just about every other popular research or practical programming language).
Re:My first exposure to list ( and a mirror of boo (Score:4, Insightful)
Re:My first exposure to list ( and a mirror of boo (Score:4, Informative)
"Lisp can generally be made faster than Haskell"
Certainly, and I'm not saying Haskell makes a good language for day-to-day coding. I'm just saying that it's a good place to learn functional programming.
"Haskell uses lazy evaluation. Lisp uses strict evaluation unless you explicitly ask for lazy evaluation."
For those who do not understand this point, it's worth going into. In C, when you say:
c = foo() + bar();
you call functioan foo and bar, add their results, and store that result in c. In Haskell a similar construct would store in c the information required to call foo and bar at a later time when/if you needed the value of c, but of course, if you just add c to another value, you just create a more complex result, you still don't invoke foo or bar.
This is a very powerful concept, but can also lead to surprising results if you are used to programming in non-lazy languages.
Re:My first exposure to list ( and a mirror of boo (Score:3, Informative)
Re:My first exposure to list ( and a mirror of boo (Score:5, Funny)
Whenever I think of Lisp, I'm transported back in time to 1975 where I'm trying (unsuccessfully) to learn this as my 2nd programming language after Fortran IV (on a DECsystem-10, no less).
I've heard it said that someone just learning how to program can pick up Lisp in a day. If you happen to already know Fortran, it will take two days.
LISP is amazing. (Score:5, Interesting)
However, LISP can also be hard to learn. The function names don't make sense to most people who have been raised on higher-level (1980s+) languages. I mean, 'car' to grab the first element of a list, and 'cdr' to grab all the others? It can get downright confusing sometimes.
Re:LISP is amazing. (Score:5, Funny)
But it leads to hilarious bumper stickers, such as: "My other car is a cdr"
Re:LISP is amazing. (Score:3, Funny)
Re:LISP is amazing. (Score:3, Informative)
Common Lisp has first [lispworks.com] and rest [lispworks.com] as accessors for lists. Many Lispers consider it good style to use them when treating conses as lists and to use car/cdr when treating conses as binary trees.
Re:LISP is amazing. (Score:3, Informative)
Re:LISP is amazing. (Score:2, Funny)
Tcl/Tk RULES!!! (Score:2)
I predict this comment lasts 12 minutes before being modded down to -1. WHY DO THE MODERATORS HATE AMERICA?
Re:Tcl/Tk RULES!!! (Score:3, Insightful)
Re:Tcl/Tk RULES!!! (Score:4, Funny)
Which would you rather have, a syntax error where indicating the code is faulty, or a silent semantics error?
Although (ahem) uh, the possibility of the former doesn't preclude the latter, but, uh, please observe the authoratative manner in which I wave my hands!
Re:Tcl/Tk RULES!!! (Score:3, Insightful)
Personally, OOGG feel any language where "value of variable" needs $ notation is severely brain-damaged. Absolute opposite of abstraction.
Re:LISP is amazing. (Score:4, Informative)
(remove-if-not #'oddp list-of-numbers)
That returns a list of all odd numbers in a list of numbers. With this sort of a difference in ease of use, why are you comparing Lisp to assembly language? My guess is that you're just talking out your ass.
That's not what car and cdr are for... (Score:5, Informative)
Linked lists are just one data structure that you can implement with cons cells. You can also implement a stack, queue, binary-tree, association-list, etc...
If your are using "cons cells" in your program, use car and cdr.
If you are using lists that are implemented via cons cells use first and rest.
If you are using a stack use push and pop.
And so on...
In other words:
CL-USER> (car (cons 1 2))
1
CL-USER> (cdr (cons 1 2))
2
CL-USER> (first (list 1 2 3))
1
CL-USER> (rest (list 1 2 3))
(2 3)
Justin Dubs
Lisp's problem (Score:3, Interesting)
The Lisp aspect that Lisp lovers (like me) tend to like most is in the most fundamental notions of the "idea of Lisp". A very small toolbox of ideas that are combinable in an amazingly flexible way, allowing a layering of totally customizable abstraction
Re:LISP is amazing. (Score:2, Funny)
Re:LISP is amazing. (Score:2)
I used LISP in an AI class. Seemed very interesting, and definitely useful for some applications. I almost wish I had done more with it. Almost. And yeah, I didn't learn about 'first' and 'rest' in that class, either.
Re:LISP is amazing. (Score:2, Informative)
Full blown macros are still beyond the reach of python I believe. I use these all the time and any language without LISP macros feels like I'm back in high school doing endless exercises over things I already know. Other languages talk about patterns and abstraction but their idea of this pales next to what can be done in LISP.
I'd elaborate but people attached to their own languages won't believe.
Re:LISP is amazing. (Score:3, Interesting)
(html (:ul (dolist (item stuff)) (html (:li item))))
(Sorry I had to put that on one line, but Slashdot doesn't handle code indentation very well.)
This HTML generation stuff is very useful, and it's pretty difficult to make without using macros. Also, this compiles down to efficient code, rathe
Re:LISP is amazing. (Score:5, Informative)
try {
methodCall();
} catch (Exception e){
} finally {
otherMethodCall();
}
Now let's say I wanted something like try/catch only specifically geared toward database transactions. I want it to look like this:
tran {
} rollback {
} success {
}
You just can't do that. Sure you could get similar functionality through the use of try/catch and a bunch of helper functions, but you can't integrate it straight into the language itself. You can only add to the language's library. In LISP, there is no real difference.
I can implement a "tran" macro so I can do things like:
(tran (withdraw 25.00 from-account)
(deposit 25.00 to-account)
This particular instance is my favorite example. It may not seem like a big deal, but I have hundreds of these things that aren't a big deal in my code. If I think something can be done a better way in the language I can add it.
The tran macro would be expanded during runtime to something that looks more like:
(begin-tran)
(withdraw...)
(deposit...)
(end
A more complicated version of this macro could take into account nested versions of itself.
Someone will say that try/catch can be made to accomplish what I want. Yes it can. Those same people won't admit however that Perl can be bent to do what Java does.
There is a lot of writing about how great it is to have macro expansion at runtime. That was always meaningless to me until I latched on to that "tran" example above. All of a sudden I realized I wasn't bound to passing values (or references to values, essentially the same thing) to a function. Now I could pass whole chunks of code around. This struck me as such a right thing to do. I'd always been bugged that all the Java consultants around me were memorizing patterns. If something is a pattern, shouldn't the computer be doing it? LISP told me that yes, the computer should be doing it, not that I should be writing pages of patterned code.
It took me a year of talking to one of the guys I worked with where I explained macros to him. Six months after I left that place we went to lunch and he told me he finally saw the light as he was cutting and pasting some in one of his J2EE programs.
If you've ever been looking at something in the language (not the library) and wished that it worked just like that, only different, that is one case where you use a macro.
Re:LISP is amazing. (Score:3, Insightful)
It can be handy during debugging. I don't recommend using cdaadr (et al) in production code.
They just couldn't write a parser for shit so they took the old adage "If in doubt, bracket" far too seriously and made it compulsory.
Wrong. Lisp has parentheses in specific places, leaving no doubt about where you're supposed to put them. Adding excessive parentheses to Lisp code changes it.
And the parens and the code-data equivalence do have a
Re:LISP is amazing. (Score:5, Insightful)
I'm not certain what you've learned, but it certainly isn't "a lot". Certainly not about programming language design in general, and Lisp in particular. If you had even taken the time to read about just the history and design of Lisp, which is accessible to even the layman, you'd be able to post a more insightful comment than you just did. Why don't you try that, at minimum, since you are obviously uninterested and/or incapable of learning the technical apsects of the language.
As for Lisp being an experimental language, nothing could be farther than the truth. Lisp is a language that was several decades ahead of its time in design, functionality and capability. Everything else is just now catching up. Evidence all the effort to fold in Lispy features into Python, Perl, Ruby, etc., etc. The thing is, these languages' designers are trying to bolt the features into their language after the fact. While Lisp Just Works.
So, since you raised the topic, what's the answer? What would you have us "move on" to?
engineering tradeoffs (Score:3, Insightful)
Engineering is about making tradeoffs--something that the designers of Lisp did not understand. If you try to create a completely general language with completely general language constructs, you try to standardize it, and you try to also make it fast, something has to give. And the thing that gives is development time.
Python, Perl, and Ruby can afford to implement lots of Lispy
Re:engineering tradeoffs (Score:3, Insightful)
Yeah, it's a terrible shame that all those incredibly intelligent mathematicians and engineers behind Lisp didn't have cahiha to advise them about the concept of engineering tradeoffs.
Lots of Lisp things??? Tell you what. How about you tell me just two. And you can use "garbage collection" if you can't think of anything else, but I'll think it prett
Re:engineering tradeoffs (Score:4, Informative)
CL has some problems with the Meta Object Protocol (MOP), which is used for reflection and to modify the object system. It's not standard, but it's supported by all major Lisp implementations---and they usually have small differences, most prominently what package they put it in. Is it in the MOP package? Or perhaps the SB-PCL package? In order to make portable code that uses the MOP, you need a compatibility layer like Closer [common-lisp.net] or MOPP or CLIM-MOP.
That said, once you have all the compatibility code in place you can do amazing things with the MOP. I co-wrote a graphical object inspector that made heavy use of Lisp's introspection abilities, and Pascal Costanza added Aspect-oriented programming to Common Lisp with AspectL [common-lisp.net].
Re:engineering tradeoffs (Score:3, Interesting)
They did, actually. I told them (as did lots of other people) even back when Lisp was more hyped up than Java has ever been and people were dropping $100k for a single Lisp-based workstation. They just weren't listening. The result of their lack of good engineering sense and arrogance was the demise of Lisp and the predic
Re:LISP is amazing. (Score:4, Insightful)
the mnemonics describe the implementation of cons cells (the basic elements from which lists are constructed, but which also can be used for other purposes). they actually are the IBM 704 assembler instructions to access the componenets of cons cells. Most (all?) lisp implementations provide other mnemonics tailored for the particular datastructures, but Lisp has a tradition of backwards compatibility, so the car and cdr mnmonics were kept in
Besides which, just look at modern functional languages; its obvious that the excessive parenthisation in LISP is totally uneccesary.
the original spec of lisp (the lisp1.5 manual) used both the current syntax and a more algol like syntax, but the first implementation was done in the parenthesized syntax. as one of the texts on the history of lisp explains, the suitability of the s-expression syntax for mcro processing was discovered quite early and convinced practically all lisp users not to bother with a more traditional surface syntax, even though there were a few attempts (one of the first i remember was something called Lisp2 done at Stanford in the early to mid 1960s. it looke very much like algol.
They just couldn't write a parser for shit so they took the old adage "If in doubt, bracket" far too seriously and made it compulsory.
bull.
Re:LISP is amazing. (Score:3, Informative)
This is not a troll, but a query... (Score:5, Interesting)
Re:This is not a troll, but a query... (Score:5, Insightful)
2) takes bottom-up programming to the extreme. Really does help, but takes a while to get used to.
3) Much better to develop in...interact with the interpreter, compile individual functions and run them, change variables in a running image...
Re:This is not a troll, but a query... (Score:5, Interesting)
Common LISP is a very old language (not as old as LISP, of course), full of the same kinds of pitfalls that any language its age or older shows (e.g. C, FORTRAN, etc). It is best to start with younger languages and work your way back.
Re:This is not a troll, but a query... (Score:3, Interesting)
This will get you familiar with some of the concepts of lists, atoms, quoting and order of evaluation. There really isn't much to a language like LISP or Scheme. The basic building blocks are few, it's largely a matter of where the line between language and library is drawn.
The
Re:This is not a troll, but a query... (Score:4, Insightful)
For example, Qi is built on Common Lisp and claims to have "the most powerful type system of any existing functional language." I think it's a fancy academic language, but the win is that you can combine it with the hardened industrial features of Common Lisp.
Comment removed (Score:4, Interesting)
Re:This is not a troll, but a query... (Score:4, Insightful)
As for starting with younger languages... cripes. Common Lisp became an ANSI standard in 1994. It continues to evolve and has two commercial companies behind it, and many open source projects.
Re:This is not a troll, but a query... (Score:5, Funny)
2. You can think of yourself as extra cool.
3. It'll get you laid.
Re:This is not a troll, but a query... (Score:2)
Re:This is not a troll, but a query... (Score:2)
Re:This is not a troll, but a query... (Score:5, Insightful)
- Eric Raymond, "How to Become a Hacker"
Re:This is not a troll, but a query... (Score:2)
Here's an interesting snippet:
The nearest thing Common Lisp has to a motto is the koan-like description, "the programmable programming language." While cryptic, that description gets at the root of the biggest advantage Common Lisp still has over other languages. More than any other language, Common Lisp follows the philosophy that what's good for the language's designer is good for the language's users. Thus, when you're programming in Common Lisp, you almost never
Re:This is not a troll, but a query... (Score:2, Funny)
Re:This is not a troll, but a query... (Score:3, Informative)
Advantage is much fast code creation, with run-time safety, and option to get efficiency later.
2. Well thought out data structures with nice language support.
For example, ability to inline arrays and lists and symbols very conveniently in code. Ability to read complicated data structures (data files) without writing parsers, that are easier for humans to interpret a
Re:This is not a troll, but a query... (Score:2)
It's sufficiently different from other languages outside the Lisp family so that learning it is an entertaining exercise.
Re:This is not a troll, but a query... (Score:2, Informative)
1. Opened my eyes on how recursion should really be used, and improved my software design abilities a lot, since you're encouraged on writing new small functions and then put pieces together. LISP is built on LISP, and I found it a really educative language (and that's the same reason because I dislike Java, with its too-easy-to-become spaghetti-code). Moreover, in LISP it isn't just that a program has to work; it has to do it in an elegant way.
Re:This is not a troll, but a query... (Score:3, Informative)
Try here [tech.coop]
Re:This is not a troll, but a query... (Score:3, Informative)
Bacon-and-eggs things to help you write more robust code:
Re:This is not a troll, but a query... (Score:5, Insightful)
Compilers in other languages first need to convert the program into an AST before compiling the code. (this is a bit of an oversimplification, but essentially true.) If you want three reasons, I can explain the repercussions of programming directly in an AST:
Elegance: In Lisp, you don't have to worry about idiosyncracies in the head of the language designers like you do in other languages: You don't have to worry about whether AND has precedence over EQUALS (Delphi programmers know this trap) you don't need to worry when a line needs to end in a semicolon, etc. etc.
Macros: By being an AST, Lisp lets you trick the compiler into thinking it sees other code than is actually there. This is COMPLETELY DIFFERENT than so-called "macros" in other languages- In Lisp you can turn your programming language into basically ANY programming language you want, within the language itself. Read Peter's excellent book or check out this site [lisperati.com] for more info.
Productivity: You can program in the purely-functional style that has been shown to increase programmer productivity by having a property called "referential transparency" and having the easily serializable syntax-expression format. Basically, with Lisp you can analyze/manipulate/automate the bejeezus out of your code very easily, under the mantra "code is data, data is code".
That's what I like about Lisp, anyway...
The advantages of functional languages (Score:5, Insightful)
- C# and Java are more readable than C++
- At the end of this list are functional programming languages.
If you can read source more easily, then maintainability will be better. Most projects maintain code, they write new code less often.
This article [paulgraham.com] will tell you why you should be interested in functional programming languages (this link is about Lisp). If you're smart and open minded, you will be convinced.
The best functional languages are Haskell [haskell.org] and Erlang [erlang.org] (click "next" at the bottom of the page). But like the review and link indicate, there's actual value to learning Lisp.
However, the book review is much too in-depth and has jargon.
A simpler example: with Java you prevent bugs by static typing variables, example:
int numberOfTries = 3;
If you later try to fill "numberOfTries" with a string, the compiler will warn you of a bug and you'll have prevented it. The Java compiler makes it a rule that you have to give a type to your variable so your code quality will be higher (fewer bugs).
With Haskell, you don't have to type int. Haskell will figure out the type for you, you get the benefit of preventing bugs with the convenience of not having to type variables. There are other good features like that in functional programming languages.
You could say that every language puts restrictions on what the programmer can do. I mean writing the source code is bottlenecked by the rules of the language (every variable should have a type. You can't do this/that etc.) so that the resulting code AUTOMATICALLY has fewer bugs. Well the amount of source "laws" in functional languages is much lower than in C++ and Java. This means that there is less to remember for a programmer and there is less chance for rules to conflict/interact with each other (in Java you can't use certain variable types in static classes = another meta rule to remember).
Besides having less rules to remember and take into consideration. The functional languages have also chosen the best "laws" to follow. I mean that if you follow the source laws of Java, it's still relatively easy to produce buggy programs, with functional languages it's harder to produce implementation bugs (thinking bugs are always possible but that's your problem).
The only problems with functional programming languages is that the rules which govern source code are very good, but also very different from the rules in traditional programming languages. It might seem like thinking upside down/backwards for people already familiar with procedural languages. Another problem is that because of humans sticking to what they know, the libraries of the functional languages aren't as extensive as those of Java for example. This means that you'll have to program more parts of your program yourself instead of just using a ready made library which fits the task. This problem is limited by the fact that you can program 10 times faster than in Java and, as I said, maintenance takes up most of the time anyway.
The reason I chose Erlang is because with functional purely functional programming languages like Erlang, you can automatically multitask your program over several CPU's (or this will take minimal effort). Nice feature to have in the future because every CPU manufacturer is going multi-core chip now. The future is in multiprocessor machines, not higher clockspeeds (unless diamond wafers become viable) (Lisp is not purely functional by the way).
Also, you can easily make a server that never goes down with Erlang because your server is automatically clustered. Just plonk down a couple networked PC's and if one dies, the server cluster will just keep on going (a bit slower) until you replaced the power supply of the broken PC.
There are tons of other advantages but, as I said,
Re:The advantages of functional languages (Score:3, Interesting)
Oh man, your post has so many things wrong, I don't know where to start! And I am not trolling, this is serious: dissinformation should be stopped. Read on, please.
C# and Java are more readable than C++
C# and Java are not more readable than C++. If I write C++ code without templates, C++ code is 99% similar to C#/Java.
At the end of this list are functional programming languages
Functional languages are not more readable than C++/C#/Java. ML is bareable, but a long Haskell/Erlang/O'Caml program is
Re:This is not a troll, but a query... (Score:3, Informative)
The deficien
Re:This is not a troll, but a query... (Score:2)
Re:This is not a troll, but a query... (Score:3, Informative)
I've written Perl code that generates more Perl code that is then fed to eval. I've help
Re:This is not a troll, but a query... (Score:3, Interesting)
Here's an example of method g
Re:This is not a troll, but a query... (Score:4, Informative)
A macro basically allows you to rewrite code completely, reaching into the bowels (if necessary) to rip out and mangle what needs to be done.
A basic example is the setf macro. This macro is used for basic assignments: Except, of course, that the first argument can be more than just a simple symbol: So far... so what, right? After all, this "fancy" syntax is just equivalent to the java code: Okay, but how about this - suppose I define some functions dealing with a simple berkeley-style database. Say, (get-from-db dbref keyvalue) and (set-to-db dbref keyvalue newvalue). Now, if I set things up properly, I can make setf work with these functions too, so that the user can do: See how I never explicitly call my database setting function? The last line there never actually calls my get-from-db function - instead, it reaches into the parentheses and rewrites the code so that what happens is a call to set-to-db.
That is, the user never has to know about the set function. Essentially, setf means "here, in the code, where I've said setf, instead go ahead and use whatever the appropriate setter function is for a reference of this type". (when I defined my db functions, I would have to call some macros to tell setf about get-from-db and set-to-db)
Now, for this specific case - creating a unifrom set syntax for any "get"-type function you wish - Ruby has specific explicit syntax support. (just name the "set" method the same as the "get" method but add an "=" to the end of the name) Lisp, however, handles setf through the more general macro mechanism. This means that it can be extended in a bunch of different ways. For example, Lisp defines incf to mean roughly what C's "++" operator does, except again without special language support. (And incf will automaticaly take advantage of the setup I've already done for setf)
In order to do its magic, setf has to be able to access the reference (get-from-db id newval) exactly as I typed it, and has to be able to rip apart and inspect the innards. This is something only a macro can do.
Re:This is not a troll, but a query... (Score:2)
Re:This is not a troll, but a query... (Score:3, Interesting)
Lisp Scheme (Score:4, Funny)
There was a story of a hacker stole one of the A.I code from the government. The code turned out to be the last 100 pages of the program. It was all closing paranthesis. That should sum up how nasty the language is.
Re:Lisp Scheme (Score:2)
Lisp is to scheme, as ,uhmm..., C++ is to Pascal. Apart from the parenthesis-heavy syntax, they have very little in common.
It's the hardest language to write for IMHO just cause it's out of ordinary.
Well, then you haven't looked very far. The hardest language language to write for is probably Malbolge [lscheffer.com].
But there are plenty of more mainstream languages that are harder to write for than lisp. As a matter of fact, most mainstream languages are harder to write
Re:Lisp Scheme (Score:3, Informative)
No. This is false. And it doesn't really matter that you or many other people believe it to be true. It's still false.
Scheme is a block-structured language modeled on Algol. Common Lisp is a natural evolution of LISP 1.5. As part of the evolution, sure, some features from Scheme have been sneaked back into Common Lisp, but they are really very diff
Common Lisp and Schem are really different. (Score:5, Funny)
Scheme can be said to be ontological attack against Lisp. It looks Lisp but is as far from Lispiness as you can and being still Lisplike.
Schemer: "Buddha is small, clean, and serious."
Lispnik: "Buddha is big, has hairy armpits, and laughs."
-- Nikodemus
Greenspun's Tenth Rule of Programming:
"Any sufficiently complicated C or Fortran program contains an ad hoc informally-specified bug-ridden slow implementation of half of Common Lisp."
Common Lisp people seem to behave in a way that is akin to the Borg: they study the various new things that people do with interest and then find that it was eminently doable in Common Lisp all along and that they can use these new techniques if they think they need them.
-- Erik Nagggum
More than anything else, I think it is the ability of Lisp programs to manipulate Lisp expressions that sets Lisp apart. And so no one who has not written a lot of macros is really in a position to compare Lisp to other languages. When I hear people complain about Lisp's parentheses, it sounds to my ears like someone saying:
"I tried one of those bananas, which you say are so delicious.
The white part was ok, but the yellow part was very tough and tasted awful."
-- Paul Graham
Lisp is about rising above implementation to saying something of lasting
value. -- Kent Pitman
Pascal is for building pyramids -- imposing, breathtaking, static structures
built by armies pushing heavy blocks into place. Lisp is for building
organisms -- imposing, breathtaking, dynamic structures built by squads
fitting fluctuating myriads of simpler organisms into place.
- Alan J. Perils
Puns are pricey to have in the language becuase they lead to ambiguity
but they are also a source of great expressional power, so we live
withthem. People who don't like them should probably seek out Scheme,
which tends to eschew puns, for better or worse.
-- Kent M Pitman @ comp.lang.lisp
Q: How can you tell when you've reached Lisp Enlightenment?
A: The parentheses disappear.
LISP has survived for 21 years because it is an approximate local
optimum in the space of programming languages.
-- John McCarthy (1980)
``Lisp has jokingly been called "the most intelligent way to misuse a
computer". I think that description is a great compliment because it
transmits the full flavor of liberation: it has assisted a number of our
most gifted fellow humans in thinking previously impossible thoughts.''
-- "The Humble Programmer", E. Dijkstra, CACM, vol. 15, n. 10, 1972
Lisp is like a ball of mud--you can throw anything you want into it, and
it's still Lisp".
Java was, as Gosling says in the first Java white paper,
designed for average programmers. It's a perfectly
legitimate goal to design a language for average
programmers. (Or for that matter for small children, like
Logo.) But is is also a legitimate, and very different, goal
to design a language for good programmers.
-- Paul Graham
> The continuing holier-than-thou attitude the average lisp programmer...
There are no average Lisp programmers. We are the Priesthood. Offerings
of incense or cash will do.
-- Kenny Tilton at c.l.l
Dalinian: Lisp. Java. Which one sounds sexier?
RevAaron: Definitely Lisp. Lisp conjures up images of hippy coders,
drugs, sex, and rock & roll. Late nights at Berkeley, coding in Lisp
fueled by LSD. Java evokes a vision of a stereotypical nerd, with no
life or social skills.
In the Algol family, parentehses
signal pain. In the Lisp family, they signal comfort. Since most people are
highly emotional believers, even programmers, it is very hard for them to
relinquish their beliefs in their associations of parentheses with pain and
suffering. This has nothing to do with aesthetics, design rationales, ease
of u
Re:Lisp Scheme (Score:3, Insightful)
It seems difficult to you for the same reason Japanese seems difficult to native English speakers, and English seems difficult to native Japanese speakers.
practical? common? (Score:5, Funny)
Re:practical? common? (Score:5, Funny)
I don't know what is sadder: the fact that you wrote it, or the fact that I understand what you wrote.
Dylan - pretty Lispy (Score:3, Interesting)
seemed to have many of the benefits of Lisp without the prefix notation - macros, CLOS-based object system, multi-methods, multiple returns, optional type declarations, named parameters (I think), etc...
Dylan was started by Apple Research Cambridge in the late 80s, but was laid to rest (at least for Apple) after Jobs came back and the NeXT infusion.
At least Functional Objects opened up their stack and is now being incorporated by the above URL guys.
C++/Java/LISP Side by Side Comparison? (Score:2, Informative)
That's great and all but I can't find any concrete examples. I want to see a list of problems that are either difficult or nearly impossible with Java/C++ and see LISP's implementation.
Can anyone help me to get past the hype?
Well, search Paul Graham's site for examples... (Score:2)
(I doubt one can express a lisp macro in C/C++ WITHOUT templates, YMMV).
Paul B.
Re:C++/Java/LISP Side by Side Comparison? (Score:3, Interesting)
Practicle Common Lisp???!!! (Score:2)
Re:Practicle Common Lisp???!!! (Score:3, Funny)
Re:Practicle Common Lisp???!!! (Score:2)
Self modifying, recursive, spaghetti code I can do without..... but I have written a chunk of it.
Re:Practicle Common Lisp???!!! (Score:2, Insightful)
I have always found that spelling and grammar skills are very important to good coding, as well. After all, it helps immensely to be able to spell your variable names correctly. Even if you spell them incorrectly consistently, someone else who is looking for the bugs in your code will probably decide that one of the bugs is your spelling, and will break more things tha
O'Reilly: Are you listening? (Score:2, Interesting)
... programming paradigms (Score:4, Funny)
Re:... programming paradigms (Score:2)
Learn Lisp Without Installing Anything on Your PC (Score:4, Interesting)
It uses a free online telnet lisp that lets you try Lisp with zero install required.
Re:Learn Lisp Without Installing Anything on Your (Score:4, Informative)
I Prefer the Elisp Implementation (Score:2)
My bigge
Best Lisp Book: On Lisp (Score:5, Informative)
You will also want to read his essay, Revenge of the Nerds [paulgraham.com], for some serious insight into why Lisp is just so darn good.
If you're just starting on Lisp, the best place to start is with GNU CLISP [cons.org], although you will find yourself wanting to use Emacs with SLIME [common-lisp.net] to interact with your Common Lisp environment. I use SBCL [sbcl.org], but CMUCL and CLISP are also acceptable. On my Powerbook, I use SLIME with OpenMCL [openmcl.org].
Re:Best Lisp Book: On Lisp (Score:3, Interesting)
Frankly, I find both Seibel's Practical Common Lisp and Norvig's Paradigms of Artificial Intelligence Programming to be much better books on Common Lisp than anything Graham has written. Seibel has excellent practical examples dealing with current technologies, and Norvig's examples cover a very interesting subject matter not usually used when teaching a language.
Re:Best Lisp Book: On Lisp (Score:3, Insightful)
Yes, that's my biggest problem with his writings. I rather like static type checking personally, and will gladly trade the minor benefit in malleabillity for more error checking at compile time. I can't count the times I've made a trivial typo in Perl, for example, taken hours to find it and then thoug
This article has truly inspired me (Score:4, Funny)
An ideal world would run on LISP... (Score:5, Insightful)
The initial vision of the GNU system - remember "GNU's not Unix" - was to combine a kernel written in C for performance reasons with a userland written largely in LISP. Emacs is the only remnant of that idea, isn't even LISP in its program core, and uses its own LISP dialect instead of CLISP or Scheme. [The climacs [common-lisp.net] project, a CLISP reimplementation of Emacs, tries to fix that.]
Two years ago, I saw a practical demonstration of a Symbolics LISP Machine from 1987. It was like seeing the light of the holy hacker grail - the first system whose userland was superior to commandline Unix in every aspect [Plan9 has superior kernel design to Unix/BSD/Linux, but its mouse-centric userland sucks IMHO]. Everything was in one language, syntax and namespace. You could hack and debug the kernel (written in LISP, too) while it was running [!], the commandline userland hooked into every aspect of the system, and could be endlessly and seamlessly extended it just through custom LISP functions and eval-ing them.
Let's dream and hope that perhaps in one or two decades, when insight into the limitations of the Unix paradigm has become common sense, we will have a free Lisp OS as the next iteration of Free Software computing...
Re:An ideal world would run on LISP... (Score:4, Informative)
The frightening thing is, lispms from the 80's enjoy quite some popularity among certain people where I work [mit.edu]. They really are amazing machines, and those who use them regularly feel strongly that there hasn't been a more usable environment in all the time since they were created.
Let me tell you, though, as a sysadmin, these things can be a royal PITA. Not because there's anything wrong with them (well, except maybe for their complete lack of security) but they're just so different.
There are still many copies of The Lisp Machine Manual [acm.org] lying around, including an early rant by RMS against the recent trend of software hoarding. It makes for an interesting read...
noah
Practical Lisp? (Score:3, Insightful)
1-it is open sourced.
2-it has some GUI support (tk or gtk).
3-it is cross platform (including the GUI support).
4-it is estable, not in some estate of eternal beta.
5-it is embeddable in a web server (yes, I know Mod_lisp exists. But, yet it doesn't comply with 2 or 3)
If a young language, like Ruby or Python, can do this, why the hell Lisp, one of the oldest languages around, can't?!
Until I find something like that, I can't say Lisp is practical, no matter how theoretically cool it is.
Re:Good book, questionable language. (Score:2, Informative)
Re:Good book, questionable language. (Score:2)
You are very confused. CommonLisp most certainly has exceptions, and generally speaking the implementations have much better GC than any Java you will come across.
Sheesh.
Re:Good book, questionable language. (Score:2)
What are you talking about? Common Lisp has both exceptions (conditions) and garbage collection.
Re:Good book, questionable language. (Score:3, Interesting)
As everyone else that's replied to you has pointed out you are talking out your ass. Lisp had exceptions and GC long before Java or C# were even an idea. GC in Common Lisp is far ahead of GC in Java and .Net, for just this reason. An industrial strength GC isn't made over night, it's made by having applications beat the hell out of the GC and the implementors spending huge amounts of time handling huge programs. This is exactly what's happened for Lisp over the last 20 years.
For example, Allegro CL [franz.com] hos
Arc would probably get widely taken up (Score:4, Interesting)
Re:Libraries... (Score:3, Informative)
Re:Static code verifications, anyone? (Score:3, Interesting)
Managers would care a lot less about handling runtime errors if static languages didn't just plain segfault when they get them. Error handling in non-Lisp languages is so bad that of course people outside of Lisp are obsessed with handling errors. Even Java, which drew from Lisp in its design, failed to pick up the notion of "restarts" and so only has the throw-style environment=wrecking error handling. That is se
Re:Static code verifications, anyone? (Score:3, Interesting)
Re:Talking to the OS (Score:3, Informative)