fbpx

Replacing C

Replacing C

https://www.spiraltrain.nl/c-programmeren/

https://www.spiraltrain.nl/advanced-c-programmeren/

https://www.spiraltrain.nl/cpp-programmeren/

https://www.spiraltrain.nl/advanced-cplusplus-programmeren/

Co-creator of the D programming language Andrei Alexandrescu has taken it upon himself to assess the languages most likely to challenge the position that C currently holds in software development. He’s also encouraged reps from Go and Rust to give their honest opinions, too.

Andrei Alexandrescu is the co-creator of D, the multi-paradigm system programming language that is said to combine efficiency and control with safety and programmer productivity. He’s recently tried his hand at dissecting the handful of languages that are in line to replace C, one of the most widely used programming languages of all time.

Alexandrescu has published an honest response on Quora to the question of which language has the best chance at replacing C between D, Go and Rust. He’s also invited members of the Rust and Go communities in similar positions to share their own opinions, as un-biased as possible.

“10x advantages” and challenges

Alexandrescu was quick to point out that the discussion was missing an essential element in C++. Assuming the age of C++ alludes to the fact that it too would be supplanted alongside C, he’s called for it to be acknowledged as “the closest language to C and the obvious step up from it”.

Starting with D

Beginning on his home turf, Alexandrescu lists D’s “10x advantages” in four key areas:

  • Faster to compile than C++ for comparably-produced code
  • Faster than scripting languages for comparable convenience
  • Easier to interface with C and C++ than any other language
  • Better than any other system language at generic and generative programming

As for its challenges, Alexandrescu admits that D lacks vision and the absence of corporate support alongside scrappy documentation hasn’t helped to improve the situation. He also believes D’s poor adoption after being around for so long is another contributing factor.

The obvious concern for many developers with D is its very purposeful decision regarding garbage collection. Reddit user GoranM sums it up nicely:

GoranM

231 points 9 months ago

GC is a great invention, but the decision to use it for D has instantly alienated a core market

Yes, I think that’s exactly right, and I commend Andrei for being so straightforward about that.

I guess there is some argument about how to define a “systems language”, but I don’t think the label fits well on anything with GC.

Even if you had an extremely fast, state of the art collector (which I suppose is something that can be said about Go at this point), there are many cases in which the ever-present overhead will simply be unacceptable.

And yes, Rust has a disproportionate focus on one specific point (safety), but I think that’s basically the problem with all the “Big Agenda” languages, as Jonathan Blow called them.

 

Google’s Go

Go’s advantages for Alexandrescu read very expectedly like a language developed by Google should:

  • Better strategy
  • Solid engineering
  • Good branding

Similarly to D, Go faces its own issues with garbage collection and the fundamental slowdown it causes together with indirect calls:

Virtually no meaningful Go can be written without resorting to indirect function calls and garbage collection, which are central to its core features. These are major impediments to achieving in-core performance.

Alexandrescu’s opinion of Go’s politics and famous simplicity are also heralded under the challenges banner, calling the language “hopelessly pedestrian” thanks to its inability to abstract simple notions or algorithms.

The verdict on Rust

Once again underlining that this is merely his opinion, Alexandrescu sees a lot of potential in Rust:

  • Better PR
  • The only language of the three with world-class PL theorists on roster
  • Better safety than other systems programming languages

On the topic of safety, he highlights Rust’s preoccupation with being safe as part of the challenges it faces, citing disharmony behind the decision to put safe, precise memory management front and centre:

Unfortunately, that’s seldom the problem domain, which means a large fraction of the thinking and coding are dedicated to essentially a clerical job (which GC languages actually automate out of sight).

The final challenge would be Rust’s foreign syntax, which has no apparent advantage in its uniqueness according to Alexandrescu.

For projects to be wooed away from C and C++, the task will fall on the above languages to “play into their respective strengths and find creative solutions to their respective challenges”. But another question remains: Why does C need to be replaced in the first place? It’s a language that has significant historical weight; companies and developers have devoted decades worth of time and effort programming in it. Many other languages have based their syntax on C, so losing it would correspond to some serious fallout.

Alexandrescu goes into much more detail about the challenges that D, Go and Rust face in his original post here.