5 ms·
> [Rust's Ownership and Lifetime rules] come with a steep learning curve and have been repeatedly cited as a barrier to adopting Rust Rust Ownership and Lifeti
by gary17the 4y ago
> [Rust's Ownership and Lifetime rules] come with a steep learning curve and have been repeatedly cited as a barrier to adopting Rust
Rust Ownership and Lifetime rules aren't really that hard to learn. The only trick is that a programmer cannot learn Rust exclusively by trial-and-error (which programmers love to do), trying dozens of syntax combinations to see what works. A programmer is forced to learn Rust by RTFM (which programmers hate to do), in order to understand how Rust works. That's all there's to it. It's like trying to learn to play the guitar without reading a book on guitar cords, pulling guitar strings individually at random - the music just won't happen, even if you're Mozart.
- cornholio 4y agoIf most people won't RTFM then most people won't get to become productive in Rust, so your pool of job applicants is diminished, the real-world use is lower, the tooling and library support is reduced. Being a member of a super-elitist cabal that knows how to use Rust "properly" is not some point of pride, it's in fact a mortal danger for the language, just look at Haskell. And this is why the world has descended into Javascript hell, everybody and their mother are coding "apps" and "microservices" where each click is accompanied by a stack dump because the code is written by a student doing Elance in their spare time, but hey, it's good and fast enough to ship so you get to be first on the market and 3 years later your startup is bought by my bank and I can't login on my internet banking account without seeing that same revolting stack dump that couldn't be produced by a modern and flexible strong typed language. Real world doesn't care about abstract code purity metrics.
- gary17the 4y ago> Being a member of a super-elitist cabal that knows how to use Rust "properly" is not some point of pride I'm not sure I follow you, since I am saying something exactly opposite: anyone, even a mediocre, 1-year-of-experience programmer can successfully learn Rust, if only he or she tries to read a book on Rust, instead of just randomly hacking at Rust code. No "super-elitist" brain required, just a switch of learning methodology. > just look at Haskell The problem with Haskell is that it requires a monumental, conceptual switch from imperative programming to functional programming, which has not happened anywhere yet outside of academia (well, perhaps with the exception of functional reactive UI programming, e.g., React Native, Swift Combine, etc.), so Haskell is a tough sell in "real world", commercial organizations. Rust does not have this problem, since Rust does not rely on any "code [structure] metrics" (did I understand this right?), but instead moves as much bug detection as possible from runtime to compile-time (especially for multi-threaded applications).
- alpaca128 4y ago> Being a member of a super-elitist cabal that knows how to use Rust "properly" is not some point of pride Rust's ownership rules are simply an explicit form of what people already have to (and sometimes fail to) look out for in C/C++. If learning a language for a couple months makes one feel elitist that's not the language's fault. Though granted, some Rust people are...very eager at talking about its virtues.
- hannofcart 4y ago> Being a member of a super-elitist cabal that knows how to use Rust "properly" is not some point of pride, it's in fact a mortal danger for the language, just look at Haskell. Just a reminder of the Haskell motto: "Avoid success at all costs." So in their case, it's working as intended.
- namaria 4y agoI find it hard to accept that being first to market, capturing a lot of value and dumping it on a greater fool are things to aspire for. I see this argument in many forms all the time, in a nutshell: monetary gain should be the sole metric of success for engineering. Considering we are killing the planet and perma-exploiting entire classes of society following that logic, maybe we should change approach? But yeah ship it, pocket it. Why be idealistic if I just need to make enough money to retire and say "got mine, f you"?
- cornholio 4y agoIf you won't ship it, then someone else with much worse ethics will, and they will also embed a secret GPS tracker that sells data to the worst abusers. Competing with unethical actors is already hard, playing the game on "super-hard" just to feel good about your ethics is actually setting yourself up for failure and betraying those ethics. Been there, done that for a decade or so, have nothing to point to as the net positive effect of my impeccable ethics, but I most certainly do lack the financial and political capital that would afford me any real impact. So by all means, ship it, make a trillion bucks, then educate and feed the poor and invest all your cash into eco technologies.
- namaria 4y agoYou are absolutely right. It is much, much easier to stoop to the average level of morality. And yes, attempting to have standards will certainly limit your earning potential. In the same way that preying on weaker communities around you via war, enslavement and pillaging has been a winning strategy for most of civilization. I truly think capitalism in its current form it immoral. And the fiction of effective altruism as a justification just makes it worse.
- cornholio 4y agoOur current society, at least the western version of it, is by far the best human society that ever existed on this planet. Our levels of wealth were inconceivable even 300 years ago. Not even kings could have things we take for granted, like medical care, round the world air travel, indoor plumbing, lasting peace and physical security, access to information and learning. In a very extremist fashion, of course you can define a moral standard high enough that we will always fail. But the opportunity for you to think about such absolute moral issues - as opposed to literally slaving in a coalmine or birthing you 14th child and dying before the age of 45 - was created by moral pragmatists who were "effective altruists"[1] of their times , even if the only thing they did was to seek profits by inventing some type of better machine. We're at a cross road now where the existing mode of wealth production, focused on growth and individual material satisfaction, has reached the point of diminishing returns and even negative returns if we consider our fate as a species in the natural environment. But denying our ability for incremental improvement, forgoing our world building tools and returning to some elusive harmonious state of nature can't be the answer. [1] though I dislike that term due to its abuse by virtue signaling sociopaths
- alpaca128 4y agoThe difficulty with ownership and lifetime is not the basic principle which indeed is easy to understand, it's understanding how those rules affect the code you write in all kinds of detailed ways. That simply takes time.
- klabb3 4y ago> Rust Ownership and Lifetime rules aren't really that hard to learn. What’s hard is not to learn the rules themselves, but to build things under the constraints of these rules. That turns out to be very different, because even though the rules are simple, they have knock-on cumulative downstream effects on the process of making software. My guess is it doesn’t fit well with how most people think, and especially the order in which a problem is broken down (such as front-loading ownership decisions).
- gary17the 4y ago> What’s hard is (...) [building] [code] under the constraints of these rules Good point - I have to admit that, for example, the single-mutable-reference rule in Rust did force me to keep restructuring my code differently than I used to in other PLs and I did struggle with it to an extent. It doesn't automatically mean, however, that Rust is (literally) "harder to learn than other PLs". It is possibly the question of whether "a programming concept is hard to learn since it cannot be painlessly brought over from previous experience" or "a programming concept is hard to learn since it is hard to understand in itself".
- klabb3 4y agoYeah. It also depends on what we mean by learning a language. For most people, I assume we feel comfortable when we can achieve day to day tasks. You could have other metrics though, such as learning how to write code that is free from certain problems, like safety and data races. The amount of problems that Rust moves from the “runtime and unit test” domain to compile time errors is unprecedented in mainstream languages, and also that those errors are binary pass/fail showstoppers. Empirically, I’ve found that programmers coming from C/C++ are much more happy about that than other backgrounds, presumably because they are aware of the pains of having those issues appear at runtime. However, it’s also important to understand that there are a huge amount of use cases where those problems can be solved “good enough” with GCs and other runtime safeguards, which then can give other benefits that outweighs the downsides.
- scoutt 4y agoBut this might be the main difference. At least for me. I learn by imitating, like a child. I got my first guitar when I was a kid as a present (no internet, no money to study or to buy books). I learnt by imitating the music I liked. Later as an adult I got technical and I closed the circle with guitar and music theory and advanced techniques. This is the way I got into C and later C++ more than 25 years ago. Again, without internet, or with limited access. I understand ownership and lifetimes, but when I open a Rust project I cannot understand what the hell is going on. For new languages I want to learn, I read other people's code and try to do some modifications to check what changed, or add a small new feature. And Rust is so hard on the syntax and the way it wants things to be done. The worst part (for what learning regards) is that Rust doesn't forgive. So I started a new project. I had no problem with ownership and lifetimes, but later I realize that returning "Result<Self, Error>" and the "?" operator are no so magical after all. And "Error" sometimes is a struct defined in "io", sometimes it thinks is a trait, sometimes is defined in some other error-handling crate. Then you have to learn to map errors, boxing them, dyn dispatching, thinking about what is the overhead of all that, etc. And all that is just for returning something meaningful from a function. So it's not all "ownership and lifetimes".
- culebron21 4y agoAfter a year and a half doing hobby projects in rust, I must say this Error dispatch is the biggest pain. You may get used to ownership by just writing less ambitiously. But those errors everywhere, are quite tangled. Even Box<dyn Error> that seems universal, stops working with thread-related functions.
- gary17the 4y agoI agree, I think the Rust Gods should think of some ingenious way (which actually seems to be the norm when it comes to the "thoughtfulness" of the Rust ecosystem) to do both library-style error handling (where specific error conditions have to be handled differently by a library consumer) as well as app-style error handling (where multiple error conditions can be handled pretty much the same way by an event loop), add it to the standard library and `clippy` out (lint) the livin' lights out of every other approach out there :).
- staunton 4y ago> the music just won't happen, even if you're Mozart. Thousands of self-taught musicians, many of them famous, beg to differ. Not that this is relevant to the discussion but the example seems flawed.
- gary17the 4y agoOk, let me rephrase: "[without using any instructional materials] the music will take an unusually long time before it happens, even if you're Mozart". Which seems to correspond to the problem that if you keep hacking at a Rust compiler without using any instructional materials, it will take an unusually long time before you eventually get the code to compile by trial and error.
- pjmlp 4y agoMost of them had mentors in one form or another.
- justincredible 4y ago[dead]