4 ms·
Well done jacquesm! It's only been what since you first looked at Lisp? 2 months? Already you know your way around typical primitive implementations. Respect!
by mahmud 16y ago
Well done jacquesm! It's only been what since you first looked at Lisp? 2 months? Already you know your way around typical primitive implementations.
Respect!
- jacquesm 16y agoI've been studying it so I can go and write a little lisp interpreter in C just to make sure I really 'got' it. For me that's the 'benchmark' of understanding a language, to be able to re-implement it. edit: by the way, it's been more than two months, but there have been a lot of things done in that time that have nothing to do with programming.
- eru 16y agoFor a challenge: Try a lazy language next. See http://research.microsoft.com/en-us/um/people/simonpj/papers/slpj-book-1987/ http://research.microsoft.com/en-us/um/people/simonpj/papers... for some hints on writing a compiler for those (or just general amusement).
- jacquesm 16y agoLisp is enough of a challenge for me at the moment. For instance, it seems to be like travelling back to the 80's just to have to live with the 'third element in the list containing the data about a person' instead of simply using person->name , I've gotten used to thinking in terms of symbols so much that I find it hard to go back to the kind of trickery that was 'normal' in say microsoft basic in the 80's because it lacked named elements in something akin to a struct. There is a certain kind of elegance in something so minimal but it also comes with considerable mental overhead and opportunity for mistakes.
- mahmud 16y agoYou're still in the pedagogy sandbox; every real Lisp worth using has structures and objects: (defstruct person name age occupation) => PERSON (make-person :name "Kris Kringle" :age 71 :occupation "Santa") => #S(PERSON-1) (person-name *) ==> "Kris Kringle"
- jacquesm 16y ago> You're still in the pedagogy sandbox; Don't worry, I realize that :) > very real Lisp worth using has structures and objects: That's a tricky and somewhat circular definition. If it is worth using it is probably real and vv, but most lisp tutorials that teach 'pure' lisp do not have structures and / or objects, they rely on lists alone as their major data structure. That also defines all lisps that do not have these items as somehow not real and there seem to be a lot of lisp people that somehow consider this 'impure'. Or is my reading material that dated ?
- jules 16y agoIf your reading material Lisp doesn't have some form of defstruct then it certainly is dated, or they are avoiding it on purpose. Every non-toy Lisp has it.
- jacquesm 16y agoOk, thanks. That helps. I started 'from the ground up', I figured that the best way to study a language is by looking at the way it was in the beginning since that's the most pure form of it. If 'lists' are as great as they are said to be you'd expect that things like structs and classes are optimizations, not essentials.
- gruseom 16y agothird element in the list containing the data about a person Most people don't do that, except in throwaway code. In CL you can use an alist, a plist, a struct, or CLOS. I've gotten used to thinking in terms of symbols so much that I find it hard to go back Given that Lisp's history with symbolic computing goes back to the beginning, something about that doesn't sound right. Your person->name comment reminds me of something, by the way. Portions of our app run in both CL and JS (via the Parenscript library). This is relatively easy, although there are a few disagreements between the two that you have to watch out for (such as how they handle null). Anyway, there are lots of CL features we've "ported" to JS via macros, but there is also one JS feature I found myself envying so much that I finally wrote a partial implementation of it in CL. That is JS's willingness to allow you to stick any property on any object just by setting it. It's a rather Lispy feature since it's maximally dynamic and maximally flexible. I find it handy for incremental development. When you have some data about a thing that you want to associate with it, but only some of the time, it's a real pain to have to make a separate data structure to hold it and then make sure it gets passed alongside the original thing to all the appropriate places. Our CL implementation of this is pretty crude but it allows the important thing, which is that you can write (@ something :some-data) and (setf (@ something :some-data) "blah") pretty much wherever you want. So we can be said to have Greenspunned a bit of JS in Lisp!
- KirinDave 16y agoInstead we all just use associative arrays. But there is a danger in overusing structs and classes, too. You end up with these hugely complex ontologies for every little program, and frequently when you try to reuse code you end up with conflicts.
- mahmud 16y agoI wrote a few long-winded posts on HN listing Lisp implementation bibliographies. There are a few essential papers that you need to read to get the full picture; Here they are collected in an archive. Nearly all of them assume nothing more than rudimentary familiarity with Lisp, some functional programming (Scheme and tiny bit of ML) and they're geared towards someone with some C, machine-org and assembly knowledge. http://dl.dropbox.com/u/2083231/essential_lisp_implementation_papers.tar.gz http://dl.dropbox.com/u/2083231/essential_lisp_implementatio... I would recommend these to someone who wants to implement a functional or a Lisp language, going with nothing but basic systems programming knowledge. Recommend prerequisites are the first 2-3 chapters of SICP, some familiarity with classic compiler construction (dragon book would do, skip the lexical analysis and parsing parts though; you wont need much of that for Lisp if you retool and existing lexer. But focus on function calling and stack discipline, lexical scope and variable visibility, and maybe learn how an Algol dialect implements runtime heap-allocation) some exposure to C and assembly, and healthy curiosity. A suggested order might be: Ghuloum, Wilson, Dybvig, the uncredited "lisp-implementation.pdf" paper, Gudeman, Kelsey, then Shao (Shao might make a whole lot more sense if you read one of Andrew Appel's compiler books and dip a tiny bit into ML.)
- eru 16y agoFor the brave, I can also recommend "Write Yourself a Scheme in 48 Hours" (http://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours http://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_H...). I write `brave', because it implements Scheme using Haskell. And if you aren't familiar with either, the learning curve will be steep.