- enumerate everything C is doing bad.
- presents fixes with a full bag of unnecessary features that no c programmer wants.
I wonder why there is no "Fixed C".
- enumerate everything C is doing bad.
- presents fixes with a full bag of unnecessary features that no c programmer wants.
I wonder why there is no "Fixed C".
Fortunately, you can simply not use any feature you find unnecessary. We won't harangue you about it, I promise! (Well, maybe a little bit if it's so cool we just can't resist.)
So on Apple platforms they will eventually have to deal with C++ and Swift no matter what.
On Microsoft platforms, they complain about C support and get shown the door to C++.
And on Google platforms, given the years of ignoring security advices, starting with Android 11, hardware memory tagging is a required feature, with the kernel randomly attaching GWP-ASan to processes, while on ChromeOS Linux gets to run on a hypervisor sandbox.
What I got: some 50,000 foot pure functional typeless language with loads of magic in the compiler that you'll never be able to reason about without having written one yourself.
That's the problem. This isn't a technology issue, it's a social one.
examples in top of my head:
- adding object oriented feature like built-in constructor/destructor while only default values are needed as week as a defer statement.
- weird template, while I can sense that we only want a proper hygienic macro system.
And "array type", pointer with length, to deal with contiguous memory.
The rest is well described in the video, but those 3 points are my major issues.
Also array type is the single biggest thing required to fix C. How many bugs in big C projects are caused by bad indexing and overruns.
On top of, "oh no free features".
The remaining C usage is a mix of existing domain expertise, existing large codebases impractical to migrate to anything else (eg, Linux), or a rejection of anything more than what C provides.
In all of those cases anything that's not exactly C is unlikely to motivate any changes. The users that could change to a "Fixed C" already did decades ago.
I can understand that "you don't have to use any features if you don't want to" is somewhat silly when talking about C++, since it has so many features that can bite you when you least expect it, especially when dealing with years of legacy code. D is far better designed than C++, however; it would not take you nearly as long to learn enough D to be comfortable reading others' code.
All I'm trying to say is that "C, but without the problems" might actually look more like BetterC than you think it does. True zero-cost abstractions are clearly still an unsolved problem, but abstractions are a necessity. C's niche is rapidly disappearing.
Also, out of curiosity, what don't you like about Zig? I saw this on your website, but I couldn't find any specific issues you'd had with it.
> Wow, Zig is competitive with assembly?
> Yeah, I totally had the same reaction. I’m interested to see how it measures up under more typical workloads. People keep asking me what I think about Zig in general, and I think it has potential, but I also have a lot of complaints. It’s not likely to replace C for me, but it might have a place somewhere in my stack.
It's just the CS community, at some point when you are writing languages you tend to try to outsmart the language you are fixing by creating overly complex behavior. Over-engineering is every single new languages.
Even Zig fails to do better than C, I think it's syntactically a disaster.
Here is a few lines from the documentation:
const ptr = @intToPtr(?*i32, 0x0);
while (it.next()) |item| { /* ... */ }
pub fn main() anyerror!void { /* ... */ }
exe.addCSourceFile("test.c", [_][]const u8{"-std=c99"});
const file = std.fs.cwd().openFile("does_not_exist/foo.txt", .{}) catch |err| label: { /* ... */ }Here's what I see in your example:
- @ indicates built-in function, which avoids namespace collisions.
- Optional types via the ?, which solves the null pointer problem.
- Real iterators, which are less error-prone and nicer to read than traditional for loops in a lot of common applications.
- The || syntax is better than something like `for (type var : array)` in Java, don't you think? Especially since it works with any iterator?
- anyerror!void is a nice way of saying that the function can return an error. Remember that we don't have exceptions here.
- It has interoperability with (multiple standards of) C.
- Error handling is higher-level and less error-prone than in C without exceptions that can create hidden jumps in your code.
So it clearly solves issues that people run into frequently in C. It brings in a nice sampling of high-level language features without doing anything that would compromise its niche as a systems language. It still has manual memory management and does not have exceptions. The behavior is simpler and requires that you language-lawyer the specification for undefined behavior far less often than in C. Your knowledge of C isn't necessarily enough to be able to immediately read Zig code, but that's because Zig isn't C. It's not hard to learn.
I actually already knew everything. I watched closely the development of Zig, and just give up when I realized all those decisions where made carelessly in my view or I just simply disagree with the direction of the syntax.
Since you took your time I will take mine to address what I don't like:
- There is no way to write "int" by default. I understand why. But I don't agree.
- struct and enum statements (within braces) are separated by a comma which is inconsistent with statements in function separated with ",". In my view expect a difference between parameters and statements. parameters (a,b,c) statement {a;b;c}
- You have to type "var" or "const" everywhere, but not in struct statement and enum statement. Sometimes it's like a "def" sometimes not.
- You have to type const when importing module:
const std = @import("std"); // Why ? Why should I specify const, this should be inferred. Same when I define a struct.
- the "undefined" keyword when it means "uninitialized" even in the documentation. var my_var: i32 = undefined;
- The worst, no default values for struct.- The list of keywords is insane: errdefer, allowzero, orelse, unreachable, anyerror
- About iterator I was doing well with:
while(get_next(context, &item)) { /* ... */ }
It's like everything has been carefully design to be even less readable than C code. I have the feeling that the syntax help more the compiler than de developer.I wish I could bet thousands of dollars that there will be only one compiler in the whole life of Zig language (also because it relies way too much to LLVM).
D is designed to be very readable to the C programmer. Some changes, like replacing:
(int)(expression)
with: cast(int)(expression)
is designed to make the code more readable, and greppable. Cast is a fundamentally dangerous operation, so being able to grep-and-check for such is worthwhile.The D compiler actually recognizes the C form and suggests using the D form to fix it.
Converting C to DasBetterC is largely just a) eliminating use of the preprocessor and then b) making the syntax changes suggested by the compiler.
D is actually a great language. I just "don't understand" why it's not massively used instead of more recent versions of C++, I consider newer version of C++ as a totally different language with more drawbacks than advantages. Half of new features are present to fix previous half baked features. This is quite embarrassing.
Sorry for my selection of words (and for the unrelated opinion, I had to rant), I'm not good at spending time to rephrase when the end content is the same.
I remember one time I spent the whole day browsing the website of D, everything actually make sense. There are still features that I wouldn't use, but this is what I expect from a programming language design. I was impressed by a lot of decisions.
I seemed to remember that I was a bit sad to not find proper performance benchmarks against other languages. I was intrigued because the documentation was so complete, it was just lacking this (maybe I just couldn't find them). It was a long time ago so it has probably been fixed. I will give it a try at some point.
Also, we used to publish benchmarks. These inevitably did not produce illumination, but long ripostes from people arguing that the benchmark was unfair, inaccurate, nobody would write code that way, we sabotaged other languages, etc.
We encourage people to run their own benchmarks on their own code and let the results speak for themselves.
One issue with moving to D is it takes a while for people to learn "the D way". For example, if they come from C they write C style code in D. From C++, they write C++ style in D. From Python they write Python style in D. Inevitably they'll run into some difference where D doesn't have an analogous feature, and would get a bit frustrated (even though in D the task would be accomplished a different way).
It takes a bit of perseverance and faith to get through that until one discovers "the D way" and then they're hooked.
One of the reasons for DasBetterC was to reduce this issue as much as possible, though the people who like metaprogramming with the C preprocessor will have more work to do in getting adapted to D's powerful metaprogramming features, which of course work nothing like text macros.
Oh, this is pretty sad...
Anyway thanks for your time. Was nice to interact with the author of D. I truly believe what you've done will inspire a lot of people.
I hope you didn't encounter too many people saying creating D was foolish.
I spent time checking about a lot of languages and only D (and Jai, but it's not released) would restore my joy of programming.
This is incorrect. There are other factual errors here as well.
Don't get me wrong, I like to help people. But I learnt to not help people that do not seek help.
You get a plumber fixing your pipes because you need your pipes to be fixed, but if every single plumbers were offering there help it would be annoying.
There are already more that three hundreds proposals:
https://github.com/ziglang/zig/issues?q=is%3Aissue+is%3Aopen...
A lot of them are about the syntax. Maybe this won't be endless but I'm sure a lot of time are being wasted. The root of the issue I point seems to be bound to the way the devs are working. Not sure if it will be efficient to tell them to "think more carefully". I do believe my time can be more profitable elsewhere (like commenting here, ah ah).