18 ms·
Learn C and build your own Lisp (2014)
- EamonnMR 5y agoI like this tutorial, but it's worth noting that you're building your own lisp with the author's bespoke parser generator.
- ludston 5y agoYes. I followed this tutorial a few years ago and found this to be quite disappointing.
- cellularmitosis 5y agoHere is my take: https://gist.github.com/cellularmitosis/71123906bb6dd5619748e33e8d072594 https://gist.github.com/cellularmitosis/71123906bb6dd5619748...
- okareaman 5y agoPrevious discussion about the parser https://news.ycombinator.com/item?id=17478992 https://news.ycombinator.com/item?id=17478992
- nafizh 5y agoIt seems the author has added an appendix [0] where he replaces the library parser with a hand-rolled one. 0. http://buildyourownlisp.com/appendix_a_hand_rolled_parser http://buildyourownlisp.com/appendix_a_hand_rolled_parser
- zelphirkalt 5y agoI started going through the book, but from the start I deviated to use Rust and Pest PEG grammar to make the parser and the logic. Saved me many times of debugging, but also showed, that you do not have to stick to the library or parser that the book uses.
- juped 5y agoyes, the parser library is definitely the most valuable part of this.
- okareaman 5y agoPreviously with more than a few comments https://news.ycombinator.com/item?id=17478489 https://news.ycombinator.com/item?id=17478489 https://news.ycombinator.com/item?id=7530427 https://news.ycombinator.com/item?id=7530427
- moonchild 5y agoDon't Build Your Own Lisp provides some harsh—and IMO totally justified—criticism: https://gist.github.com/no-defun-allowed/7e3e238c959e27d4919bb4272487d7ad https://gist.github.com/no-defun-allowed/7e3e238c959e27d4919...
- phlalexsh 5y agoThe criticism may be justified but jeez the person who wrote that comes off like a HUGE asshole. Reminds me of people I've worked with in the past who think they know everything and have an arrogance so thick you could cut it with a knife.
- astrange 5y agoEvery Lisp programmer I've ever met is like this. I don't know why, but it's probably Erik Naggum's fault. They used to be called "Lisp weenies" and now would be called "abusers". (The Clojure and Racket people are supposedly nice.)
- guenthert 5y agoI've seen Erik Naggum's name mentioned in this context before, but years ago I looked through a bunch of his contribution on comp.lang.lisp and couldn't see anything justifying this reputation. His articles rather looked quite eloquent and thought-through. Could you provide an example?
- astrange 5y agoAlas it's been a long time and I don't remember enough anymore. I just remember what I used to remember. There's some here (http://xahlee.info/Netiquette_dir/death_of_a_troll.html http://xahlee.info/Netiquette_dir/death_of_a_troll.html) and classic discussion can be found at (https://wiki.c2.com/?SocialProblemsOfLisp https://wiki.c2.com/?SocialProblemsOfLisp). The rest of the odd pattern of every Lisp programmer I've ever met being an asshole is mostly lost to IRC history, but I guess RMS is another example.
- plinkplonk 5y agoThe book skips major components of a lisp implementation - garbage collection, macros - as "bonus projects" to be implemented by nhe reader.
- desine 5y agoI've had this in my bookmarks for awhile, intending to work through it. I think I can probably even do it solo without the guide, at this point. After years of programming, and learning (or at least playing with) many languages, I've come to a philosophical conclusion of sorts: C and Lisp should be the two languages all students start with, in my opinion. Probably SICP style Scheme education, and classic simple C89. C is the barest of the high level, the least abstracted, the most work. Students should build their own data structures, memory management, improved string handling, etc. I think this gives a really solid foundation of what other languages' features actually do, their benefits and trade offs. Then Lisp, to show what metaprogramming can do, and demonstrate the power that a language can have. From there, sure, learn C++, Java, Rust, Go, Node.js, whatever toolset matches your industry. Start with the fundamentals, though.
- subtra3t 5y agoI wholeheartedly agree with you. Lisp is a perfect example of an underestimated programming language. It really is astonishing that most programmers (whom I know) consider Lisp to be this weird language with too many brackets.
- capableweb 5y ago> It really is astonishing that most programmers (whom I know) consider Lisp to be this weird language with too many brackets. Programmers (humans really) are really good at having knee-jerk reactions to things and then sticking with the same opinion for some reason. As engineers, you would think we'd be better at looking at things objectively, but somehow discussions/thinking around programming languages tend to be a very emotional thing for many, so they stick with their first impressions.
- andi999 5y agoThe real problem with lisp programs is each of them has its own DSL (the macros) so you have to learn one language per program. (I think that's the reason also why the library ecosystem is lacking)
- gjvc 5y ago
- fungiblecog 5y agomal is much, much better IMO: https://github.com/kanaka/mal https://github.com/kanaka/mal
- yur3i__ 5y agoMAL and this book serve different purposes, this book's purpose is learning C by writing a Lisp interpreter, whereas MAL is more focused on writing a Lisp interpreter and is language agnostic
- Koshkin 5y agoBuilding a simple Lisp interpreter which can be then embedded in your project is the single best thing that you can do. Configuration? Solved. Serialization? Solved. Separating the application logic from the gory details of its implementation? Done.
- rich_sasha 5y agoThat's one of the things that initially drew me to Lisp. If I had to embed a scripting language in something else, it may well be that the simplest thing is to write and embed a simple Lisp interpreter.
- coldacid 5y ago"Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp." -- Philip Greenspun
- thewakalix 5y agoIf you don’t have time to write an embedded Lisp interpreter yourself, store-bought is fine. (I recommend Guile.)
- vuonghv 5y agoIf you want to make your own langue, I recommend reading excellent book "Crafting Interpreters" by Bob Nystrom. http://craftinginterpreters.com/ http://craftinginterpreters.com/
- dang 5y agoThe main previous threads appear to be Learn C and Build Your Own Lisp (2014) - https://news.ycombinator.com/item?id=17478489 https://news.ycombinator.com/item?id=17478489 - July 2018 (86 comments) Learn C and build your own Lisp - https://news.ycombinator.com/item?id=10474717 https://news.ycombinator.com/item?id=10474717 - Oct 2015 (49 comments) Learn C and build your own Lisp - https://news.ycombinator.com/item?id=7530427 https://news.ycombinator.com/item?id=7530427 - April 2014 (145 comments)
- yewenjie 5y agoSome of the comments here don't like this book for various reasons. I'm curious - is there a (or two) recommended book which serves this purpose - learning C and building a lisp (= learning how programming languages work)?
- theiasson 5y agoThis book is on "Stuff that should be avoided" list[0]. [0] http://iso-9899.info/wiki/Main_Page#Stuff_that_should_be_avoided http://iso-9899.info/wiki/Main_Page#Stuff_that_should_be_avo...
- lewisjoe 5y agoLooks like a bunch of C gatekeepers got together and decided to reject any other path ways of learning C except their own.
- phonebucket 5y agoI have little C experience. I've always wanted to learn it properly to broaden my horizons, so I really respect the opinions of the gatekeepers: C is a small footprint language with plenty of footguns. It goes beyond matters of style and straight to things like memory leaks that can cause security issues.
- cbzbc 5y agoAt least some of the things on that list have long been bugbears and known as sources for either incorrect/erroneous explanations and code (most of Schildt's output for instance). So it may be an attempt at gatekeeping but on the face of it seems a reasonable one.
- heja2009 5y agoC programming - luckily in my opinion - has a culture of very rigorous evaluation of programming techniques especially towards memory-unsafe programming, arguably the biggest weakness of C as a programming language. This book uses gets() which is a function that can not be used safely. Any input that exceeds the buffer length will corrupt memory. The conventional wisdom in the C community is to NEVER use gets. I personally stopped reading in chapter 4 where this is done. Unfortunately strictly avoiding memory issues is somewhat involved und thus often ignored in C beginner books. It is also hard to see unless you are pretty familiar with C's pitfalls. IMHO this is why this list of bad books is desperately needed.
- scioxo 5y agoBe warned; Buildyourownlisp is a great book for novice C programmers looking to build more complicated projects but it's a very bad introduction to Lisp. Most of what makes Lisp great you won't find here.
- amanaplanacanal 5y agoWhen you say “lisp” are you specifically talking about Common Lisp, or the whole family of lisps? What is it missing?
- teataster 5y agoI worked through this book and I think is a fine way to get your feet wet with C. When I learn a new language, I like learning something else in the way, because language learning tends to be samey once you have gone through a couple. This book was right up my alley, cause you get a sense of language design and the very basics of C. After reading the book I managed to write some cli programs in C, modifying someone else's code. The main caveat about the book: It Is an introduction in both it's topics. I know the bare minimum of C and I could not design a language. Yes, the lisp you build... Well I would not use for anything. But is well written and it has exercises, and I believe exercises is how you learn.
- dspearson 5y agoI can also recommend the following books by Nils M Holm: LISP From Nothing (https://t3x.org/lfn/ https://t3x.org/lfn/) LISP System Implementation (https://www.t3x.org/lsi/ https://www.t3x.org/lsi/) Scheme 9 from Empty Space (https://t3x.org/s9book/ https://t3x.org/s9book/) They're more leaning towards the LISP implementation side, and far less on the learning C side, for which there are far better options.
- willcipriano 5y agoI made a Sean Connery themed language with this book: https://github.com/willcipriano/Connery https://github.com/willcipriano/Connery I recommend it, it was a lot of fun and I still tinker with the Connery from time to time.
- Decabytes 5y agoI’m a python programmer and my dream would be to learn C and an extension language like Guile or Ecl. Then I could write the performant bits in C and extend it with Lisp. I’m actually pretty proficient in Racket so I’m doing pretty well on the lisp side, but I’ve found the books for learning C lacking. I absolutely had “C a modern approach” and “Modern C”
- deleted 5y ago[deleted]