[HN Gopher] Let's make a Teeny Tiny compiler ___________________________________________________________________ Let's make a Teeny Tiny compiler Author : whack Score : 82 points Date : 2020-06-06 19:50 UTC (3 hours ago) (HTM) web link (web.eecs.utk.edu) (TXT) w3m dump (web.eecs.utk.edu) | ngcc_hk wrote: | Python!? Anyway wait for part 2 and 3. | azhenley wrote: | I released Part 2 yesterday! (I had forgot to update the link, | which is now fixed.) | | http://web.eecs.utk.edu/~azh/blog/teenytinycompiler2.html | lixtra wrote: | I wonder if he left out the LET nums = nums - 1 | | on purpose. | melling wrote: | I've got a bunch of links about compilers in a GitHub repo: | | https://github.com/melling/ComputerLanguages/blob/master/com... | cellularmitosis wrote: | Nice! I have been collecting a list as well :) | https://gist.github.com/cellularmitosis/1f55f9679f064bcff029... | boudewijnrempt wrote: | What I always admired about the ZX-Spectrum's Basic was that it | skipped the entire idea of a lexer, because, well, the keyboard | let you input tokens directly. | jacobush wrote: | Which tied into how they could make the keyboard cheaper, | remember the rubber keys? :-) | Lerc wrote: | I think it was closer to the other way around. The keyboard let | you input tokens because it didn't have a lexer. | | I suspect this is more due to the memory cost of storing a | literal line of code more than the ROM or CPU cost of a lexer. | Going back to the ZX-80 storing even the current line being | typed as characters was probably a burden. | tachyonbeam wrote: | AFAIK the keyboard was also just very cheap and a pain to | type on. | webreac wrote: | I don't remember complaining about keyboard. The only issue | was loosing memory because the memory expansion (16ko) had | bad contacts. | cloogshicer wrote: | If you want to dive deeper into this topic, I also recommend the | wonderful book Crafting Interpreters by Bob Nystrom. It can even | be read for free online: http://craftinginterpreters.com/ | | I'm not affiliated with it, but I devoured it recently and | thought it was amazing. | azhenley wrote: | Author of Teeny Tiny here! I really like Crafting Interpreters | too (I link to it at the bottom). Also highly recommend the | book Writing an Interpreter in Go (https://amzn.to/2Saf28j). | mhh__ wrote: | 'tis a good book. | | Appel's compiler implementation in _x_ (if you choose anything | other than ML you don 't deserve to live) is a good follow on | userbinator wrote: | There seems to have been an explosion of such articles within the | past few years, despite things like Crenshaw's tutorial existing | for several decades; I wonder why a large number of people have | suddenly started thinking "I understand this, I should write an | article about it". | | My favourite demonstration of a "teeny tiny compiler" is still | C4: https://news.ycombinator.com/item?id=8558822 Perhaps it | inspired all these compiler articles? | staycoolboy wrote: | <I deleted this because it wasn't nice> | azhenley wrote: | Actually, my students were having trouble following other | tutorials so I wrote this for them. | | I'd summarize my tutorial as a shorter version of Crenshaw's. | | I love seeing more and more compiler tutorials. They all have | different goals and perspectives. | staycoolboy wrote: | Sorry, my comment wasn't in the HN spirit. | molticrystal wrote: | Always enjoyed Fabrice Bellard's work, like | https://bellard.org/otcc/ which is 2048 bytes and self compiles | & https://bellard.org/tcc/ , his TinyEmu and Javascript PC | Emulator that boots several OSes including linux are cool as | well. | mrlonglong wrote: | REPEAT seems superfluous as only ENDWHILE is needed to end the | loop. And, oh yes who forgot to decrement nums? | | Edit: s/N/nums ___________________________________________________________________ (page generated 2020-06-06 23:00 UTC)