6 ms·
This is a fair point, but it brings to mind another point I didn't really understand till the last couple of years. Learning about how compilers work is just as
by andrewvc 13y ago
This is a fair point, but it brings to mind another point I didn't really understand till the last couple of years. Learning about how compilers work is just as important. Building a small lisp compiler was a life-changing experience for me in terms of going one level deeper, as much as understanding C was. For those who've never written lisp before, the reason I recommend a lisp compiler is that lisp compilers are the simplest to write, and the most expressive in terms of runtime strategy since lisp syntax mirrors a compiler's IR (intermediate representation). I think this is just as important in todays world because languages like Ruby and Javascript are both directly inspired by lisp. We also live in a world where Clojure is seeing a steady rise, for once a Lisp with large potential for significant commercial adoption.
I can highly recommend the book Lisp in Small Pieces, $93 on amazon, and worth every penny. Walking through the building blocks and design decisions of a language changes the way you code. Every language you look at winds up being internally translated into your own IR whether you've written a compiler or not. Understanding the inner workings of a compiler however adds depth.
- mbel 13y agoI totally agree; actually a small, incomplete Scheme interpreter (which may be used to develop a lisp compiler later on) can be easily created in few hours (depending on used language) [0], without any prior experience. It's surely not as deep learning experience as building a compiler, but I think it's still worthwhile. [0] http://norvig.com/lispy.html http://norvig.com/lispy.html
- irahul 13y agoA more complete interpreter: http://norvig.com/lispy2.html http://norvig.com/lispy2.html
- z3phyr 13y agohttp://en.m.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours http://en.m.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48... Write yourself scheme in 48 hours (with haskell). Great learning experiance!!
- fdr_cs 13y agoI do recomend SICP .
- dmix 13y agoThe SICP Stanford videos by Sussman from the 80s and reading the book was an experience that sounds almost exactly like the author had learning C. It was one of the moments where I realized I enjoyed programming as much (or more) than design.
- betterunix 13y ago"lisp compilers are the simplest to write" I think Forth may have that honor, and people have done some pretty amazing things with simple Forth implementations. I do agree, though, that writing a simple Lisp compiler is a worthwhile exercise, and the Lisp In Small Pieces is a book everyone should have on their shelf.
- dysoco 13y agoI would say Brainfuck is even easier.
- gngeal 13y agoReally? I'd say that a Forth compiler in Forth is going to be somewhat smaller than a Brainfuck compiler in Brainfuck.
- Falling3 13y agoWell probably... but no one said anything about bootstrapping being a requirement.
- gngeal 13y agoThe LiSP book only describes self-hosting implementations while in Forth it's heresy to implement it in anything else than Forth or assembly. Well, perhaps Java implementations are excused for not being implemented in terms of themselves. :-)
- dasmoth 13y agoIt's been done: http://jikesrvm.org/ http://jikesrvm.org/ Historically, the performance was pretty decent. I don't know how it stacks up against Hotspot today, but I note it does still seem to be a live project after >10 years.
- deleted 13y ago[deleted]
- tptacek 13y agoWrite an emulator! If you write an emulator, you can probably skip "learning C".
- dpritchett 13y agoWhat might I read to begin to learn which platform to emulate and how to get started?
- tptacek 13y agohttps://news.ycombinator.com/item?id=5786842 https://news.ycombinator.com/item?id=5786842
- webreac 13y agoI do not understand the hype around clojure. I think functional programming languages have mainly evolved to introduce stronger typing and to remove the parenthesis. I wish a great future to scala (and haskell). For me, clojure is outdated.
- siddboots 13y agoI suppose it's because functional programming isn't a one-trick shop. There is a paradigm that comes out of lisp macros that can't be accomplished within a language like Scala or Haskell, even though those languages are superior in many other respects.
- webreac 13y agoscala has also macros since 2.10.0 : http://scalamacros.org/ http://scalamacros.org/ Is there something special in clojure macros ?
- willismichael 13y agoClojure macros were designed in from the beginning, and thus a significant portion of Clojure core is built using macros. Also, to repeat an oft-stated argument, Clojure is homoiconic, making it much easier to treat code as data, and data as code, which dovetails quite nicely with the macro system.
- happy_dino 13y ago> a significant portion of Clojure core is built using macros Well, pretty much all the Scala compiler is written using macros, because compiler API ~= macro API. Homoiconicity is nice, but the lack of it doesn't make anything impossible. If there is anything which makes stuff impossible, it's the static type system, which can catch most of your macro errors at compile time. That's a pretty good thing in my book.
- zedshaw 13y agoHell yeah, learning how to make compilers should be what a BS in CS is all about. Pretty much everything in computer science can be turned into a language and compilers have almost all of the major topics in CS as one easily explainable thing. It's also one of the few parts of CS that stands on a solid logical proof filled footing and is still insanely practical. I basically teach baby compiler theory at the end of my Python book without people even noticing because I think parsing at a minimum is so important.