Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Thanks for the recommendation, though I'd give the caveat that I've been rambling all over the place, especially in the later parts. I also have lots of changes after the latest part that I need to write about...

I'd really like to get a chance to take the time to retrospectively go over and tighten it up. The trouble with that is that it's easily 10 times+ as much effort to follow along with a project this way and write about each change as it is to cover the finished code (especially thorny issues such as how to avoid wasting too much time on bug fixes that may or may not have affected understanding of previous parts).

Personally, while I'm very happy that people find my series useful, I'd recommend perhaps supplementing or starting with Niklaus Wirth's books or Crenshaws "Let's write a compiler" (one of the ones recommended in the linked artile) for something much more focused. I feel the angles are sufficiently different that it's worth it. And Wirth is my big hero when it comes to language and compiler construction.

While the other suggestion in the article is well worth a read, I'd give one caveat: Lots of passes is hard to keep mental track of. My compiler sort-of does something similar in applying multiple transformation stages to the AST, and I'm mulling collapsing it into fewer stages rather than more because I feel it's getting more complex than necessary. You can work around some of the debugging complexity by outputting each stage to a suitable format so you can test each transformation individually, but it's still hard to keep track of exactly what each stage expects and delivers.



> You can work around some of the debugging complexity by outputting each stage to a suitable format so you can test each transformation individually, but it's still hard to keep track of exactly what each stage expects and delivers.

Honestly this sounds like a good case for a type system - which of course isn't available in ruby.


Of course it's available in Ruby. You just don't get ahead-of-time verification without lots of extra trouble (implementing it yourself). The problem is not that you can't specify pre-conditions, and use the type system to do it.

The problem is that either you create specialized IR's for each stage, or a lot of this is expressed through tree shape, and it's just painful to mentally keep track of more than it is painful to test.


Try Crystal, then?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: