News for hackers. Stuff that matters.
Re:An embedded database written in Rust by EugeneOZ on Monday May 28, 2018 @04:56AM (#17171364)
In Rust abstractions are free.
Re:An embedded database written in Rust by nixpulvis on Monday May 28, 2018 @11:16AM (#17172859)
Some are (more or less) free, others are not. Rust simply gives you some great tools to make the choices yourself. The biggest win tends to be that you can get away without a GC, but still keep the guarantee that you're not leaking memory by forgetting to collect it.
Re:An embedded database written in Rust by steveklabnik on Monday May 28, 2018 @12:08PM (#17173149)
Rust doesn't guarantee freedom of leaks, as leaking is memory-safe.
Re:An embedded database written in Rust by saghm on Monday May 28, 2018 @01:25PM (#17173600)
To be fair, I think the way GP worded it might still be accurate; they said that you wouldn't leak by forgetting to collect it. I took that as a statement about not needing to manually free things than an assertion that Rust guarantees no memory leaks (which can still occur from things like reference cycles).
Re:An embedded database written in Rust by steveklabnik on Monday May 28, 2018 @04:32PM (#17174671)
You’re right, I might be overly sensitive to people incorrectly making this claim directly.
Re:An embedded database written in Rust by nixpulvis on Monday May 28, 2018 @05:41PM (#17175021)
I too try (and sometimes fail) to be careful when talking about this. People get all hot and bothered when you go overboard :P It can be tempting to start explaining what an afine type system is, but that can hurt more than help.
Re:An embedded database written in Rust by steveklabnik on Monday May 28, 2018 @05:51PM (#17175086)
<3
Re:An embedded database written in Rust by fooker on Monday May 28, 2018 @06:09AM (#17171609)
If that was so, there wouldn't have been a need for the unsafe mode.
Re:An embedded database written in Rust by zacmps on Monday May 28, 2018 @06:37AM (#17171691)
Unsafe does not exist for performance.

Quoting from the rust book:

> Unsafe Rust exists because, by nature, static analysis is conservative. When the compiler is trying to determine if code upholds the guarantees or not, it’s better for it to reject some programs that are valid than accept some programs that are invalid. That inevitably means there are some times when your code might be okay, but Rust thinks it’s not! In these cases, you can use unsafe code to tell the compiler, “trust me, I know what I’m doing.” The downside is that you’re on your own; if you get unsafe code wrong, problems due to memory unsafety, like null pointer dereferencing, can occur.

> There’s another reason Rust has an unsafe alter ego: the underlying hardware of computers is inherently not safe. If Rust didn’t let you do unsafe operations, there would be some tasks that you simply could not do. Rust needs to allow you to do low-level systems programming like directly interacting with your operating system, or even writing your own operating system! That’s one of the goals of the language. Let’s see what you can do with unsafe Rust, and how to do it.

Re:An embedded database written in Rust by steveklabnik on Monday May 28, 2018 @07:08AM (#17171790)
As the person who wrote those paragraphs, yes. The fundamental reason unsafe exists is not for performance reasons. That being said, the parent is also true that sometimes, unsafe is used to enhance performance. But that's not the usual case, and in fact, can even hurt performance in ways. For example, &mut T can't alias, but *mut T can, and so &mut T can be optimized more aggressively. (We recently turned these optimizations back on: https://github.com/rust-lang/rust/pull/50744 )
Re:An embedded database written in Rust by PudgePacket on Monday May 28, 2018 @06:34AM (#17171679)
You're argument doesn't really make sense. Not all abstractions are workarounds for "unsafe" things. For example, unsafe is needed for dealing with the OS, no amount of abstraction will help you there. At some point you must talk to and accept memory that another process (OS) tells you is correct. I'm not so knowledgeable in Rust so I can't say definitely, but I think you should back up your statement with some (any) examples.
Re:An embedded database written in Rust by EugeneOZ on Monday May 28, 2018 @07:08AM (#17171796)
Re:An embedded database written in Rust by p0nce on Monday May 28, 2018 @06:59AM (#17171763)
Do you realize "zero-cost" abstractions are not specific to Rust?
Re:An embedded database written in Rust by steveklabnik on Monday May 28, 2018 @07:12AM (#17171810)
Your parent didn't say that. Speaking about Rust in a thread about a Rust project seems to be very on-topic?

(I would also disagree with that statement, but in a different way: Rust enables zero-cost abstractions, but nothing inherently means they have to be. I can also make quite costly ones, and they'll compile.)

Re:An embedded database written in Rust by p0nce on Monday May 28, 2018 @07:37AM (#17171887)
> Your parent didn't say that.

Yes and it's more disturbing. It says "In Rust abstractions are free" when an algorithm was discussed.

Rust having "free" abstractions does not change the performance characteristics of an algorithm: this is what the grand-parent was talking about.

Re:An embedded database written in Rust by steveklabnik on Monday May 28, 2018 @07:49AM (#17171926)
Yes, I certainly agree with that distinction. If you'd have said that in the first place, I wouldn't have said anything :)
Re:An embedded database written in Rust by EugeneOZ on Monday May 28, 2018 @07:51AM (#17171932)
What is results disturbing is that you are arguing just for the sake of arguing. "Algorithm" is a too wide term - everything is an algorithm, especially in programming. Talk was about abstractions, now you're trying to say it was about algorithms. We need "ignore" button here.
Re:An embedded database written in Rust by EugeneOZ on Monday May 28, 2018 @07:31AM (#17171866)
I would answer "you can write trash in any language, in Rust you need to find ways how to do it, when in other languages - how to avoid it". Looks like ycombinator now is the place when people just looking for negativity and what else ti disagree with.