Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
Measter
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
10 ms
·
91.
▲
by
Measter
2y ago
Maybe I just suck at reading, but I'm not sure I get the argument for why function overloading and constructors are required for RAII. Is it some interaction with C and C++'s object models that I clearly didn't understand?
92.
▲
by
Measter
2y ago
> There are also related restrictions about function call barriers. AFAIK the Rust compiler cannot "peek into" called function bodies to figure out what's actually going on inside those functions (and that information woul
93.
▲
by
Measter
2y ago
> Comment above, mentioned borrowing while structs instead of borrowing memory. I believe this was once discussed under term 'partial borrows', but the "idiomatic" aproach is to 'just split your structs'. Yo
94.
▲
by
Measter
2y ago
They don't support general arithmetic. They do have member functions for abs, multiplication, negation and power operations, but they are all checked/saturating if they can result in 0. If you want to do actual arithmetic, you hav
95.
▲
by
Measter
3y ago
> Let us ask the question: Is there anything inherently unsafe about multiple (even mutable) references to an object? I think the problem with your example here is that it's a bit simplistic. In your example, if we drop the concept
96.
▲
by
Measter
3y ago
> I think the only language that gets Unicode 'right' out of the box is Swift, as it actually provides grapheme iterators, Locale awareness, etc. - but it comes at the cost of the language being tied to the (ever-moving) Unicod
97.
▲
by
Measter
3y ago
That article gives an example of where mutable aliasing isn't always dangerous: let mut my_tuple = (1, 2); let first_elem = &my_tuple.0; // error[E0506]: cannot assign to `my_tuple` because it is borrowed
98.
▲
by
Measter
3y ago
Of course, but that still requires the attacker to specifically target me. Attacking some random service I have an account with and getting everyone's account info isn't enough.
99.
▲
by
Measter
3y ago
The MSVC-based compiler doesn't come with a linker, so you need the MSVC build tools to get it. One of the ways to get the build tools is to install Visual Studio, which is fairly large.
100.
▲
by
Measter
3y ago
Funny you should bring up that argument. I had a media PC that was running Linux, and it worked great. Then there was big security vulnerability discovered in I think the SSL implementation, and I needed to update the OS because it was conn
101.
▲
by
Measter
3y ago
I had a go at writing this, both the initial float version and the later integer-based version. Note that I haven't actually tested these to make sure that output is correct, so, I might have messed up somewhere, and that I targeted Ro
102.
▲
by
Measter
3y ago
I feel I have to disagree with your (implied) contention that it's feasible to write an API in C++ that, no matter what its inputs are, cannot ever exhibit undefined behaviour. Because that's what "safe" in Rust means. N
103.
▲
by
Measter
3y ago
Rust's stdlib's API is completely safe here. On Windows[1], it uses the GetEnvironmentVariable/SetEnvironmentVariable API, which as you noted doesn't have this problem. On Unix[2], it maintains its own RwLock to provide
104.
▲
by
Measter
3y ago
I'm going to be boring and just use Rust again. I might also do some of the earlier ones in my own language, but it's so primitive that it's hard to do non-trivial things.
105.
▲
by
Measter
3y ago
Typically when people say that they mean that the language doesn't have guaranteed tail-call optimization. You can certainly write Rust that has the TCO pass applied, but it can be brittle because it's just an optimisation pass
106.
▲
by
Measter
3y ago
It was a logic error... that led to a memory safety error, which resulted in a privilege escalation vulnerability. Just because the source is a logic error doesn't mean the end result can't be bad when combined with a lack of memo
107.
▲
by
Measter
3y ago
I first just went through it front to back, having a go at some of the simpler ones as I went. Since then, I've mostly just picked ones that felt interesting to learn. I've been a bit partial to more decorative stuff lately: a few
108.
▲
by
Measter
3y ago
A few years ago, just after rustc got AVR support, I decided it'd be fun to port a (very) simplistic roguelike, writing everything from the HAL up. What I ended up doing was representing the MMIO registers and their bits using unit str
109.
▲
by
Measter
3y ago
I recently bought myself a copy of Ashley's Book of Knots, and been teaching myself... well... knotting. In my ignorance, I used to see knowledge of knots as this complex, hard to learn thing, but one thing I've been learning is t
110.
▲
by
Measter
3y ago
According to the documentation[0], enabling the "sync" feature should make the Engine Send+Sync. From a quick look at the source, it looks like it switches between using Rc/RefCells and Arc/RwLock. [0] https://
111.
▲
by
Measter
3y ago
Not just in theory. Rust does now mark almost all references as `noalias`, the exception being `&T` where `T` contains an `UnsafeCell`. The equivalent safe Rust function signature[1] would have all four references marked `noalias`, even
112.
▲
by
Measter
3y ago
The borrow checker is really at its happiest when your ownership and borrow structure is tree-like, so uni-directional references and ownership, because it's much easier to analyse. If the ownership structure that gives the best perfor
113.
▲
by
Measter
3y ago
Surely this argument could also apply to hardware. A piece of hardware's interface would be its API, which would surely mean that any software written to use that interface (drivers) would be a derivative work. Which in the case of pro
114.
▲
by
Measter
3y ago
> While I agree to a point, I also understand the argument against this. In programs, a lot of state needs to be changing. Which means you're going to type mut a LOT over the course of a 100k line program. And frankly, that gets ted
115.
▲
by
Measter
3y ago
It is an issue on desktop, though only for submissions. The flag link is next to the hide link (which I use constantly), and because the username and time are to the left of these, the flag and hide links are in a different position for eac
116.
▲
by
Measter
3y ago
A quick and dirty comparison on my project: -- GNU Ld 2.31.1 >> cargo build --release Compiling mfl v0.1.0 (/mnt/d/Programming/Projects/Rust/mfl/crates/mfl) Finished releas
117.
▲
by
Measter
3y ago
For comparison, using Rust's Serde-Json library on my desktop (Intel 11700k, and with computer doing other things), benchmarked with Criterion: Benchmarking json_read_struct: Collecting 100 samples in estimated 5.2012 s (81k iter
118.
▲
by
Measter
3y ago
Of course not, don't be daft! We go shopping for CPUs.
119.
▲
by
Measter
3y ago
You may be thinking of a different kind of memory mapping. I believe spatter is thinking of memory-mapped hardware.
120.
▲
by
Measter
3y ago
I wrote an Assetto Corsa server plugin for the ACRL racing league which enforced track limits. The initial commit was in 2016, and to my knowledge it's still in use.
More ›