Live data from Hacker News

Rust 2019 and beyond: limits to some growth

graydon2.dreamwidth.org

91–100 of 237 posts

Re: Rust 2019 and beyond: limits to some growth

#91

Earlier quoted context omitted.

Common practice would be to set the pointer to NULL after free and if you have multiple pointers to the same object - well, try to avoid doing that. If you must, you can use reference counting.

> well, try to avoid doing that I think that's pretty terrible advice for something that affects memory safety, and it invalidates your entire "the compiler will warn you" argument. There's a reason Rust has ownership and lifetime annotations: there are many things that a compiler simply cannot infer.

I haven't looked into Rust very much yet, but doesn't the borrow checker effectively prohibit you from having multiple references to the same object?

I wouldn't say it's terrible advice though. If I see that something I do is potentially dangerous and would require special care to get it right, I'd first look if there is another way to do it.

Re: Rust 2019 and beyond: limits to some growth

#92
I have written non-trivial code in Go and Rust. My situation is C++ dev -> Go -> Rust -> Go (current day job). The shifts have been due to various circumstances on my day job.

The thing is when I moved back from Rust to Go, I had forgotten how productive Go is and I felt something like this:

https://youtu.be/1i_Eqj7wu88?t=50 (20-30 sec video)

As someone who tried to "sell" rust in my org, I see the biggest issue is:

1. Steep learning curve (it is true)

2. When lot of people talk about #1 it gets amplified in the minds of people who make calls on the tech to be used

A great effort has been spent on #1 and I agree the payoff is worth it. But #2 is perception/marketing issue.

PS: I am huge fan of both Rust & Go.

Re: Rust 2019 and beyond: limits to some growth

#93
post #86
post #79

Earlier quoted context omitted.

How is adding async await will make Rust into C++ ? Would people actually name the features that should not be in? Outside of ownership and borrowing have Rust added any features that are not mainstream and well proven in other languages?

How did adding exceptions to the language make C++ into C++? RTTI? Multiple virtual inheritance? Default member function generation? They didn't, not individually. They were popular and uncontroversial (rather less controversial than promise apis, even). And yet... The point is that Rust seems to be charging blindly down the same road, not that any one feature is going to blow it all up. Frankly IMHO Rust is already…

I think there is fairly large difference between learning and being able to write production ready code. It's hard to imagine a person for whom Rust is hard to learn and who can write safe threaded code in C++ for example.

Re: Rust 2019 and beyond: limits to some growth

#94
post #61

The comparison between C++ and Haskell is laughable, and shows that Graydon is missing the most important facet of this: GHC Haskell and Rust with have an intermediate language (Core and MIR + Chalk, respectively), which keep the rest of the language in tight check. No other mainstream language has this (Java bytecode doesn't really speak to high level safety properties). This ensures the vast majority of the languag…

I agree with you, but complexity is perceived by newcomers through the surface syntax of the language, not through an internal, mostly invisible IR. It's great that as advanced users, most of the perceived complexity can simply be thought of as sugar, but to a newcomer without an understanding of the core of the language yet, the complexity is often intimidating. It's easy for a language designer to say things are ju…

For starters, I think newcomers should look at the core languages more. It's a great way to develop a (shared) mental model, rather than do so independently, reinventing the wheel and then maybe finding that yours disagrees with others'.

But even discounting that, I think it's still meaningful. Sugar is easier to deprecate; The desugaring can be used to remove deprecated sugar in the wild too. Core language complexity is a lot harder to eradicate.

Re: Rust 2019 and beyond: limits to some growth

#95

Earlier quoted context omitted.

> well, try to avoid doing that I think that's pretty terrible advice for something that affects memory safety, and it invalidates your entire "the compiler will warn you" argument. There's a reason Rust has ownership and lifetime annotations: there are many things that a compiler simply cannot infer.

I haven't looked into Rust very much yet, but doesn't the borrow checker effectively prohibit you from having multiple references to the same object? I wouldn't say it's terrible advice though. If I see that something I do is potentially dangerous and would require special care to get it right, I'd first look if there is another way to do it.

For vanilla references (&), Rust will prevent you from having multiple mutable references. Beyond that, there are several types in the stdlib[0] that progressively increase flexibility, but always safely.

I think it's bad advice because you need to know what is potentially dangerous. That alienates newcomers to systems programming (which is why one of Rust's goals is to be able to "hack without fear"). There are also some designs that I'd never try to build without safety checks, because they're notoriously hard to get right. Even knowing the fundamentals of memory safety, without a way of enforcing lifetimes and mutability, writing zero-allocation implementations that share immutably can be daunting.

[0] Cell, RefCell, Mutex, Rc, Arc

Re: Rust 2019 and beyond: limits to some growth

#96
post #93
post #86

Earlier quoted context omitted.

How did adding exceptions to the language make C++ into C++? RTTI? Multiple virtual inheritance? Default member function generation? They didn't, not individually. They were popular and uncontroversial (rather less controversial than promise apis, even). And yet... The point is that Rust seems to be charging blindly down the same road, not that any one feature is going to blow it all up. Frankly IMHO Rust is already…

I think there is fairly large difference between learning and being able to write production ready code. It's hard to imagine a person for whom Rust is hard to learn and who can write safe threaded code in C++ for example.

Hundreds of thousands of engineers are writing "production ready" C++ code every day. Your point seems trivially falsifiable, unless you want to turn it into a no-true-scotsman situation and explain how what they're "really" writing isn't "C++" or whatever.

I'm not saying Rust is bad. I'm saying it's... becoming senselessly complicated. And that in 20 years when 60% of its amazing new features turn out to be just fashion (because they happens to everything), Rust will be "ugly" then in basically the same way that C++ is now, and we'll all be chasing some other new hotness.

Re: Rust 2019 and beyond: limits to some growth

#97

The comparison between C++ and Haskell is laughable, and shows that Graydon is missing the most important facet of this: GHC Haskell and Rust with have an intermediate language (Core and MIR + Chalk, respectively), which keep the rest of the language in tight check. No other mainstream language has this (Java bytecode doesn't really speak to high level safety properties). This ensures the vast majority of the languag…

That is not an important facet at all. It's not a thing your users see. The "syntactic sugar", as you call it, is the interface between you and your users. No amount of pretending otherwise will change that. No amount of separation will change this. It does not give you any more ability to change the syntax over time, or get it righter. Your users care only about this syntactic interface. In a good world, they do not…

OK yours is the second comment to talk about "Users". IMO this first-impression-based design methodology, like we're writing some consumer CRUD app for the startup [proverbial] you're gonna quit in terrible skeumorphic philosophy for designing languages. Languages are for more terrible; programs last (too?) long; long-future readers may be expert or knowledge.

Let me response point-by-point

> It's not a thing your users see. The "syntactic sugar", as you call it, is the interface between you and your users.

Users can and should learn the core language too. It's can allow compressing the information in the brain just as it allows reducing the code in the implementation.

> In a good world, they do not care how the rest happens in practice.

Again, I believe the core language is a meaningful thing to study and learn, not just some shove-under-the-rug implementation detail. You clearly don't, and your conclusion is indeed implied by that presupposition. It's hard to argue either from other principles so let me say it is widely held by those that study programming languages and work with cutting-edge programming languages: My axiom has more buy-in by the relevant in-groups. Maybe out-groups with yours are right and we are bad designers, or maybe those out-groups should accept a non-trivial learning curve vs permanent complexity.

> The lower levels do not drive the higher level in roughly any case.

This is wrong. As someone active with RFC discussion for both Rust and Haskell, this empirically not the case. Ideas are constantly proposed and vetted based on whether they fundamentally extend expressiveness or are just sugar.

> First you understand what users want at a high level

Yes, languages changes should and are be driven by end goals, but end goals != surface syntax!!

> There are nothing but tradeoffs in mid level IRs

What does this even mean? Surface syntax is full of tradeoffs too.

> those tradeoffs change over time based on the needs of languages, not the other way around.

Again, once the MIR/core exists, RFCs heavily reference them so this is false.

> Driving a language based on what you can accomplish in a mid level IR would be incredibly silly - "Welp, we better use this form of parallelism at a high level because we chose coroutines in the mid level IR" should never occur. Instead, the answer is "we change the mid level IR to best support the form of high level parallelism we want in the language".

This leads me to think you don't know much about IRs in these langauges in practice. Neither Rust's or Haskell's IR has any notion of concurrency precisely because nothing good enough has presented itself. Both language use syntactic / "encapsulation tricks" (See Haskell using the IO monad to avoid the value restriction of OCaml, Rust's Send and Sync) to chew off some safe subset that works with many modules. An IR with a deep/"semantic" understanding of concurrency doesn't exist for these "production" languages, though I hope http://plv.mpi-sws.org/rustbelt/ could get Rust there someday.

Re: Rust 2019 and beyond: limits to some growth

#98
post #73

Earlier quoted context omitted.

Async/await isn't stable yet, that seems to be making many commenters here wait to adopt, so at least that should make it in before they lock it down. I'd like the platform independent SIMD but that I can admit is niche and could live in nightly for a long time without harming adoption. They have polls to get a feel for the difference between those two categories and which features fall into them.

Async/await appears to require runtime support, possibly even a modern OS. Wasn't rust supposed to be suitable for writing bare-metal code? SIMD at least has hope of running on bare metal. I suppose the ideal is to have it adjustable: compiled to non-SIMD, using typical SIMD hardware, using implicit threads (and thus needing OS support), or using SIMD hardware with threads. I fear the high-level web developers are in…

> Async/await appears to require runtime support, possibly even a modern OS. Wasn't rust supposed to be suitable for writing bare-metal code?

You're probably thinking of Tokio, the library for async network IO, which obviously depends on an OS. The async/await language feature compiles down to basically a state machine and has minimal runtime requirements. I'm looking forward to using it on bare-metal microcontrollers.

Re: Rust 2019 and beyond: limits to some growth

#100
post #65

Since when did you need to read, comprehend, and digest every language feature in Rust to ever use the language? The absence of HKT / GATs / overloading / default arguments from the language doesn't make it easier for a newbie to learn. These aren't topics someone new, or even intermediate, should ever be touching until they need them. And in the absence of having this functionality (example - we JUST got const fn th…

Yes this hole thread makes me think we have a bunch of people who think complexity = initial learning curve. No wonder most of our industry is an inscrutable inconsistent mess.
Post reply on HN