4 ms·
Don’t Build Your Own Lisp: https://gist.github.com/no-defun-allowed/7e3e238c959e27d4919bb4272487d7ad https://gist.github.com/no-defun-allowed/7e3e238c959e27d491
by cardanome 1y ago
Don’t Build Your Own Lisp: https://gist.github.com/no-defun-allowed/7e3e238c959e27d4919bb4272487d7ad https://gist.github.com/no-defun-allowed/7e3e238c959e27d4919...
Just so people are aware of it. It is not a good source if you want to learn how to make a lisp that could scale beyond a toy.
You can still learn a bit of C and get a taster of how to make a language, just be aware that some stuff you learn will hold you back in the long term.
- Arch-TK 1y agoYou shouldn't use it to learn C either. It's full of bad C.
- freilanzer 1y agoThat sounds horrible. What are better resources?
- stevekemp 1y agoMAL, the original "make a lisp", is a bit terse on details but gives you freedom to use different languages, and yet still provide a rough blueprint: https://github.com/kanaka/mal https://github.com/kanaka/mal Discussed here, a few times: https://news.ycombinator.com/from?site=github.com/kanaka https://news.ycombinator.com/from?site=github.com/kanaka
- dang 1y agoThanks! Macroexpanded: Mal – Make a Lisp - https://news.ycombinator.com/item?id=26924344 https://news.ycombinator.com/item?id=26924344 - April 2021 (40 comments) Mal – Make a Lisp, implemented in 79 languages - https://news.ycombinator.com/item?id=21670442 https://news.ycombinator.com/item?id=21670442 - Nov 2019 (11 comments) Mal – Make a Lisp, in 68 languages - https://news.ycombinator.com/item?id=15226110 https://news.ycombinator.com/item?id=15226110 - Sept 2017 (69 comments) Make your own Lisp - https://news.ycombinator.com/item?id=13967401 https://news.ycombinator.com/item?id=13967401 - March 2017 (32 comments) Mal – Make a Lisp - https://news.ycombinator.com/item?id=12720777 https://news.ycombinator.com/item?id=12720777 - Oct 2016 (1 comment) Make a Lisp in Nim - https://news.ycombinator.com/item?id=9145360 https://news.ycombinator.com/item?id=9145360 - March 2015 (44 comments) Make a Lisp - https://news.ycombinator.com/item?id=9121448 https://news.ycombinator.com/item?id=9121448 - Feb 2015 (41 comments) Lisp implemented in under 1K of JavaScript - https://news.ycombinator.com/item?id=9109225 https://news.ycombinator.com/item?id=9109225 - Feb 2015 (16 comments)
- cardanome 1y agoMAL is pretty good, albeit less hand-holding: https://github.com/kanaka/mal https://github.com/kanaka/mal Writing a Lisp in Ocaml: https://bernsteinbear.com/blog/lisp/00_fundamentals/ https://bernsteinbear.com/blog/lisp/00_fundamentals/ Not Lisp-specific but Crafting Interpreters is also great: https://craftinginterpreters.com/ https://craftinginterpreters.com/
- mastermage 1y agoCrafting Interpreters is an amazing resource.
- OhMeadhbh 1y agoI just nano-blogged my thoughts about this yesterday: https://BI6.US/CO/N/20250803.HTML#/080401 https://BI6.US/CO/N/20250803.HTML#/080401
- Philpax 1y agoMicroblogs are 200-500 characters, so I was expecting a nanoblog to me to be an order of magnitude less than that :sweat_smile:
- sestep 1y agoOr technically, three orders of magnitude smaller? (half a character per post)
- OhMeadhbh 1y agooh. the measure is how much code was used to implement it. at about 200 lines of javascript (to parse the text, convert it to json and render it as static HTML) it's at least a thousand times fewer lines of code as the early scala code that implemented twitter. [edit - though it looks like handlebars (that I use for generating HTML from templates) has about 30k lines in files that end in .js, so maybe twitter is 30m lines of code?] [second edit - hmm... maybe i'll change the name to "mini-blog" to signal it's a blog that's 25% the performance of a "mainframe-blog" but 10% the cost. though "mini-blog" might be more appropriate: halfway between a "normal" blog entry and a "micro-blog."]
- wink 1y agoJust make the urls a little longer and then you can tell people the posts are generally shorter than the urls.
- OhMeadhbh 1y agoalso... I'm a computer scientist so "three orders of magnitude" means 8. ;-)
- axblount 1y agoLisp In Small Pieces by Christian Queinnec It takes a very thoughtful approach to introducing an increasingly complex Scheme implementation. I doesn't shy away from the complexity that many LISP implementation tutorials try to push under the rug.
- hajile 1y agoI'd say that the best is probably the book "Lisp in Small Pieces". Be aware that it's some 500 pages and makes several interpreters then a couple of compilers as I recall. If you read it though, you'll come out the other end with a pretty good understanding of how lisp implementations actually work.
- teunispeters 1y agoI started from https://github.com/videogamepreservation/abuse https://github.com/videogamepreservation/abuse which ... well, isn't perfect but it IS fun and the original game was, too.
- Fraterkes 1y agoI’m sure the author of this is actually a nice person, but this is the first time I’ve actually seen a lisper being smug and obnoxious in the way I’ve seen people satirize a thousand times.
- cardanome 1y agoI think the issue is that the topic comes up quite often as seen by the author needing to create the gist. It easy to come across as a bit of "smug and obnoxious" when you explain something for the xth time. I remember chatting with them years ago and they were pretty friendly. But yeah Lisp does have a specific culture and it can put people off thought I personally never encountered any bad apples.
- Fraterkes 1y agoI checked some of her other stuff and she seems great! I just wouldn’t want to argue with her about Lisp I think.
- Jach 1y agoIf the argument was not born from ignorance I think it'd be fine ;) There's a rich history, decades old, of people claiming Lisp can't do X or is bad for Y, or is only a category and the true meaning of Lisp as a category is just having s-expression syntax. Some Lispers get more touchy when such things come up yet again. Attempts to correct misconceptions do work a little bit but just like bad and false popsci memes (remember when the "you only use 10% of your brain" myth was more popular?) the false memes seem to spread more easily. It takes a long time to overcome them, if ever.
- wk_end 1y agoCompared to much of what went on comp.lang.lisp this is pretty gentle. Based on the impression it gives of the book, possibly more gentle than it deserves!
- BalinKing 1y agoWith the exception of one or two sentences, it sounded pretty neutral to me... maybe I just didn't read it closely enough? The "dogmatism" of the technical criticism (assuming the post is accurate) really does seem justified to me—e.g. if the book uses dynamic scoping without even a disclaimer like "this is a bad idea, but we're doing it for simplicity", that alone makes it a bad recommendation for beginners IMO.
- matheusmoreira 1y agoHe makes many good points in his criticism but I'm still wondering what language one's supposed to use if not C. My lisp has a conservative mark-and-sweep garbage collector. The mark phase spills all registers and then walks the entire stack looking for pointers to lisp objects. I managed to implement the stack walking through some convoluted pointer nonsense but even C could not express the notion of spilling registers, I had to write assembly code for each architecture. I have no idea how such a garbage collector would be implemented in Rust or Zig.
- int_19h 1y agoThe same exact way you did it in C - by relying on implementation-specific features such as assembly.
- munificent 1y agoHere's a more balanced take: "Build Your Own Lisp" is an opinionated, idiosyncratic take on one style of programming in C and one way to implement a Lisp-like language. If you go into it treating it like an intro textbook to the "standard" way of implementing an interpreter, it may lead you astray. Worse, it may lead you astray without realizing it if it's your first book on the topic. On the other hand, if you approach it as following an author as they deliberately wander off the well-trod path of implementing Lisps with recursive descent and all the other classic techniques, then you can have a good time and maybe get some interesting ideas out of it. For what it's worth, I quite enjoyed the book. But I had enough programming language experience already to know when the author was teaching you the basics versus teaching you their own thing. The more the world world becomes aggregated, summarized, averaged, and watered down, the more I crave stuff like this that is quirky and unique.
- fud101 1y agoThis is a solid take. I also had the same opinion on the book. You're better off doing the Norvig Lisp in Python journey then branching out on your own.
- kazinator 1y ago>> In our Lisp, when we re-assign a name we’re going to delete the old association and create a new one. This gives the illusion that the thing assigned to that name has changed, and is mutable, but in fact we have deleted the old thing and assigned it a new thing. > Please don’t do that. What would be the result of evaluating: (let ((a 1)) (+ (let ((a 2)) a) a)) That is off the mark; that example doesn't re-assign anything; it is binding a shadowing instance of a. Removing a binding and destructively creating a new one in the same environment is a viable strategy for implementing assignment, compared to mutating just the value part while keeping the same binding cell. You can implement it so that the semantics is absolutely identical; the program simply cannot tell. If you try to make it nondestructive somehow, then the program can tell; e.g. if you functionally rewrite the current environment to produce a new environment in which the variable is edited to the new value. then closures will reveal the trick. Previously captured closures keep seeing the old environment and old value (obviously inapplicable discussion to dynamic scope). If a variable that has been captured by any number of closures is destructively assigned, all the closures must see the new value after the assignment, otherwise you have something other than assignment.