←back to thread

517 points bkolobara | 1 comments | | HN request time: 0s | source
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 #
kouteiheika ◴[] No.45043157[source]
Every language has questionable design decisions that lead to brittle code, although some more than others.

Like, how can anyone think that requiring the user to always remember to explicitly write `mutex.unlock()` or `defer mutex.unlock()` instead of just allowing optional explicit unlock and having it automatically unlock when it goes out of scope by default is a good idea? Both Go and Zig have this flaw. Or, how can anyone think that having a cast that can implicitly convert from any numeric type to any other in conjunction with pervasive type inference is a good idea, like Rust's terrible `as` operator? (I once spent a whole day debugging a bug due to this.)

replies(2): >>45043445 #>>45050774 #
veber-alex ◴[] No.45043445[source]
You are right, but it doesn't mean we can't complain about it :)

As a side note, I hate the `as` cast in Rust. It's so brittle and dangerous it doesn't even feel like a part of the language. It's like a JavaScript developer snuck in and added it without anyone noticing. I hope they get rid of it in an edition.

replies(3): >>45043464 #>>45043857 #>>45045791 #
JoshTriplett ◴[] No.45043464[source]
> As a side note, I hate the `as` cast in Rust. It's so brittle and dangerous it doesn't even feel like a part of the language. It's like a JavaScript developer snuck in and added it without anyone noticing. I hope they get rid of it in an edition.

Rust language hat on: I hope so too. We very much want to, once we've replaced its various use cases.

replies(2): >>45043819 #>>45044497 #
1718627440 ◴[] No.45044497[source]
How are people supposed to use a language, that changes syntax?
replies(1): >>45044618 #
sunshowers ◴[] No.45044618[source]
Rust's edition system allows the language frontend to be changed every few years.
replies(1): >>45045205 #
JoshTriplett ◴[] No.45045205[source]
In particular, note that new Rust compiles code with both old and new editions. Upgrading Rust does not require you to move to the new edition. And one project can pull in crates from multiple editions.

(Imagine if Python 3 let you import Python 2 modules seamlessly.)

replies(1): >>45045661 #
1718627440 ◴[] No.45045661{3}[source]
That's nice, but I think at some point they will cut the old implementation, as otherwise they would end with hundreds of versions.

And it doesn't exactly help to compile newer software on an older OS.

replies(2): >>45045713 #>>45046004 #
1. sunshowers ◴[] No.45045713{4}[source]
No, there's a commitment to not cut old editions. A new edition/frontend comes out every 3 years, so Rust (and maybe humanity) is probably going to be completely dead long before it has hundreds of versions.