Live data from Hacker News

The case against a C alternative (2022)

c3.handmade.network

31–40 of 84 posts

Re: The case against a C alternative (2022)

#31
Several of the arguments are not compelling.

For instance:

"The C language is not just the language itself but all the developer tools developed for the language. Do you want to do static analysis on your source code?"

This is a finite problem set. For instance, AI could auto-create useful toolings eventually. And even without AI, people can. Even more so if a new language is designed with that in mind from the get go. So, perhaps it would be a lot of effort, but this is really not the reason why C is so dominating.

> The uncertainties of a new language

> Before a language has matured, it's likely to have bugs and might change significantly to address problems with language semantic.

Here I somewhat agree. Another language is different, that is true, and may not be better, that is also true. I am still not convinced Rust is better than C, for instance.

However had, I also don't this this as unsolvable. Many new languages are in part better than C. I mean, I notice this when I write ruby code and C code. Let's ignore the speed problem; and the fact that ruby is written mostly in C (which kind of shows that C dominates everything). The ruby code I write is about 1000000000x easier to understand, simpler and almost always shorter than C. There is no comparison here. Ruby is the better programming language. C is faster and more efficient. And this is also significant. My prediction is that a language that would be able to replace C, needs to target both the speed issue without compromise AND the efficiency of writing code, be it ruby-like, python-like and so forth. And neither of these two languages try to replace C either, so they don't quite count here.

> And what about maintainers? Sure, an open source language can be forked, but I doubt many companies are interested in using a language that they further down the line might be forced to maintain.

This is a problem, but you have this problem with corporations too. For instance, Go is controlled by Google, as is Flutter/Dart. Google can babble that everyone can contribute but the reality of the situation is that Google decides what happens; same with the adChromium code base. Personally I really don't want corporations to dictate their world view onto a language. Committees can also have problems or be bribed and what not, we can see the chaos in the C++ committee too, even without bribery - stupidity often rules supreme. But by and large, I much prefer single benevolent dictators or indepedent (as much as possible) committees than mega-evil mega-huge greedy corporations controlling a language. This does not automatically mean a language is better or worse, either way, but it is a preference for me. And I know for a fact that many others somewhat or strongly agree with this too, except a few die-hard Google fanbois (but most of them are employed by Google anyway, so their "opinion" does not count; I see the same problem with shopify and ruby, by the way, it's really interesting).

> 3. The language might just not be good enough > Is the language even addressing the real pain points of C? It turns out that people don't always agree on what the pain points with C is.

Yup, that is also true, see Rust. On the other hand, I think cargo is really useful, and even C++ agreed. I think C also did not that long ago, but boy, for many decades C thought that easy download of add-ons is not needed. C changes very slowly. I understand that this is often nice, but just as in the example of cargo and what not, this was really STUPID of C to not change here.

Other than that I agree on the general point. Many changes are also idiotic in other languages. Ruby incorporated many idiotic changes too; thankfully I can avoid most of them so I just ignore them indeed.

> A new language will naturally have a much smaller pool of experienced developers. For any middle to large company that's a huge problem. The more developers there are available for a company, the better they like it.

That's also true, e. g. look how few developers use D. I think the only way to change this is to make the language SIMPLE, EASY but also efficient at the same time. Like python. Though python is not aiming to be a replacement of C, so it does not count - but people are quite easily able to learn and use it. C is much harder to use; just give new recruits a task to implement things that manipulate memory and pointers a lot.

> The C ABI is the standard for interoperability

Any language can have that too so I don't see this as a problem.

> 1. Better syntax

> Having a "better syntax" than C is mostly subjective.

Wrong. And this is what 99% of those "I will replace C with my language XYZ" get wrong. The syntax they use usually SUCKS. They think syntax matters absolutely not at all. They are wrong. But they think they are right, so they write a useless pile of crap and then wonder why nobody writes in that language.

> 2. Safer than C > Any C alternative will be expected to be on par with C in performance. The problem is that C have practically no checks, so any safety checks put into the competing language will have a runtime cost, which often is unacceptable.

This is partially correct, partially wrong. Rust showed that safety is a feature; C++ agreed. C does not. I understand the speed penalty, and I am not saying you need to make safety a pseudo-religion like Rust did, but that trade-off needs to be determinable by the code author. So, some code can be fast like in C; for other code the trade-off may be different. A language should make it super-easy to distinguish here. Rust does not make it super-easy. C even less.

> Programmer productivity

> First of all, pretty much all languages ever will make vacuous claims of "higher programmer productivity". The problem is that for a business this usually doesn't matter. Why? Because the actual programming is not the main time sink. In a business, what takes time is to actually figure out what the task really is. So something like a 10% or 20% "productivity boost" won't even register. A 100% increase in productivity might show, but even that isn't guaranteed.

Also totally wrong. Yes, writing code is not always the bottle neck, but what he forgets is the simplicity of writing good, fast code. If it takes 5 hours to write 3 lines of code, something is wrong with the language itself.

Re: The case against a C alternative (2022)

#32

The overarching argument in this article seems to be sort of chicken and an egg. > 4. No experienced developers Well, with C you need experienced devs that are also EXPERIENCED IN C. You can write C that compiles but is all kinds of incorrect, usually subtly. Any new language that works with the dev on writing correct code or outright refuses to compile with incorrect code (hinting at Rust here) cracks this egg a bit…

Yeah, it's not that the hurdles pointed out in this article are wrong, but IMO the jump from "it's very hard" to "it's impossible" isn't convincingly argued. In discussions of the future of C, something along the lines of "C is never going away" is frequently said, which I think is both right and wrong, depending on what precisely you mean by "going away". If you ask me, C is not going away in the same way that Fortr…

> But for C as a culturally defining language in computing, I think the tide is already turning.

The problem still is which language will replace C here.

C++ won't.

Neither will Rust or Java.

So which language will replace C here?

I agree that C and Fortran can not be compared really. C will remain for a very long time to come.

Re: The case against a C alternative (2022)

#34
post #7

To me the case against a C alternative is simple. C is like Math. It is the fundamental high level language. There can be no alternative.. Rust made the mistake of thinking it can be low level AND safe. It tried to have the cake and eat it too. That will be its downfall.

Mathematics has much less tolerance for "undefined".

> thinking it can be low level AND safe.

"low level and unsafe" is something that people will eventually get tired of once there is a big enough disaster. Or at least start slapping Prop 65 warnings on unsafe products.

Re: The case against a C alternative (2022)

#35

The overarching argument in this article seems to be sort of chicken and an egg. > 4. No experienced developers Well, with C you need experienced devs that are also EXPERIENCED IN C. You can write C that compiles but is all kinds of incorrect, usually subtly. Any new language that works with the dev on writing correct code or outright refuses to compile with incorrect code (hinting at Rust here) cracks this egg a bit…

> Any new language that works with the dev on writing correct code or outright refuses to compile with incorrect code (hinting at Rust here)

I've started writing Rust in the past year and... honestly... I LOVE it.

But what kept me away from Rust for a long time is this talking point of rejecting incorrect code which is so obviously wrong it made proponents of Rust sound very cultish to me.

Rust cannot prevent incorrect code, nor is this possible (halting problem).

What Rust can do is enforce a very specific type of correctness, which may be termed resource-use-correctness. Basically it can enforce that every resource that is used, is properly opened, is properly accessed, has (one writer) OR (multiple readers and no writer) at a time, and is properly closed. It can do this for memory, files, sockets, as well as arbitrary constructs of your choice.

This ability is extremely valuable!

But it is also quite easy to write incorrect buggy programs in Rust, for the very simple reason that it is very easy to write incorrect buggy programs that do not misuse their resources.

Re: The case against a C alternative (2022)

#36
post #11

To me, the value of C is the interop story. Is there a modern language with ABI stability that can replace C for that? As in, you can wrap anything with a C API and be sure that it can be called from any other language easily?

The interop story is largely a self-fulfilling prophecy. When you start to explore the edges of C ABI compatibility you discover that er... there's actually no ABI compatibility unless somebody did the work and they never did the work. Two C implementations on the same CPU with 64-bit integers both, unsurprisingly, think 64-bit integers work the same way - because that was obvious. Now, how about 128-bit integers. Ah…

Somebody did do the work! The System V AMD64 ABI definitely defines the registers for __int128, e.g. as first argument to a function it will always be rdi (lo) rsi (hi) and for return value it will always be rax (lo) rdx (hi).

Re: The case against a C alternative (2022)

#37
post #2

Pretty unconvincing arguments overall. Mostly boils down to "any new language will start as new and not mature". Dismisses any "killer feature" in C's design space. Ignores that there is already a well established C alternative: C++. But obviously nothing will replace C in the sense that C will cease to exist.

This one struck me in particular as unconvincing:

> The problem is that C have practically no checks, so any safety checks put into the competing language will have a runtime cost, which often is unacceptable.

Why would all possible checks that provide an improvement over C be runtime-only?

Re: The case against a C alternative (2022)

#38
post #11

To me, the value of C is the interop story. Is there a modern language with ABI stability that can replace C for that? As in, you can wrap anything with a C API and be sure that it can be called from any other language easily?

The interop story is largely a self-fulfilling prophecy. When you start to explore the edges of C ABI compatibility you discover that er... there's actually no ABI compatibility unless somebody did the work and they never did the work. Two C implementations on the same CPU with 64-bit integers both, unsurprisingly, think 64-bit integers work the same way - because that was obvious. Now, how about 128-bit integers. Ah…

128-bit integers aren’t part of the standard (yet)… but the point is right; platform and architecture matter. Many aspects of them are defined by the compiler implementation.

Also ABI compatibility isn’t part of the C specification. Most implementers use System V ABI compatibility guidelines. Many compilers can output code for different ABI’s calling conventions. There’s more than one! Which you use depends on how crufty the code is and on the platform you are using.

I think the big advantage of C like languages here is the plethora of implementation defined platforms. That’s a huge network effect. If you want to target the 6502? There’s a compiler for it. Some chip you’ve never heard of? Probably some fork of GCC that targets it. Want to call some library function in some foreign binary written in a completely unknown language? If you can finagle the bytes and reverse engineer the calling conventions you can do it with C.

I think it might be that C does leave so much out of the specification and up to the implementation and platform that makes it unique and useful at times.

Re: The case against a C alternative (2022)

#40
post #6

I am guilty in a sense, I started a new programming language called C+ and one of the pillars I set was that it should not be an alternative to C (or any other language), in fact it uses Clang as its compiler, most of the points in the article still hold, but I hope it doesn’t stop people from coming up with new ideas and actually implementing them in this field, you don't have to be next big thing to be awesome

I like to program in a C++ subset that's basically C plus a sprinkling of ergonomic quality of life C++ features eg references and generic containers. I think of it as C+. (Edit: No disrespect meant. I just thought such completely different language concepts potentially sharing the same name was kind of amusing)

no worry, name is intentional, it's C + packages, language itself is tiny, strictly bounded by the C ABI, and doesn't include most of the features you'd expect in a language, even standard library is just a external package, so it's not a subset of C++ at all
Post reply on HN