←back to thread

517 points bkolobara | 9 comments | | HN request time: 0s | source | bottom
Show context
veber-alex ◴[] No.45042068[source]
I find the Zig example to be shocking.

It's just so brittle. How can anyone think this is a good idea?

replies(5): >>45042182 #>>45042784 #>>45043157 #>>45045393 #>>45046983 #
1. tialaramex ◴[] No.45042784[source]
I assume it's a bug. However because this is an auteur language if you want the bug fixed it will be important to ensure the auteur also thinks it is a bug. If they get it into their head that it's supposed to be like this, they'll double down and regardless of how many people are annoyed they're insist on it.
replies(5): >>45043413 #>>45043564 #>>45044228 #>>45048414 #>>45054675 #
2. veber-alex ◴[] No.45043413[source]
Knowing how the Zig developers operate it's 100% not a bug and it's exactly the case you described.
3. ozgrakkurt ◴[] No.45043564[source]
Tbh you would just use ErrorTypeName.ErrorKind to check equality and not error.ErrorKind if you are worried about this.

It is a tradeoff between making some things easier. And probably compiler is not mature enough to catch this mistake yet but it will be at some point.

Zig being an auteur language is a very good thing from my perspective, for example you get this new IO approach which is amazing and probably wouldn’t happen if Andrew Kelley wasn’t in the position he is in.

I have been using Rust to write storage engines past couple years and it’s async and io systems have many performance mistakes. Whole ecosystem feels like it is basically designed for writing web servers.

An example is a file format library using Io traits everywhere and using buffered versions for w/e reason. Then you get a couple extra memcopy calls that are copying huge buffers. Combined with global allocation everywhere approach, it generates a lot of page faults which tanks performance.

Another example was, file format and just compute libraries using asyncio traits everywhere which forces everything to be send+sync+’static which makes it basically impossible to use in single thread context with local allocators.

Another example is a library using vec everywhere even if they know what size they’ll need and generating memcopies as vec is getting bigger. Language just makes it too easy.

I’m not saying Rust is bad, it is a super productive ecosystem. But it is good that Zig is able to go deeper and enable more things. Which is possible because one guy can just say “I’ll break the entire IO API so I can make it better”.

replies(1): >>45044312 #
4. jibal ◴[] No.45044228[source]
Why would you assume that? It's very intentional design decision.
replies(1): >>45050386 #
5. tialaramex ◴[] No.45044312[source]
> if you are worried about this

Obviously nobody knows they've made this mistake, that's why it is important for the compiler to reject the mistake and let you know.

I don't want to use an auteur language, the fact is Andrew is wrong about some things - everybody is, but because it's Andrew's language too bad that's the end of the discussion in Zig.

I like Rust's `break 'label value`. It's very rarely the right thing, but sometimes, just sometimes, it's exactly what you needed and going without is very annoying. However IIUC for some time several key Rust language people hated this language feature, so it was blocked from landing in stable Rust. If Rust was an auteur language, one person's opinion could doom that feature forever.

6. Ericson2314 ◴[] No.45048414[source]
I'm smirking big time reading this :), well said

(To be clear to others, it's not even that this is 100% a bad thing, but people love to shit on "design by committee" so much, it helps to have a bit of the opposite)

7. tialaramex ◴[] No.45050386[source]
Because it's a foot gun. People are going to shoot themselves in the foot with this feature, and I'm generous enough to assume that was not desired which makes it a bug.
replies(1): >>45050559 #
8. jibal ◴[] No.45050559{3}[source]
As others have noted, this is not idiomatic usage. But again, this is the design ... there's no bug. Languages are full of design decisions that may not be optimal in all usages ... that's different from bugs. Footguns breed bugs.

Here's a page of non-bugs: https://www.reddit.com/r/ProgrammingLanguages/comments/1hd7l...

9. gwenzek ◴[] No.45054675[source]
Andrew actually agrees with the general sentiment. And this will be made into a compile error.

What's happening is that compiler knows the two errors come from disjoint error set, but it promotes them both to anyerror

Details at https://github.com/ziglang/zig/issues/25046