5 ms·
* compiler without optimization phase
by mati365 3y ago
* compiler without optimization phase
- TheChaplain 3y agoProbably adheres to the principle; "Make it work, then make it fast"
- kevindamm 3y agoIt's actually three steps: make it, make it work, make it work faster. this may actually be somewhere between step one and two.
- phtrivier 3y agoIf I read the article correctly, it's actually "a compiler for a language that only supports basic arithmetic, without a lexer, a parser, symbols, nor an optimization phase". Which _is_ surprisingly easy to write. But it might be a stretch to call it "a compiler" :D
- cmrdporcupine 3y agoYeah, I've written stuff like this many times -- mostly producing AST then bytecode, etc. I never really wanted to call it a 'compiler' per se though that's what it is. Because I generally stand in awe of serious optimizing compiler engineers, they have deep domain expertise that is admirable.
- mattgreenrocks 3y agoTrue, but no need to self-gatekeep the terminology here just to appease a rando commenter. :)
- ozim 3y agoYes draw two circles and then the rest of the owl kind of thing.
- eichin 3y agoEh, a college friend put together a C compiler in 100 lines of yacc (not particularly golfed, either, C just isn't that sophisticated.) Great for playing with "what if C + this one feature" kind of things in a concrete way. So from my perspective, not a stretch at all...
- sebastianmestre 3y agoParsing and symbol resolution on simple languages is kinda trivial in my opinion, but I'll probably write some articles about that stuff later Control flow and pointers are coming in the next part, and it's still surprisingly easy
- phtrivier 3y agoIs memory / register allocation in your roadmap too ? (honest question, I'm not sure it's in the scope of your articles)
- sebastianmestre 3y agoRegister allocation is not on the roadmap, I think it's too hard for this series... But maybe I just haven't figured out an easy enough way to do it yet :^) Memory allocation? You mean making a heap allocator? In the spirit of lowering the bar for creating new languages, I lean more towards calling into libc's malloc instead of building a custom solution haha
- acchow 3y ago* compiler without good error messages
- musicale 3y agoClang may have better static checking, but Apple's MPW C compiler still had better error messages. https://news.ycombinator.com/item?id=37283375 https://news.ycombinator.com/item?id=37283375
- deleted 3y ago[deleted]
- acchow 3y agoCute and whimsical, but I was thinking along the lines of context for answering "why?" "..because it was defined at [....] and used [....] and [...] as a int32 type (thus coerced to int64), but passed in [...] as a"
- zem 3y agoif you use the nanopass approach you can add optimisation phases relatively easily
- agumonkey 3y agobut since he hardcodes the register allocation, i wonder how he can control anything here
- mepian 3y agoAs opposed to a tree-walking interpreter, which is usually presented as the only viable way to write your first programming language implementation.
- mamcx 3y agoAka: a compiler. A compiler is just `source -> generate -> target`. All the other fancy things are optional. IMPORTANT things, but don't detract from calling it a "compiler". --- This is similar to anything else: A single `.html` served on `:80` is a website. A 2d, grayscale `pacman` is a videogame. `print("hello world")` is a program, etc.
- aatd86 3y agoAka a function tongue-in-cheek :p
- deleted 3y ago[deleted]
- FeepingCreature 3y agoIf you cared about performance, you'd feed it into LLVM anyways.