←back to thread

611 points LorenDB | 6 comments | | HN request time: 1.654s | source | bottom
Show context
markus_zhang ◴[] No.43908006[source]
What if we have a C that removes the quirks without adding too much brain drain?

So no implicit type conversions, safer strings, etc.

replies(10): >>43908024 #>>43908037 #>>43908071 #>>43908130 #>>43908141 #>>43908193 #>>43908341 #>>43908840 #>>43909556 #>>43913099 #
1. wffurr ◴[] No.43908024[source]
This seems like such an obvious thing to have - where is it? Zig, Odin, etc. all seem much more ambitious.
replies(3): >>43908123 #>>43908201 #>>43908346 #
2. steveklabnik ◴[] No.43908123[source]
There have been attempts over the years. See here, a decade ago: https://blog.regehr.org/archives/1287

> eventually I came to the depressing conclusion that there’s no way to get a group of C experts — even if they are knowledgable, intelligent, and otherwise reasonable — to agree on the Friendly C dialect. There are just too many variations, each with its own set of performance tradeoffs, for consensus to be possible.

replies(1): >>43914808 #
3. zyedidia ◴[] No.43908201[source]
I think the only "C replacement" that is comparable in complexity to C is [Hare](https://harelang.org/), but several shortcomings make it unsuitable as an actual C replacement in many cases (little/no multithreading, no support for macOS/Windows, no LLVM or GCC support, etc.).
replies(1): >>43909591 #
4. IshKebab ◴[] No.43908346[source]
I think if you are going to fix C's footguns you'll have to change so much you end up with a totally new language anyway, and then why not be ambitious? It costs a lot to learn a new language and people aren't going to bother if the only benefit it brings is things that can sort of mostly be caught with compiler warnings and static analysis.
5. Zambyte ◴[] No.43909591[source]
And why do you think Zig (and Odin, but I'm not really familiar with that one) is not comparable in complexity to C? If you start with C, replace the preprocessor language with the host language, replace undefined behavior with illegal behavior (panics in debug builds), add different pointer types for different types of pointers (single object pointers, many object pointers, fat many object pointers (slices), nullable pointers), and make a few syntactic changes (types go after the names of values in declarations, pointer dereference is a postfix operator, add defer to move expressions like deallocation to the end of the scope) and write a new standard library, you pretty much have Zig.
6. wffurr ◴[] No.43914808[source]
That was fascinating reading and a graveyard of abandoned "better C" dialects: SaferC, Friendly C, Checked C, etc.