Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
Measter
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
8 ms
·
61.
▲
by
Measter
2y ago
> Compilers rather works in terms of UBs being constraints (on the program), which they can then leverage for optimisations. All the misbehaviour is emergent behaviour from the compiler assuming UBs don’t happen (because that’s what an U
62.
▲
by
Measter
2y ago
I have a weird second-hand memory by this. Back in the 90s, when I was still in school, we were having a bit of a relaxed period. My teacher had the radio on and was marking some stuff, while we kids were doing whatever. At one point, while
63.
▲
by
Measter
2y ago
> Also, from learning human languages, it's a well-known lesson that phrasebook-type "this means this" translations (like some here are asking, from Zig to C/Rust) are useful for quick and dirty learning good enough f
64.
▲
by
Measter
2y ago
Yeah same, though with Rust. I once did a refactor of my compiler project where I completely rewrote how the AST was represented, then spent the next three or four hours fixing compiler errors. Worked perfectly first time, because the type
65.
▲
by
Measter
2y ago
> It does have syntax for them, but that is just syntactic sugar for an class with a single method under the hood. So streams end up doing lot of object allocation and garbage for the fake closures. In Rust a closure is really just a str
66.
▲
by
Measter
2y ago
The value of an abstract machine is that it allows you to specify how a given program behaves without needing to point to a specific piece of hardware. Compilers then have this as a target when compiling a program for a specific piece of ha
67.
▲
by
Measter
2y ago
They mean whether the value is properly initialized, as in all the bytes that make up that value have set values that are valid for that type. For example, in Rust the only valid values a boolean can have are 0 and 1, anything else is inval
68.
▲
by
Measter
2y ago
You were conflating details of C++'s object model and implementation of move semantics with RAII. Rust also makes heavy use of RAII, and the details of its object model and move semantics are not the same as C++'s. The only thing
69.
▲
by
Measter
2y ago
> When does your constructor & destructor fire when a dynamic array grows? What constructor? And why would a Drop implementation be invoked to move something? You've moved it, there's nothing left to drop . > Did you us
70.
▲
by
Measter
2y ago
> The default cargo crate (template?) encourages people to use permissive licensing for their code. So that is an example where you are already making implicit political decisions on behalf of the ecosystem and developers. That is alarmi
71.
▲
by
Measter
2y ago
Most languages handle this by having interfaces/traits/etc. Zig doesn't have those, so you're forced to use these ad-hoc struct instances.
72.
▲
by
Measter
2y ago
Rust has two possible behaviours: panic or wrap. By default debug builds with panic, release builds with wrap. Both behaviours are 100% defined, so the compiler can't do any shenanigans. There are also helper functions and types for un
73.
▲
by
Measter
2y ago
You might be thinking of CVE-RS[0] which is exploiting bugs in the compiler. [0] https://github.com/Speykious/cve-rs
74.
▲
by
Measter
2y ago
There was a paper a few years ago[0] was related to proving soundness. That could be what they meant. [0] https://plv.mpi-sws.org/rustbelt/popl18/paper.pdf
75.
▲
by
Measter
2y ago
Rust's aliasing restrictions only apply to references. If you only stick to pointers and never at any point create a reference , you can alias to your heart's content. For example, the equivalent[0] of the article's Offset O
76.
▲
by
Measter
2y ago
Having a quick look at efsw, it depends on both libc and the windows API, both are huge dependencies. The Rust bindings for libc come to about 122 thousand lines, while the winapi crate is about 180 thousand lines. [Edit] And for completene
77.
▲
by
Measter
2y ago
Though we should also accept that some things are just hard. Though that's not to say that we should give up on trying to make them as easy to learn and use as possible.
78.
▲
by
Measter
2y ago
I'll ignore the option of returning a Vec or Option, as the article already went over why these options were rejected, and concentrate on the later options. Firstly the `std::iter::empty()` attempt: The issue they had here came down to
79.
▲
by
Measter
2y ago
Bear in mind that the optimization on `Option<Infallible>` isn't specific to that type; it applies to anything that results in one possible value. For example, `Foo` in this example is also zero-sized: pub enum Foo {
80.
▲
by
Measter
2y ago
What's happening is that `Infallible` has no values, and cannot be instantiated. This results in `Option<Infallible>` only having one possible variant (None) which has no payload, and therefore being a zero-sized type. Separately
81.
▲
by
Measter
2y ago
How are build times for AOT these days? Last time I tried it (~2019) it was slower than Rust at building the same project.
82.
▲
by
Measter
2y ago
I've found it's kinda helpful to think of Rust/modern C++ style management as semi-automatic memory management. You control when things are allocated and freed, but you don't bother with the minutia of it unless you'
83.
▲
by
Measter
2y ago
I think Steve might have forgotten (so many helper functions...), but Rust's slices have a `copy_within`[1] function for exactly this scenario: fn main() { let mut buf: [u8; 16] = *b"D04GOKUD09OVER90";
84.
▲
by
Measter
2y ago
My understanding is that no one's asking them to take on that burden. What seems to be being asked is for them to explain the current semantics of the API, because it's unclear what they actually are. From the sounds of it, some o
85.
▲
by
Measter
2y ago
That's definitely been one of my hurdles. Though ammusingly one thing that's helped is to give an example to ChatGPT and ask it to describe the art style.
86.
▲
by
Measter
2y ago
> (except doing so often triggers LLVM bugs, so it's usually turned off). It's been enabled for a couple years now.
87.
▲
by
Measter
2y ago
> (For what it’s worth, if you use a prover-adjacent language such as Agda or Idris, this is exactly how things are going to work there.) You don't even have to go that far, Rust supports this concept. The built-in empty type is cal
88.
▲
by
Measter
2y ago
Thank you for putting the time into writing it! Your book was what really made it all click for me, and I'm currently working on my own static-type compiled language as a result. I plan on doing part 2 of your book in that language; it
89.
▲
by
Measter
2y ago
For this book, that is absolutely what you should do. It starts you off building a simple parser and interpreter, and then has you add features to both as you progress through the book. Skipping sections can mean that you end up missing fun
90.
▲
by
Measter
2y ago
Ah, I missed the "copy wholesale" aspect. When I started reading it, the first thing that came to my mind was the issue with copying the structs. The article started looking at the issue, but didn't really follow further with
More ›