Live data from Hacker News

A Rust shaped hole

mnvr.in

251–260 of 319 posts

Re: A Rust shaped hole

#251

> If someone posts a patch or submits a PR to a codebase written in C, it is easier to review than any other mainstream language. There is no spooky at a distance. [..] Changes are local. Lol, wut? What about about race conditions, null pointers indirectly propagated into functions that don't expect null, aliased pointers indirectly propagated into `restrict` functions, and the other non-local UB causes? Sadly, C's e…

If anything I'd like an even lower-level Rust. There's so many good high-level languages to choose from, but when you need to go low-level, there's essentially only C, C++, Rust. Maybe Zig once it reaches 1.0. What we need isn't Rust without the borrow checker. It's C with a borrow checker, and without all the usual footguns.

"C is the language that combines raw power of assembly with expressiveness of assembly."

Re: A Rust shaped hole

#252
post #204

Earlier quoted context omitted.

As the definition says, the C++ standard is a formal technical document. Rust doesn’t have a standard, it has a book, so you should refer to the initialization section from Stroustrup’s C++ book to keep things fair.

Rust doesn't need a formal document so badly, because (in safe code) the punishment for not following the rules is much more clear and small. It's either a logic bug that doesn't lead to memory-related vulnerabilities, or a readable compiler error. Of course, if your compiler doesn't catch and explain your errors to you, you need a separate book to help you with that!

To be fair, the formal document isn't for language users, it's for compiler implementors. Rust doesn't have a formal document for other reasons, mainly that there is one main Rust compiler, as opposed to C or C++ where there are dozens that all need to agree on behavior.

Re: A Rust shaped hole

#253
post #166

A nice thing about C is that you can be pretty confident that you know all major footguns (assuming you spent some time reading about it). With languages that are young or complex there is a much greater chance you’re making a terrible mistake because you’re not aware of it.

It is nice that, unlike C++, the C language standard does list all the Undefined Behaviour (in Annex J.2), it's a pretty long list and IMO it's terrifying, not so much because of specifics like this:

"A searching or sorting utility function is called with an invalid pointer argument, even if the number of elements is zero"

But because of broad choices like:

"The execution of a program contains a data race"

"An object is referred to outside of its lifetime"

These are essentially categories of mistake we know programmers make, and in C the result is... Undefined Behaviour. No diagnostics, no exit, no errors, just throw your hands in the air and give up, anything might happen.

Re: A Rust shaped hole

#254
post #247

Earlier quoted context omitted.

Editions will look like band-aids that don't fully solve the cruft accumulated over the 50 years. That's not hard to predict. It's still a very useful mechanism that slows down the accumulation of said cruft. I'm yet to see a language that has a better stability/evolution story

In any case, while I as language geek have these kind of discussions, given current progress in AI systems, my point of view is that we will get the next evolution in programming systems, thus it won't matter much if it is C, C++, Rust, C#, Java, Go or whatever. We (as in the industry) will eventually get reliable ways to generate applications directly to machine code, just as optimizing compilers took a couple of de…

The machine code will always be generated from "something". A one-line informal prompt isn't enough. There will always be people who write specs. Even the current languages are already far from "machine code" and could be considered "specs", albeit low-level

Re: A Rust shaped hole

#255
post #252

Earlier quoted context omitted.

Rust doesn't need a formal document so badly, because (in safe code) the punishment for not following the rules is much more clear and small. It's either a logic bug that doesn't lead to memory-related vulnerabilities, or a readable compiler error. Of course, if your compiler doesn't catch and explain your errors to you, you need a separate book to help you with that!

To be fair, the formal document isn't for language users, it's for compiler implementors. Rust doesn't have a formal document for other reasons, mainly that there is one main Rust compiler, as opposed to C or C++ where there are dozens that all need to agree on behavior.

Yeah, the historical reason for standardizing C is the reason to "reconcile" a bunch of already existing compiler implementations

Re: A Rust shaped hole

#256
post #213

Earlier quoted context omitted.

> Not really, because the crates they depend on cannot expose APIs with semantic changes across versions. Not sure what you're talking about. Any specific examples? > Also it requires everything to be compiled with the same compiler, from source code. It's not related to editions at all. It's related to not having an implicit stable ABI. It's possible have a dynamic Rust library that exposes a repr(C) interface, comp…

To avoid repeating myself, here is an example from 4 years ago. https://news.ycombinator.com/item?id=26966151

As the response to that comment points out, you are confusing editions for ABI changes. Different editions are purely a source-level change in the language. All editions are ABI-compatible.

Re: A Rust shaped hole

#257
post #165

Earlier quoted context omitted.

Fair enough. That's what they seem to be saying. But then I want to chime in and argue that the repetitive syntax isn't even close to being the main problem with Go: https://home.expurple.me/posts/go-did-not-get-error-handling...

So, while on that subject; does Zig get error handling right?

I think it does.

Re: A Rust shaped hole

#258

Earlier quoted context omitted.

My major problem with Swift was its error messaging. “Error: -2.” Okay, well, I suppose I’ll attach a debugger and… it’s of absolutely no help, since it crashes internally to some function and I can’t get out a stacktrace. Function calling is irksome, with implicit parameters and mandatory parameters vaguely mixing? And the typing is appalling - there are multiple bottom types with implicit narrowing casts, one of th…

You should be able to get stack traces in the debugger, what issues did you run into?

I think the issue was an async boundary - I was able to trace back to CoreFoundationLibrary but the trail ended there. Also, lldb was unable to get locals? Which is something I’ve not seen happen…

Re: A Rust shaped hole

#259
post #146

Earlier quoted context omitted.

Even ignoring undefined behavior and nulls, everything in C is mutable. Action at a distance is basically the norm.

And global states. I remember the first time I was using gettext and wonder "wait, why do I have to switch the language for my whole program if I need it for just this request?" and realized that's because GNU gettext was made like that.

This even works across processes. The initial locale comes from environment variables, and you can’t generally rely on any particular values.

In fact, the “correct” values aren’t even portable. As far as I know, there is nothing resembling universal agreement on how to ask for what some systems call “C.UTF-8”. And, no offense to non-Americans, it’s fine [0] to spell one and one half “1,500”, but it is utterly broken to invoke this behavior by means of an environment variable that no one can quite agree on.

[0] OK, it really is ridiculous that the same string of Arabic numerals, commas and periods means different things in different places.

Re: A Rust shaped hole

#260
Oh, another one of those articles where people try to logically explain why they absolutely need to learn Rust and no other language will do. This time, even with religious connotations (https://en.wikipedia.org/wiki/God-shaped_hole). I mean, if you want to learn Rust, good for you, go ahead, no need to write a whole blog post rationalizing your decision!
Post reply on HN