r/programming • • Jan 17 '20

A sad day for Rust

https://words.steveklabnik.com/a-sad-day-for-rust
1.1k Upvotes

609 comments sorted by

View all comments

Show parent comments

75

u/SirClueless Jan 17 '20

Also, if the perceived problem is that the Rust ecosystem is worse off for the amount of unsafe code in actix-web then forking isn't a rational solution.

Unsafe code in a popular library might be a bad thing for the ecosystem. Unsafe code in a popular library plus a warring fork is not likely to be any better.

55

u/UtherII Jan 17 '20

Unsafe code is not the core of the problem, the language was designed with this feature for a reason. Even the standard library use unsafe, so nearly every Rust program contain parts of unsafe code.

The point is the unsafe code should be carefully used in safe abstractions to reduce the use to the maximum and the abstraction used by the actix maintainer were leaking.

28

u/ericonr Jan 17 '20

Even the standard library use unsafe

It kind of has to, because someone has to interact with the OS and libc, and that can't be done in safe Rust. So it doesn't work as an example of the validity of unsafe code.

From what I've read, it seems a lot of the unsafe stuff that people use in Rust tend to be related more to performance than to actually being impossible in safe Rust.

12

u/UtherII Jan 18 '20

Unsafe is used in a lot of places of the standard library for performance too.

6

u/Minimum_Fuel Jan 18 '20

Unsafe rust is not only used for interacting outside of rust. It is used all over the place for performance reasons that safe rust can’t know are actually fine. There’s over 1600 hits to unsafe in rust. FAR from all of those are interacting with the OS.

→ More replies (2)

4

u/hayesgm Jan 18 '20

It’s slightly strange to me that rust doesn’t percolate up “unsafe” to the type so that the call sites know they are using unsafe code and all higher up functions know it as well. This would be similar in spirit to the IO monad from Haskell. I feel this could lead people to have a gauge on how much code they depend on is unsafe and in which circumstances.

6

u/MEaster Jan 18 '20

Because then literally everything would be unsafe. At some point you have to have some unsafe code in order to interact with the system because the compiler cannot prove that the system will do as advertised.

2

u/PM_ME_UR_OBSIDIAN Jan 27 '20

Sorry for the late reply: the point of an unsafe block is to say "this is the correct level of abstraction at which to reason to prove that this operation is safe". It's not in the type because it wouldn't be composable; the idea is to build safe abstractions from unsafe operations. Once the safe abstraction is built you treat it as such.

11

u/[deleted] Jan 17 '20

[removed] — view removed comment

15

u/not_perfect_yet Jan 17 '20

Do you want a fix or not?

Also, if the perceived problem is that the Rust ecosystem is worse off for the amount of unsafe code in actix-web then forking isn't a rational solution.

I think people who submit PRs and patches want the code, but also the author, to "better" from the submitter's perspective. Rejecting PRs is very fundamental form of disagreement I'm not sure most developers are equipped to handle.

So maybe wanting that fix is kind of undermining some of the freedom open source usually aims for. And the result may be that the freedom to reject PRs is more valuable than a single PR. And then you would not want the fix.

12

u/PM_ME_UR_OBSIDIAN Jan 17 '20

Security-minded people aren't investing their time and efforts into actix-web because of how deep in its DNA this anti-security mindset goes. From this point of view, actix-web is best understood as an attractive nuisance that could come to taint the wider Rust ecosystem by association.

4

u/[deleted] Jan 17 '20

[removed] — view removed comment

11

u/[deleted] Jan 18 '20

[removed] — view removed comment

2

u/exploding_cat_wizard Jan 18 '20

That sounds a lot more like an Apple mindset than open source.

"No, you're not allowed to write a performant library in Rust, because it undermines our safety-first stance"

1

u/PM_ME_UR_OBSIDIAN Jan 27 '20

You're allowed to write it and publish it, but you risk people speaking out against your library and discouraging others from using it.

By analogy, companies have a right to release shitty products, but consumers have a right to spread the word not to buy them.

5

u/TribeWars Jan 18 '20

Yeah? The quality of third-party libraries is a common argument in discussions involving which programming languages to learn and use.

4

u/Nickitolas Jan 18 '20

I mean, it happened to php

5

u/ChemicalRascal Jan 18 '20

Jeez, based on some of the VB and C# I've seen at my workplace, that must mean the entire .Net ecosystem is utterly fuckin' trash.

-3

u/ProbablyJustArguing Jan 18 '20

Breaking news...

0

u/[deleted] Jan 17 '20

[deleted]

33

u/HeWhoWritesCode Jan 17 '20

any suggestion for a production ready language with a safe ecosystem that does not permit unsafe code?

25

u/ImpactStrafe Jan 17 '20

HTML, obviously.

14

u/HeWhoWritesCode Jan 17 '20

your right, screw all these abstractions and let us just inline c into html!

This project will need a name. Let us call it personal homepage project!

→ More replies (1)
→ More replies (17)

8

u/shponglespore Jan 17 '20

So no language with an FFI, then? Or really, no language that compiles to a lower-level langues with less type safety, or interpreted by an interpreter written in a less safe language. Well, shit, that rules out all programs.

If you want safe code, someone at some point has to implement it in terms of unsafe code. Forbidding any kind of unsafe code in the language just means the only people who can implement features that require unsafe code are the maintainers of the language toolchain itself, which is how you end up with a language like JavaScript (as implemented in browsers) whose capabilities are severely crippled compared to just about any other language. Given the niche JavaScript fills, the limitations are reasonable, but most people want a language that allows them access to the full set of capabilities provided by their platform.

→ More replies (2)