My good friend Olve Maudal said something the other day that caught my ear. He said C will never be replaced.
I think he's right.
Languages like Java and Ruby are great languages when you don't need to get near to the metal.
But if you do need to get near to the metal, then C has already filled that niche so well that it's hard to see it ever being replaced.
You might say that a language like C, but without C's penchant for undefined behaviour, could somehow replace C.
I don't think so.
The point is that the sweet spot for a language designed to be used close to the metal is a language
that deliberately does
not get rid of its undefined behaviour.
Because that is part of it being in the sweet spot.
And besides, C has been around long enough that if a language was going to replace C wouldn't it already have happened?
While I don't entirely disagree with you I do think that languages like C++, D or (possibly - I haven't tried it) Go do have the potential to replace C.
ReplyDeleteThey all have the advantage that you can "hit the metal" just as much as C - but also support higher level features. This allows you to move, almost seamlessly, between lower and higher levels in the same code-base.
That could also be seen as a negative. Particularly in the case of C++ it introduces other dimensions of complexity that could potentially make it even less safe.
The more modern counterparts, such as D and Go, mostly concentrate on reducing that spiraling complexity, while attempting (at least in the case of D) to retain the power and expressiveness of a language like C++.
So I think the reasons are not technical. The biggest reason, I think, is one of mindset. There's a lot of people who do C, and do it well, but are just not interested in moving to C++, et al. Why would they be? What does it offer *them*?
Then there's the fact that C's ABI has become the lingua franca of language interop. If you have to know C anyway to write at a systems level why not just write C?
But in the end I think being "replaced" is the wrong way to look at it.
There certainly is a lot of systems level code being written in C++ and other languages. In those instances C has been replaced.
But it remains true that C is going to be around - even for new codebases - for a long time to come.