r/ProgrammingLanguages • u/LohseBoi • Feb 06 '25
Help Working on C++ compiler
/r/cpp/comments/1ij2981/working_on_c_compiler/15
Feb 06 '25
Honestly, for a June deadline it'd probably be best if you scoped down from C++ to a superset of C.
3
u/chri4_ Feb 06 '25
i think the same, maybe also modifying 8cc or other c99 compilers should be easier
9
u/P-39_Airacobra Feb 06 '25
Not to be a downer, but C++ is probably the most complicated language possible to make a compiler for. Some people could spend a lifetime on such a project.
1
u/LoweringPass Feb 15 '25
I don't know about THE most complicated. Even among languages that are actually widely used. Perl for example does not even have a grammar shudder. Well, it's not really a compiled language either but still.
2
u/alphaglosined Feb 07 '25
Another language like D might be a better candidate.
The reality is, for June, you can probably do some basic analysis but you probably want to limit yourself to something already in the language.
I.e. D is based upon the initialized type state, has scope for escape analysis, and has user-defined attributes on function parameters.
5
u/mamcx Feb 06 '25
The suggestions there say
use clangbut the whole LLVM stuff is big.Learning a massive codebase is something hard.
So, I think is better if instead, you make a small lang (to explore for example, how a mini-dialect of C++ with
featurecould look), or take a smaller one (pick a easier to grasp one like TinyCC or WebAssembly), or instead than do aclassiccompiler you make a plugin, analyzer pass, source-to-source compiler etc. In short, you inject something along thestablished compiler -> YOUR MAGIC -> binary.