• 0 Posts
  • 27 Comments
Joined 1 year ago
cake
Cake day: June 30th, 2023

help-circle




  • I am currently writing a C compiler, with my own backend (and hopefully, frontend) in OCaml.

    But why write your own C frontend? It’s much more of a pain than people imagine. I maintain a C frontend implemented in OCaml (the project itself goes back 25 years) and it’s still not on par with GCC or Clang.

    For any other language, sure, but C has so many “wonderful” features, starting with the lexer hack. Your grammar conveniently overlooks this issue but it’s something you’ll have to deal with to actually implement it. So it simply won’t be as nice as theory suggests.












  • It’s not necessarily about the load, it’s about the algorithmic complexity. Going from lists (lines in a file, characters in a line) to trees introduces a potentially exponential increase in complexity due to the number of ways the same list of elements can be organized into a tree.

    Also, you’re underestimating the amount of processing. It’s not about pure CPU computations but RAM access or even I/O. Even existing non-semantic diff implementations are unexpectedly inadequate in terms of performance. You clearly haven’t tried diffing multi-GB log files.