Hacker News new | past | comments | ask | show | jobs | submit login

If you're going to write a compiler, please, for the love of Bjarne Stroustrup, don't write it in C++. There are so many better modern languages for writing a compiler: OCaml, Haskell, Rust, and Terra to name a few. You really want features like algebraic data types and a sane package manager in your language of choice. In my mind, the only use case for C++ is interfacing with existing C++ libraries/codebases. All other tasks can be better relegated to superior languages.



What you say is very true, so cant think why you got downvoted. Compilers are so much easier to write in dialects of ML. Anything that has algebraic data types and pattern matching makes life a lot easier. I think one can save a lot of effort by writing large parts of the compiler in a language that has such support.


Golang's compiler was originally written in C++, so people are actively avoiding your advice.


no, it wasn't. the go compilers initially came from Plan 9, which hasn't seen any C++ code ever :)


"Came from Plan 9". What does that mean?


Plan 9 was a research OS that was sort of intended to be a "next generation" Unix. The Golang project is led by at least one person who worked on the Plan 9 OS, and overall it seems to be heavily inspired by Plan 9's design.

https://en.wikipedia.org/wiki/Plan_9_from_Bell_Labs


Yes, I know that. But I don't understand the implication that Go came magically from Plan 9. I recall reading Kernighan stating that the first Go compiler was written in C++ before bootstrapping.


Sorry, I misunderstood your comment. I think the original poster was referring to the Plan 9 team's strong preference for C over C++. Plan 9 was written with a modified version of C, and the developers seemed to be very interested in evolving the C language. As far as I can tell, they never used C++.

> In the presentation before the awarding of the Japan Prize today, you were quoted on the distinction between research and development. [The former, Thompson stated, was directionless, whereas development had a specific goal in mind.] So in that context, is Go experimental? > Yes. When the three of us [Thompson, Rob Pike, and Robert Griesemer] got started, it was pure research. The three of us got together and decided that we hated C++. [laughter] [1]

It looks like you were half-right about the early Go compiler being partly written in C++: There were two compilers, and "gccgo" had a C++ front-end, while their homemade compiler "gc" was written entirely in C. [2]

[1] http://www.drdobbs.com/open-source/interview-with-ken-thomps...

[2] https://golang.org/doc/faq#What_compiler_technology_is_used_...



People can and do write compilers in C++, clearly, but that doesn't make the language any better. The mistakes of others need not justify one's own!




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

Search: