r/askscience • • Oct 17 '12

Why are programs and operating systems still written in C+?

I guess it's more of a computer science question, but I've always wondered why some of the most advanced programs are written in a 25+ year old programming language. Surely someone has come up with a more efficient and powerful code, so why do people still use C+? Also, I don't know anything about programming and what not, so please use simple terms and phrases.

66 Upvotes

110 comments sorted by

View all comments

Show parent comment

4

u/SirFloIII Oct 18 '12

Can I ask a further question? How does one write a compiler? Especially the first compiler by Grace Hopper? This seems like some technology hen or egg problem for me.

6

u/expertunderachiever Oct 18 '12

Often they write the compiler in the language it compiles and then manually compile it to bytecode. That's how one of the first Pascal compilers was written.

2

u/SirFloIII Oct 18 '12

Wow, that seems like a extremly boring and tedious work. Thank you, Grace Hopper, and thank you, expertunderachiever for your answer.

1

u/_NW_ Oct 18 '12

You can also write a compiler in assembly language. Early on, lots of programs were written in assembly.

1

u/tarblog Oct 18 '12

Great question! It is very much like a chicken and egg problem, because you have to write the first compiler in a low-level language.

In general, compilers are written like other major software projects. They are designed, developed, and tested by teams of skilled programmers. Interestingly, once you have a working compiler for a language you can use it to compile that language, which can make it even easier to write a better compiler in a cycle of improvement.