Live data from Hacker News

Rust for Professionals

overexact.com

21–30 of 103 posts

Re: Rust for Professionals

#21

Earlier quoted context omitted.

I mean, some question. I learned Rust with 0 professional experience in any language (I learned it after I dropped out of a CS program after 2.5 years) and I found it pretty damn easy. That was in 2015 when the language was wayyyy less approachable (worse borrow checker, everything used nightly, smaller community, no book). Easy is relative. I suspect a major reason I found it easy was because I didn't try to solve l…

> Easy is relative In the case of programming languages, yes, it's relative to the difficulty of other PLs. I've learned many over the years, and found Rust by far the hardest (it's the only one that defeated me). And it's not the most different from others I've learned - lisps are far further from the common languages than Rust is. > I suspect a major reason I found it easy was because I didn't try to solve lifetime…

> In the case of programming languages, yes, it's relative to the difficulty of other PLs.

I've learned many many PLs at this point. Rust was one of the easiest for me.

> Well yes anything's easy if you skip the hard bits. Learn C without using pointers.

That's my entire point. Rust is not hard if you learn the easy parts first. Trying to learn everything at once is not easy, no matter the language. Once the problem becomes just learning the borrow checker it's not that big of a deal. The harder thing to do is learning the borrow checker and traits and closures and blah blah blah.

Re: Rust for Professionals

#22

Earlier quoted context omitted.

You can also use Cow to choose between cloning and and immutable borrowing at runtime.

Unless you're using `'static` you will still run into lifetimes with Cow, which I suspect a lot of people will find difficult. I'd suggest just using clone, learning the broader language, and learning about lifetime stuff later. Lifetimes aren't hard or complicated, what's complicated is understand their interaction with other features (closures) when you don't even understand wtf closures in rust are, or traits, etc…

> Lifetimes aren't hard or complicated,

Untrue - read https://users.rust-lang.org/t/what-is-a-good-mental-model-of.... Even Rust aficionados can't describe how they work without vast screeds. Or if you think the posters there are just wrong, try the RFC on which the current implementation is based: https://rust-lang.github.io/rfcs/2094-nll.html. You truly don't find that hard or complicated?

It may be the case that people can use simplified subsets of the language to ease their way. But when a Rust advocate says that in effect to understand lifetimes you have to read the standard library source (as is written in the forum thread linked above), because no current documentation is comprehensive enough to cover it, then you know the whole thing itself is pretty complex.

Re: Rust for Professionals

#23

Earlier quoted context omitted.

Unless you're using `'static` you will still run into lifetimes with Cow, which I suspect a lot of people will find difficult. I'd suggest just using clone, learning the broader language, and learning about lifetime stuff later. Lifetimes aren't hard or complicated, what's complicated is understand their interaction with other features (closures) when you don't even understand wtf closures in rust are, or traits, etc…

> Lifetimes aren't hard or complicated, Untrue - read https://users.rust-lang.org/t/what-is-a-good-mental-model-of... . Even Rust aficionados can't describe how they work without vast screeds. Or if you think the posters there are just wrong, try the RFC on which the current implementation is based: https://rust-lang.github.io/rfcs/2094-nll.html . You truly don't find that hard or complicated? It may be the case that…

> You truly don't find that hard or complicated?

This is like saying: "You think a 64bit integer is simple? OK, let's dig into the C memory model, twos complement, overflow CPU flags, how CPU caches are implemented, architectural nuances that can lead to unsynced writes from registers to RAM, etc". In reality most people can just learn that it's a number that holds 2^64 values, not complicated. If you want to really understand integers though go read the intel manual and the C memory model specification.

Are lifetimes complicated? If you're a compiler developer who needs to consider the implications across all features and edge cases, yes. If you're learning the language and you just want to write "find me a &str in another &str but don't clone it", no, it's not complicated at all.

The vast majority of beginners can just learn "& means any number of readers and no writers, &mut means one writer and no readers".

Re: Rust for Professionals

#24
post #3

It'd be nicer if there was some way of selection which language is shown on the left side. Expecting readers to understand both C++ and Kotlin and Java and Javascript will be a stretch for most.

All of those languages adopt the C-like syntax and semantics, it shouldn't be hard for someone with familiarity with languages in that family to deduce what's being conveyed in code in languages they might not have experience with.

Re: Rust for Professionals

#25

Earlier quoted context omitted.

> Lifetimes aren't hard or complicated, Untrue - read https://users.rust-lang.org/t/what-is-a-good-mental-model-of... . Even Rust aficionados can't describe how they work without vast screeds. Or if you think the posters there are just wrong, try the RFC on which the current implementation is based: https://rust-lang.github.io/rfcs/2094-nll.html . You truly don't find that hard or complicated? It may be the case that…

> You truly don't find that hard or complicated? This is like saying: "You think a 64bit integer is simple? OK, let's dig into the C memory model, twos complement, overflow CPU flags, how CPU caches are implemented, architectural nuances that can lead to unsynced writes from registers to RAM, etc". In reality most people can just learn that it's a number that holds 2^64 values, not complicated. If you want to really…

> The vast majority of beginners can just learn "& means any number of readers and no writers, &mut means one writer and no readers".

But 'beginning' is never the hard part of learning any programming language, at least for a programmer. The hard part is going from having learned the basics to getting stuff done. Rust is harder than any other mainstream language to do that in. The writers in that thread can't even describe their mental model (NOT the underlying tech as you claim) of lifetimes without vast elliptical descriptions. And they can't point to any straightforward documentation.

I have learned multiple programming languages, of many different paradigms, and never had the trouble getting to the stage of writing useful software that I have had with Rust. I've witnessed the same again and again with all the people I know - all professional programmers. In fact I'm the only one I know who's stayed with it.

I find the denial of Rust's difficulty (and not even centred on the borrow checker - it's the use of just about every commmon library) just very very strange. Odd enough (and distant enough from the obvious, adn the experience of every person I've known) that I find it completely incomprehensible.

Re: Rust for Professionals

#26

Earlier quoted context omitted.

> You truly don't find that hard or complicated? This is like saying: "You think a 64bit integer is simple? OK, let's dig into the C memory model, twos complement, overflow CPU flags, how CPU caches are implemented, architectural nuances that can lead to unsynced writes from registers to RAM, etc". In reality most people can just learn that it's a number that holds 2^64 values, not complicated. If you want to really…

> The vast majority of beginners can just learn "& means any number of readers and no writers, &mut means one writer and no readers". But 'beginning' is never the hard part of learning any programming language, at least for a programmer. The hard part is going from having learned the basics to getting stuff done. Rust is harder than any other mainstream language to do that in. The writers in that thread can't even de…

The rust borrow checker has been described in trivial terms many times. The first time I had it explained, as I recall, was as a book.

You own a book.

`&` - You can lend others the book, they can't fuck with it. `&mut` - You can lend the book to one person, they can fuck with it `move` - You give someone else the book, it's theirs now

Or `many reader NAND one writer`

Is this a complete explanation? No. But it's quite simple and you can be plenty productive with just this amount of understanding.

Your experience is not my experience. I used Rust for the first project I wrote as an intern after dropping out, having never used it before, and I even used it to interact with mysql, which I had never used before.

At my last company I had multiple people pick up rust in a matter of days.

I'm not denying rust as being difficult, I'm saying it's easy for some and hard for some. I found it easy, I was writing productive code on day 0 with virtually no preparation other than that I wanted to try it out. Many people find it easy. Obviously some people, many people, find it hard. Life's weird like that.

Re: Rust for Professionals

#27

Earlier quoted context omitted.

> You truly don't find that hard or complicated? This is like saying: "You think a 64bit integer is simple? OK, let's dig into the C memory model, twos complement, overflow CPU flags, how CPU caches are implemented, architectural nuances that can lead to unsynced writes from registers to RAM, etc". In reality most people can just learn that it's a number that holds 2^64 values, not complicated. If you want to really…

> The vast majority of beginners can just learn "& means any number of readers and no writers, &mut means one writer and no readers". But 'beginning' is never the hard part of learning any programming language, at least for a programmer. The hard part is going from having learned the basics to getting stuff done. Rust is harder than any other mainstream language to do that in. The writers in that thread can't even de…

> Rust is harder than any other mainstream language to do that in.

It's not hard, you just add boilerplate. Cloning data, using interior mutability, or adding ref counting to deal with cases where multiple "owners" can keep an object around independently.

Then removing the boilerplate is how you do optimization, once you've gotten things to work. The opposite of other languages where low-level code is the most verbose and least intuitive.

Re: Rust for Professionals

#28

Earlier quoted context omitted.

> You truly don't find that hard or complicated? This is like saying: "You think a 64bit integer is simple? OK, let's dig into the C memory model, twos complement, overflow CPU flags, how CPU caches are implemented, architectural nuances that can lead to unsynced writes from registers to RAM, etc". In reality most people can just learn that it's a number that holds 2^64 values, not complicated. If you want to really…

> The vast majority of beginners can just learn "& means any number of readers and no writers, &mut means one writer and no readers". But 'beginning' is never the hard part of learning any programming language, at least for a programmer. The hard part is going from having learned the basics to getting stuff done. Rust is harder than any other mainstream language to do that in. The writers in that thread can't even de…

Ok, so how do I do one writer and one or more readers?

Re: Rust for Professionals

#29
post #9
post #3

It'd be nicer if there was some way of selection which language is shown on the left side. Expecting readers to understand both C++ and Kotlin and Java and Javascript will be a stretch for most.

My experience with Java ended circa 2000 and I never wrote a single line in Kotlin. But I read these examples without noticeable issues.

what have you been programming in the past 20 years?

Re: Rust for Professionals

#30
post #7

Earlier quoted context omitted.

AFAICT, the expectation is that the reader knows at least one modern programming language from the list, and maybe is acquainted in passing with a couple of others. So at least some comparisons should click. (They seemingly don't use more apt comparisons with OCaml and Haskell, for instance, not expecting the reader to know them.)

Javascript I've seen a decent amount and tweaked/edited some of code in it but I wouldn't say I "know" it at all. Kotlin I've never even seen before and I know literally nothing about the language. Java I wrote a bit of in high school but haven't touched it in 15 years. So yeah there's quite a lot that people wouldn't know.

Well, Golang? Pascal? They have similar ways of declaring data types, for instance.

This guide is not going to magically teach you Rust is there's nothing to compare it to; there are other guides to help those without a background. But it could somehow help people who already have similar concepts in their mind to link them to corresponding concepts in Rust.

Post reply on HN