RE: Complicated AST manipulation looks ugly in C++. How to refactor it?
January 27, 2022 at 5:58 pm
(This post was last modified: January 27, 2022 at 5:58 pm by Angrboda.)
(January 27, 2022 at 5:29 pm)HappySkeptic Wrote:(January 27, 2022 at 2:16 pm)Jehanne Wrote: Isn't that the whole point of a compiler, to translate computer code into machine code? I would ditch the C++ and just use C, modeling your new language on an existing one. C#, after all, "borrowed" heavily from Java.
Anyone writing complex code in C is crazy or a masochist. C++ at least has the standard template library (even if it is a pain to learn).
Using C++ allows Flat to potentially compile his compiler into any platform, including webassembly. Yes, that can be done with other languages, but it isn't easy with garbage-collected languages.
It's a matter of trade-offs. Hand-optimizing C is a lot more effective than trying to optimize object-based code. Time is money with compliers.
![[Image: extraordinarywoo-sig.jpg]](https://i.postimg.cc/zf86M5L7/extraordinarywoo-sig.jpg)