intrigued_66
intrigued_66

Reputation: 17230

Building a C++ compiler using erlang

Do you think its possible for a single person (average C++ experience) to build a non-commercial C++ compiler using Erlang, possibly concentrating on optimization?

I wasnt sure if this is completely unrealistic? Is there any advice people could give?

Is erlang the best language to use? I thought it would be good due to its pattern matching. Im not sure if it concurrency would help with writing a compiler??

EDIT: The reason for this is that I dont get to code C++ at work and I want to learn more about the language as I am interested in low latency work. I thought knowing the ins and outs via writing a compiler would be the best way?

Upvotes: 2

Views: 618

Answers (1)

Alex Wilson
Alex Wilson

Reputation: 6740

A C++ compiler is a lot of work. No, really, a lot of work. C++ is one of the hardest (if not the hardest) production languages to parse. Even just the front-end. Just try reading the standard, it's more than one thousand pages of dense text.

What do you want to use it for? LLVM has the Clang C/C++ front end and an extremely friendly and well-documented intermediate representation. I suggest you use something like this (from Erlang, appropriately adapted or otherwise) and concentrate on the optimisation stage - leaving the parsing to someone else.

Pattern matching does make for a nice compiler though. So Erlang/F#/Scala/Ocaml/Haskell will shine here.

Upvotes: 9

Related Questions