12 ms·
Learn Lisp the Hard Way
- mkautzm 12y ago"Is Lisp as hard as people say it is? No. Lisp is actually the simplest programming language, and has no syntactic cruft. While it wasn't designed to be “easy to learn” like Swift, Python, Ruby, or Basic, there is less overall to learn and you will be writing real, useful programs in Lisp sooner than you could with other languages." It's like a never-ending stream of lies, every word being a little more absurd than the last...
- wes-exp 12y agoJust because Lisp looks foreign doesn't mean that it's harder. The syntax is different, but it is also very simple. If this were untrue, Scheme wouldn't have survived as a teaching language all these years.
- sejje 12y ago> The biggest secret to Lisp is that it is actually the simplest programming language ever created—and that, coupled with its expressiveness and elegance, is why it is favored exclusively by the best programmers in the world. But is it?
- nohaxplz 12y agoSounds like you just got told you're not one of the best programmers in the world and are still in shock about it.
- AnimalMuppet 12y agoSounds to me like the GP is in shock about such an over-the-top claim. And it sounds like you're trying to pretend to read his/her statement for something other than what it is.
- nightski 12y agoSimple syntax does not a simple programming language make.
- gre 12y agoSimple syntax "Hello world!" ++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.
- sejje 12y agoI'm not one of the best programmers in the world, no shock there. I'm learning and enjoying clojure, though!
- bsilvereagle 12y agoAt first I thought the Dr. Scheme (now Dr. Racket) program was crazy to choose a Lisp like language. Then as I learned more languages I realized how much easier it is to think about programming since I started out with Dr. Scheme. How To Design Programs for those interested in picking up Scheme: http://htdp.org/ http://htdp.org/
- mkautzm 12y agoIt's less about it being 'foreign' and more about it being totally unparsable. The thing with imperative programming is that you don't really need to know the language to at least get an idea of what's happening. Lisp is so dense that while you can pack an unbelievable amount of programming into a small chunk, approaching it as a beginner is daunting. There isn't a really good way to 'build' on an algorithm and learning it is significantly harder than learning C# or Java or even better yet, Python. It's like saying, 'Linux is easy to learn! You can do so much in so few characters! It's so powerful! And look, robust manual pages for all!' Yeah, that's true, but handing a user some pipes and greps isn't going to explain what the hell they actually do or better yet, how to leverage that into something useful. It's just going to look like greek to anyone who sees it and a huge effort has to be made to get to the point where you can even begin to understand what's happening. Imperative programming doesn't ask you of much. 'Here is a class. Here is the main method. Write some stuff in here. Here are some basic methods in the default libraries and their expected inputs. It's going to execute line by line. Go nuts.' And that's really the difference here. Lisp asks a lot of the user up front. Python doesn't. C# doesn't. Fuck, Python is so loose that you don't even really need to know what any of the structure is to start writing something that kicks back some output. Yeah, as a group that understands Lisp and Scheme and Haskell and F#, it's really easy to say, 'Lisp isn't THAT hard', but that's bullshit. Lisp IS that hard. Lisp is a very difficult language to pickup when you are starting at square one and it's only marginally easier if your background is purely imperative languages. Misrepresenting that is a bold-faced lie.
- catern 12y agoI don't find your argument to be very compelling. Let me guess: you learned imperative programming first, you're most familiar with it, and you only have limited experience with Lisp, if any? The fact that you find imperative programming easy (because you know it well) and Lisp and functional programming to be hard, is not very informative about which of imperative or Lispy or functional programming is easiest to learn.
- tormeh 12y agoThe only thing that was hard with imperative programming that I can remember was "=". That was absurd, to put it simply. "x = x + 1"? As someone who has seen these symbols in math class and think they know what they mean that notation kind of suck.
- gre 12y agoThe DSL for string formatting certainly doesn't look simple. (format t "~{~@(~A~)~^ ~}, because ~{~A~^ ~} is easier!" llthw (cddr llthw))
- gaigepr 12y agoI am only recently a lisp user but honestly, how is the format function far from: printf("something %s then %d finally %f!", "asd", 1, 1.2) As mentioned, there is a loop built into format. Since lisp also has a (list) function eg: (list 'a 'b 'c 1) I still don't see an argument beyond familiarity with the C style printf syntax for why format is bad/unreadable.
- wglb 12y agoThere is a loop embedded in the lisp version.
- mcosta 12y agoI do not understant it, but with changing ~ with % I can imagine what it does.
- ScottBurson 12y agoIt's complex because it's powerful. ~A is the most common directive; it simply prints an object. '~{...~}' (braces) iterates over a list, applying the directives within it to the list elements. Within that construct, '~^' exits if the last element of the list has been consumed; it's used here to keep the separating space from being printed after the last element. '~@(...~)' (parens) capitalizes words in the output of the directives it contains, downcasing the non-initial character of each word. So there's a lot more power here than in 'printf' control strings. If you find the more exotic notation unintuitive -- and you certainly wouldn't be alone -- you don't have to use it.
- gre 12y agoIt's just disingenuous to say that LISP has extremely simple syntax and then show the DSL for format, which is anything but LISPy or simple.
- rtpg 12y agoSimplicity of syntax does not translate to ease of use. Or else we'd all be programming in one-instruction Turing Tarpit.
- kazinator 12y agoThat's right; Lisp's syntax is not only simple; it is simple while retaining the power to combines together and express any syntax tree. If you put on special Lisp goggles, you can see S-expressions inside the syntaxes of other languages.
- JasonFruit 12y agoCould you enumerate the lies for us? Your comment is arresting but not enlightening without more information.
- kazinator 12y agoI'm an Lisp programmer, so I can. The language ANSI Common Lisp certainly has its fair share of "syntactic cruft". For instance numerous "macro dispatch characters" like #'func #:sym #c(2.0 4.1) #(vec tor). None of the syntactic cruft requires a LR(1) algorithm to work out; most of it is based on recognizing a character or two of prefix material and dispatching a read function. When the dispatch involves two characters, the first one is almost always # (though for programming your own nonstandard read syntax, that is not a fixed rule.) Read syntax is not even considered "real" syntax by Lisp programmers; "real" syntax is the structure of macros. But since macro forms are unambiguously written as nested lists, they already express the phrase structure almost directly; there is no phrase structure that needs to be applied to get a syntax tree. There isn't any syntactic cruft in Lisp that will have you scratching your head as to what goes with what. There are semantic head-scratchers related to syntax, like working out the implied actions of complicated, nested backquotes. There is never a question of syntax, though: nested backquotes are not ambiguous syntactically: they are just nested lists, with some sprinkling of a simple prefix-based notation throughout (splices and unquotes).
- mkautzm 12y agoLisp is the hardly the simplest language. It has way less 'stuff' to learn, but that 'stuff' in imperative languages is generally useful abstractions that you don't to learn, but instead simply know of. By that measurement, x86 Assembly is really the simplest language of them all, but I don't think I need to explain why that's equally absurd. Lisp is a difficult language due to it's density and unreadability. Useful stuff hasn't been built in functional languages until very recently, exception being some AI. Haskell and friends are making functional languages cool and useful (and that's great!) but if you want to build something useful as soon as possible, learn .NET, Java, Python or Ruby.
- noblethrasher 12y ago
- AnimalMuppet 12y agoWell, let's see. Lisp has no syntactic cruft? It has (almost) no syntax, so there's less room for cruft. That said... cons? car? cdr? That's your syntax? That's not cruft? Seriously? There may be less total cruft, but the percentage of cruft might still be higher... There's less overall to learn? If you mean to master the syntax, sure, that's true. You'll be writing real, useful programs in Lisp sooner than you could with other languages? That's a much more arguable point. There's more to being able to effectively program in Lisp than learning the syntax (as there is for every language). Is that "more" easier to learn for Lisp than for other languages? I have no data, but for the web site's claim, I'd at least say "citation needed".
- kazinator 12y agoI believe that Lisp requires years to master. If you're a bright developer, who puts in time eagerly, it will take at least six months before you begin to "get it". At that time you may start itching to evangelize to others, but those who have not put in the time will not get it. It's not realistic to try to make someone see in one or two e-mails or postings what took you a year to see for yourself.
- nmrm 12y agoI think the whole enlightenment thing w.r.t. lisp is overblown.
- kazinator 12y agoFrom what vantage point?
- Blackthorn 12y agoI'm not the above poster but I think the power of macros is way overhyped and not nearly as strong as people claim. I see the claim of "you can write a macro to do it" for any imaginable feature all the time, but it is simply not true. A recent example from personal use is continuations. Scheme has them as a first-class object. Common Lisp does not, but a common claim is that you can write macros to provide continuations. Some people have: there's "cl-cont" available on Quicklisp, which is a macro that will code-walk your functions to turn them into continuation-passing style and thus allow you to use continuations in those functions. So that's great, right? Common Lisp now totally has continuations? Not at all. In order to get this feature, you need to wrap ahead of time (specifically, at compile time) the functions you want to be continuable, and all of their callers, in this macro. You cannot simply use a function that you've been given as part of a continuation, it had to have been compiled under this macro. That's where the power of macros completely falls down and, in my opinion, gets completely overblown. Yes, your language is extendable, but your extensions are limited to computation and source-to-source transformation at compile time. You can't apply any of that power to already-existing artifacts.
- terminus 12y ago> It's like a never-ending stream of lies, every word being a little more absurd than the last... It's been my experience that most things are tractable once you spend long enough staring at them. If you care enough about a subject to have strong sentiments like "never-ending pack of lies" then your time would perhaps be better served by spending time with the "adored" object, rather than these comments.
- nilved 12y agoI think the sentence is poorly put together, but there aren't any lies. Clojure syntax is by far more simple (and thus easier to learn) than C-style languages or Python or Ruby. But the language is harder to jump into because it places particular emphasis on programming principles that are confusing to new programmers, like function purity, recursion and higher-order functions. Keep in mind too that different Lisps have different syntax. The only thing in common between them is Polish notation, S-expressions and a macro system. A Clojure program and a Common Lisp program look and feel very different.
- jfarmer 12y ago"simple" isn't the opposite of "hard," it's the opposite of "complex."
- jschulenklopper 12y agoBefore asking the obvious question when noticing the "Learn [X] The Hard Way" pattern, the FAQ already addresses that :-) Q: Is this site affiliated with Zed Shaw and Learn Code The Hard Way? A: No. This is a separately run and managed site, based on the format of Zed Shaw's LxTHW open-source package [1] for writing your own programming language course. You should check out the project and see what others are up to! More information is available at: Learn Code The Hard Way [2] [1] https://gitorious.org/learn-x-the-hard-way/ https://gitorious.org/learn-x-the-hard-way/ [2] http://learncodethehardway.org/ http://learncodethehardway.org/
- andrewstuart 12y agoWhy copy his format? Seems Zed did the hard work to establish the brand.
- ambiate 12y agoWhy would he put up a public repository if he did not want the format copied? Zed A. Shaw created project Learn X The Hard Way 2011-08-29 22:06:48 UTC This is a skeleton book project that makes it easier to start working on a "Learn X The Hard Way"...
- ProAm 12y agoI think you can copy his format, but taking his brand is a different story. Zed put a lot of hard work into that, this is less than honest in my mind.
- AnimalMuppet 12y agoSaying that it's a template for a "Learn X The Hard Way" book sounds to me like an invitation to write a book titled "Learn X The Hard Way" (absent any statement on his site asking that people name their book something different).
- andrewstuart 12y ago
- bestrapperalive 12y ago"The mysterious force driving human society towards the technological singularity, true and total unification of human with technology, also seems to be shaping all programming languages into Lisp, and all computers into Lisp Machines. Lisp, after all, can do everything, and do it every way; that Lisp is not already the de-facto programming language is just a reflection of the state of the world as a whole—only a very small percentage of the population are excited for the technological singularity, but the singularity is coming no matter how much people complain. One way or another, every programmer is going to end up being a Lisper, because every programming language continues to adopt features and syntax from Lisp, one piece at a time. It is in every programmer's interest to master Lisp now, before the world at large realizes how essential Lisp will become over the next two decades." The title is right, IMO. This is a difficult way to learn Lisp. I'm feeling the burn already.
- AnimalMuppet 12y agoThat burn isn't from Lisp, though. It's from this author's tying Lisp to a somewhat far-out world view - one that doesn't actually relate to Lisp very much.
- malisper 12y agoI'm surprised there is no mention of Lispbox[0], by far the easiest way to set up Common Lisp. [0] http://common-lisp.net/project/lispbox/ http://common-lisp.net/project/lispbox/
- guiomie 12y agoAwesome, I'll give this a try. Does it use Steel Bank Common Lisp ?
- FatalBaboon 12y agoThey wrote that they use "Clozure Common Lisp compiler" [1] [1] http://ccl.clozure.com/ http://ccl.clozure.com/
- S4M 12y agoYes, quicklisp works with SBCL.
- Grue3 12y agoI suspect it's mostly because quicklisp (http://www.quicklisp.org http://www.quicklisp.org) pretty much obsoletes it.
- terminus 12y agoI'm guessing this was posted earlier than expected. Don't see much content beyond the Preface.
- danso 12y agoI can't bag on a free book, one created as a labor of love...but if I had to make a suggestion, it would be to tone things down a bit: http://learnlispthehardway.org/book/preface/ http://learnlispthehardway.org/book/preface/ > The biggest secret to Lisp is that it is actually the simplest programming language ever created—and that, coupled with its expressiveness and elegance, is why it is favored exclusively by the best programmers in the world. As a Lisp novice...my thoughts are, "Really?" to both of those assertions. Because the natural follow up is..."So if all the best programmers use it, whatever "best" means, why is it a language that seems so rare in everyday use?". No need to assert things you can't actually prove or show...it just builds up skepticism before the reader even starts learning. Just talk about the language at hand, or at the very least, do a quick Rosetta Stone comparison of Lisp doing something much more simply than Python/Ruby/PHP, and that's all you need to write in the intro.
- mushishi 12y agoFrom the FAQ: "Is Lisp as hard as people say it is? No. Lisp is actually the simplest programming language, and has no syntactic cruft. While it wasn't designed to be “easy to learn” like Swift, Python, Ruby, or Basic, there is less overall to learn and you will be writing real, useful programs in Lisp sooner than you could with other languages." Is it necessary to put strong subjective statements that have no supporting links or proof? Also, are you seriously saying that /Common/ Lisp is the simplest language? (from FAQ: "Lisp — the friendly nickname for Common Lisp")
- slapresta 12y agoSyntax wise, it is probably the simplest language as long as you don't include Turing tarpits. Of course, simple syntax is nice, but it doesn't actually get you very far by itself.
- Udo 12y ago"that Lisp is not already the de-facto programming language is just a reflection of the state of the world as a whole—only a very small percentage of the population are excited for the technological singularity, but the singularity is coming no matter how much people complain." As a transhumanist myself I resent the arrogance that led to this ridiculous appropriation. Yes, Lisp is pretty great, but the use of other languages is not some grave cultural defect through which you can glimpse at all the badness in the world. If the goal here is to evangelize Lisp, radiating this kind of pomposity seems like a questionable move because it reflects badly on the community you are trying to win new members for. Worse, this could be interpreted as willful cluelessness in the face of the rich multi-language ecosystem potential readers are living in. As far as the singularity is concerned, monocultural boneheadedness is not something people associate with technological progress.
- onetimeusename 12y agoSomething I find ironic is that Zed Shaw dislikes both haskell and lisp programmers for a variety of reasons that would only provoke if I put them here, some of which you already mentioned. Search "lisp" in second source. [1]http://lemire.me/blog/archives/2010/05/31/computer-science-is-shallow/ http://lemire.me/blog/archives/2010/05/31/computer-science-i... [2]http://learnpythonthehardway.org/book/intro.html http://learnpythonthehardway.org/book/intro.html
- zedshaw 12y agoYeah that is kind of funny, but if he finishes it then I can update that intro to point people at his book instead.
- coolsunglasses 12y agoMIRI (one of the more well known groups of people serious about the singularity) actually recommend people learn Haskell if they want to contribute to mathematical, statistical, AI research. http://intelligence.org/courses/ http://intelligence.org/courses/ https://github.com/bitemyapp/learnhaskell https://github.com/bitemyapp/learnhaskell
- jflowers45 12y agoI went to a techie high school and we studied LISP in an AI class I took. My biggest memory is the load of parentheses! It was definitely an interesting language and I've often thought about looking back at it for giggles. This could be a good reference.
- kazinator 12y agoAn easily overlooked, seemingly forgotten book that is great for newbies is Stuart Shapiro's _Common Lisp: An Interactive Approach_. I stumbled into Lisp some fourteen years ago when a hard copy of the book landed my way. The book is now freely available in electronic form (and has been for years): http://www.cse.buffalo.edu/~shapiro/Commonlisp/ http://www.cse.buffalo.edu/~shapiro/Commonlisp/
- melipone 12y agoThat was my first Lisp book 30 years ago already.
- anmonteiro90 12y agoOK. this is actually true. thank you so much
- PuercoPop 12y agoRegarding the tone I concede it is a little over the top, but considering the author works for D-Wave[1] building the future of (Quantum) Computing I think it is not without merit. It may be better to leave the intro part for the end as it may alienate programmers that have preconceived notions about lisp based on hearsay and not actual experience (i.e. it's enlightening, it's old, full of cruft, hard to read, it's functional, Clojure is the future of lisp). It is also very much a WIP that the author didn't submit so keep that in mind. I hope he gets to writing the chapter on Quantum computing: http://learnlispthehardway.org/book/3-14-0-quantum-computing/ http://learnlispthehardway.org/book/3-14-0-quantum-computing... [1]: http://www.dwavesys.com/ http://www.dwavesys.com/
- semiel 12y agoThe author working for D-Wave is a very illuminating fact, given the high probability that D-Wave's products are pseudoscience.
- thephoeron 12y agoIt's worth noting that I don't work for D-Wave. Quantum Computing is an interest of mine, so naturally I signed up for their developer program when they launched it a couple years back (which they shut down entirely earlier this year).
- PuercoPop 12y agoSorry, my mistake. Don't know where I got the idea that I had seen D-wave on your gh profile.
- thephoeron 12y agoOh, yeah that was just the group for members of their developer program. It's gone now though.
- Kluny 12y agoThe FAQ section answered all of my questions. Well done.
- jaekwon 12y agoWhat is that background image? Some fractal?
- meowface 12y agoI have nothing against Lisp, but... >Is Lisp as hard as people say it is? >No. Lisp is actually the simplest programming language, and has no syntactic cruft. I always see this used when claiming certain languages are easy to grasp. "It's not complex at all! The syntax is incredibly simple!" x86 assembly also has very simple syntax but it's not too easy for beginners to write in, beyond very simple and small programs.
- kazinator 12y agoThe syntax of assembly language isn't combinative, beyond simple catenation. You're not creating trees, just a "link sausage" (or, a graph, more accurately) of instructions. Lisp syntax expresses tree structures; it actually does what other languages achieve with complicated syntax. They have parsers which build trees out of nodes. Those trees can be written in a Lisp-like way. E.g. a C declaration might be turned, by a C compiler, into (declare specifiers-qualifiers declarators), where specifiers-qualifiers might look like (const int) and declarator might be (a (pointer (array 3))), giving us (declare (const int) ((a (pointer (array 3)) (b (pointer (function (a int) (b int))))) for the surface syntax "const int (a)[3], (b)(int, int)". It's not just that the syntax is simple, but that it can capture the structure of programming (and other) languages while remaining simple.
- cma 12y agoYou still end up with myriad syntax rules; why (a int) and not (int a)? Why not any inversion or isomorphic transformation?
- spain 12y agoIt really is. That's why they used Scheme for the Structure and Interpretation of Computer Programs (SICP). If you look closely at it, you'll notice that they don't actually spend a lot of time teaching you anything about language itself, just the processes.
- zedshaw 12y agoI really hope Colin finishes this as I've always thought Lisp would be a better beginner language if there was a book like mine for it. You've either got "The Little Schemer" series, which is annoyingly written for little kids but close to the style, or you have giant academic tomes that only hard core geeks would bother reading. A "trainer" book like mine would definitely solve this gap. The intro is a little bit copied but it's fine since he is keeping to the idea and the "rules" I have, but could be nicer if it was in his own voice more. Who knows, maybe he does write like me a lot or he's just ultra inspired. The big reason I say people should use their own words, apart from copyright, is that if you're writing one of these books for a programming language you love then your words will express that better. You'll say things that come from your community and culture, and you'll give away a sense of what you like about that language. When people copy what I say the prose comes out obviously not by them and not for that language. Anyway, this is pretty cool and I hope he works on it some more.
- correnos 12y agoPractical Common Lisp is a very good introduction. It's very much targeted at competant non-academics.
- taeric 12y agohttp://landoflisp.com/ http://landoflisp.com/ is a nicely informal book on learning lisp that is easy to get into. Pretty sure I've seen it highlighted here a few times.
- serf 12y agoI like Land of Lisp, and I own the ebook+paperback, but I don't think that it's well suited to beginning programmers. I think the "let's make a game" approach actually works better for programmers who are coming from a different language and trying to understand concept translations, rather than novel concepts themselves. edit : I can't reply to you, but re-read what I said. I am making the point that I believe Land of Lisp to be for people coming from other languages, whereas I think that "learn X the hard way" is better for people new to programming altogether. The parent of my reply is pointing out to zedshaw that "Land of Lisp" is a good beginners book. I am adding that it's my opinion that it's a good "beginner at lisp" book, and not an overall "good-for-beginner-programmers" book.
- scottlocklin 12y ago"Lisp is, at its heart, a very mystical language, that blurs the line between programming and magic." I like lisp, but this kind of mystical gobbledeygook is not helpful. It's worth noticing that mystics and lisp-ninnies are alike in a very important way: promising much, and delivering little. The people who actually accomplish things in lisp (Yann LeCun, Richard Fateman) do not speak in this preposterous mouth foamy way. They also don't work for overt frauds like d-wave.
- enupten 12y agoYann leCun does not use Lush anymore.
- krapp 12y agoOk i started this. How long before I can condescend to the rest of you barbarian peons? But seriously - i've been wanting to learn a lisp for a while now and this seems like an accessible way to go about it.
- krapp 12y agowelp apparently i'm done for now... http://learnlispthehardway.org/book/1-02-02-more-strings/ http://learnlispthehardway.org/book/1-02-02-more-strings/
- thephoeron 12y agoRestarted the server, you should now be able to see the next three exercises... although there's very little to be seen in them so far.
- thephoeron 12y agoWow. The response on here has been amazing---yes, the criticism too. I was really shocked last night with the spike in traffic from Reddit, but I had no idea what to make of getting to the front page of Hacker News. TBH, I'm feeling pretty overwhelmed about the whole thing. Just to put my two cents in, as a general reply to a lot of comments here... this is a very, very early draft in progress, and I didn't expect anyone to pay attention to this project, let alone post it everywhere. It needs a lot of work, particularly in toning down the Lisp Evangelism, and staying true to the methodology without accidentally parroting Zed Shaw's voice. Zed Shaw: it means a lot to me to get your perspective here. Yes, you and your series ultra-inspired me. I've wanted to write a book on Lisp for a long time, but it wasn't until I was pointed to your series that I felt like I could give Lisp the perspective it was missing. I'll make a point of editing the Preface more carefully---everything that's up there so far, I wrote off the top of my head with very little editing, so I guess in following your method and format I accidentally used some of your words as well. Thanks everyone!
- code_chimp 12y agothephoeron should start a mail list to let us know when there are updates and when the paperback is ready to buy.
- meenzu 12y agoThis is fantastic! Really looking forward to the web chapter!