Live data from Hacker News

Rewrite Everything in Rust

robert.ocallahan.org

201–210 of 242 posts

Re: Rewrite Everything in Rust

#201
post #189

Earlier quoted context omitted.

May I ask what those big ones are? How is it going to affect/improve the life of a systems programmer?

The most recent one off the top of my head is the ? syntax RFC, which should reduce the amount of error-handling boilerplate. The big ones though are: * Specialization. This will allow you to write ultra-performent generic code by special-casing when you have the knowledge. It also will be a building block for the next few features. * The bag of features colloquially known as "inheritance", though that's not really a…

Great. They all look great. The ones like higher kinded types are the ones that I am highly suspicious of. The typical C programmer who pokes around hardware data sheets and writes drivers and stuff will likely not pay much attention to Rust if such complex features are added.

Also features like that makes me wonder if you folks are really targeting C/System programmers. Sorry if I sound negative, that isn't my intention.

Re: Rewrite Everything in Rust

#202
post #201

Earlier quoted context omitted.

The most recent one off the top of my head is the ? syntax RFC, which should reduce the amount of error-handling boilerplate. The big ones though are: * Specialization. This will allow you to write ultra-performent generic code by special-casing when you have the knowledge. It also will be a building block for the next few features. * The bag of features colloquially known as "inheritance", though that's not really a…

Great. They all look great. The ones like higher kinded types are the ones that I am highly suspicious of. The typical C programmer who pokes around hardware data sheets and writes drivers and stuff will likely not pay much attention to Rust if such complex features are added. Also features like that makes me wonder if you folks are really targeting C/System programmers. Sorry if I sound negative, that isn't my inten…

They are specifically there so that you can write zero-cost abstractions. Yes, people who are hardcore C programmers may not have experience with more advanced type system features, but it's all in service to the goal of writing expressive code that goes as fast and as safely as possible.

As a practical example of higher kinded types, you can't say "this function takes an Rc or an Arc. I just want something refcounted, but I don't care about how." HKT would get you there.

Another common problem it would solve is "I don't want to write both a &T and &mut T version of my function."

Re: Rewrite Everything in Rust

#203

Earlier quoted context omitted.

> A rewrite would clean up the code, sure, but then you're left in the same situation, only with brand new bugs that nobody has time to fix. The entire point is that you're not in the same situation regarding memory safety problems/vulnerabilities.

Memory safety problems are the low-hanging fruit of vulnerabilities. A re-write by unskilled programmers will not guarantee the code is safe, because they will introduce many other kinds of vulnerabilities.

Rust's improvements over C don't just consist of memory safety. It also provides an excellent type system and the ability to statically check for concurrency bugs at a higher level than just memory safety, for instance.

None of these things (except maybe some of the concurrency stuff) are quite new to Rust. It's just that C is such an old language that stuff that other languages have been doing well for decades were not available to systems software.

Re: Rewrite Everything in Rust

#204

Off topic, but it's surprisingly refreshing to see someone put "Christian" next to their name in the same place they put "Mozilla hacker." The vast majority of programmers either aren't religious or hide it so well that you couldn't possibly tell if they were. (Not that being overt about it is better, either.) I understand that it's generally best not to talk religion in the professional workplace, but a person's own…

Do you find it refreshing because he's Christian? What I mean is, if instead it said "atheist" or "Muslim" would you also find it refreshing?

Being a Christian myself, yes, I do find it refreshing specifically because he's another Christian programmer. It's very rare that someone is both, let alone an adult convert to Christianity.

Re: Rewrite Everything in Rust

#205
post #196

Earlier quoted context omitted.

> current level of documentation they are in the realm of some obscure hacks I don't think so. Rust encourages a certain style of designing code, using enums and traits. Almost all the time this suffices. My comment was at the macro level; I'm not saying that an OOP pattern will have an equivalent in Rust, I'm saying that if you look at the larger use case you can design your code in idiomatic Rust to avoid it.

> I'm saying that if you look at the larger use case you can design your code in idiomatic Rust to avoid it. As I said, may be you can, but it's far from trivial and unless you know how to do it already, coming up with such approaches isn't something that one who just learns the language would be focusing on. You yourself said above, that it's hard. And unlike languages like C++ where OOP approaches are very well doc…

> You yourself said above, that it's hard.

I said modeling single inheritance is hard. That's a very niche use case; basically only crops up when writing an interpreter for a language with single inheritance (and in cases like Servo's DOM)

> unless you know how to do it already, coming up with such approaches isn't something that one who just learns the language would be focusing on

Again, it's not a thing that you do as a drop-in for inheritance. I'm saying that the regular approach (i.e. using traits and enums idiomatically) to designing your application in Rust will cover the use cases for inheritance, differently.

Basically, don't try to write Rust code as if it's C++ or Java and stuff should work out.

Re: Rewrite Everything in Rust

#206

Earlier quoted context omitted.

It's true. In my DNS code I have zero unsafe code. Though I did need to add some new unsafe code to the Rust OpenSSL library, but that's really because of the FFI to C. That too would be unnecessary if OpenSSL was rewritten in Rust.

Does the OpenSSL library allow/plan for an Rust reimplementation (possibly side-by-side for a while) of the C bits? Seems that would be best practice - assuming the goal is make everything safe Rust.

In theory that's just copying the Rust bridge code and using that as the frontend API for a rewrite. So yes it's possible, you "just" need to rewrite the rust-openssl-sys library.

I think the hesitation there is that everyone has gotten it beaten into your head that writing new crypto libraries is dangerous. It's probably safer to use a library that has tons of eyes on it, but at some point we should do it.

Re: Rewrite Everything in Rust

#207
post #145

Earlier quoted context omitted.

What about binding to the OCaml implementation at https://nqsb.io/ ?

Wouldn't that require pulling in the OCaml garbage collector? Much of the reason people use glibc or other low-level libraries rather than a managed runtime is so they don't need to link in a managed runtime.

Good point, I think it would indeed mean pulling in all of OCaml's runtime model.

Re: Rewrite Everything in Rust

#208
post #57

Earlier quoted context omitted.

OP article was specifically talking about Rustbelt as one tool you would be able to use in the future to mitigate the risks posed by the unsafe code you do have. But in general, I think that entire idea is that as more code moves to memory-safe languages, the less need we have for unsafe sections. Ideally, once the kernel itself can be written in a memory safe language, everything running on top of that wouldn't need…

It's not decades away! Check out https://sel4.systems .

[deleted]

Re: Rewrite Everything in Rust

#209
post #9

I think this misses the real problem. So many pieces of foundational software like glibc and OpenSSL are understaffed, underfunded, and plagued by terrible code. Go read glibc getaddrinfo: it's a mess! Rewriting the software in Rust would not solve these problems any more than rewriting it in C++ would. A rewrite would clean up the code, sure, but then you're left in the same situation, only with brand new bugs that…

This is why I personally think the OSS community should be more encouraging of "salary" style funding. There is a loud, poisonous minority of advocates that seem to think that asking for money is just plain evil. That attitude is a material disservice to OSS in general: it makes OSS weaker and less capable, for the sake of some weird puritan reflex. N.B.: I have never and will never ask for, nor accept any income fro…

[deleted]

Re: Rewrite Everything in Rust

#210
post #201

Earlier quoted context omitted.

The most recent one off the top of my head is the ? syntax RFC, which should reduce the amount of error-handling boilerplate. The big ones though are: * Specialization. This will allow you to write ultra-performent generic code by special-casing when you have the knowledge. It also will be a building block for the next few features. * The bag of features colloquially known as "inheritance", though that's not really a…

Great. They all look great. The ones like higher kinded types are the ones that I am highly suspicious of. The typical C programmer who pokes around hardware data sheets and writes drivers and stuff will likely not pay much attention to Rust if such complex features are added. Also features like that makes me wonder if you folks are really targeting C/System programmers. Sorry if I sound negative, that isn't my inten…

Incidentally, the specialization RFC was just accepted https://github.com/rust-lang/rfcs/pull/1210#issuecomment-187...
Post reply on HN