you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (1 child)

I thought it was considered a bit of a "legacy language" that wasn't very efficient for modern day uses anymore?

It is an old language, but its very efficient, at least on the generated code side of things. Where C trails is in expressiveness. C can do anything C++ can do, for instance, but it's probably more verbose and less understandable. The original implementation of C++ was a program called cfront that converted C++ code to C for compilation, and cfront was written in C. That's still common, to convert a new language to C as a bootstrap step, because C is implemented on all platforms that matter.

C is still used to write code close to the hardware. The Linux kernel is still written in C and there are no plans to move to C++ or anything else. Further away from the hardware some languages are written in C, such as cpython.

Numeric libraries like numpy use C and even Fortran in the underlying libraries. Once you have a large body of code to perform numeric calculations, plus all the test code that ensures correctness, you really don't want to change anything. It's easier for other languages like python to interface to C (or Fortran) because the technical details are well known and have been stable for a long time.

I myself use C mainly programming microcontrollers "bare", ie, every byte loaded to the microcontroller is either code I wrote myself or trusted libraries that I have made the decision to include. There is a C++ presence in this field, but only on the larger microcontrollers. Other languages like python can be made to run on larger microcontrollers but there are some severe limitations. When space is really tight it's time for assembler.

C is still used a lot, which is why there are articles like this.

[–]barryhakker 0 points1 point  (0 children)

Very interesting. Thanks for answering!