Live data from Hacker News

A 30 minute introduction to Rust

words.steveklabnik.com

11–20 of 161 posts

Re: A 30 minute introduction to Rust

#11
A little OT...but what's with Svbtle's apparent default styling of links? There's no indication that any particular word or sentence contains a link, which basically makes those links invisible to readers. Or do lots of people read web articles by randomly hovering the mouse around the text?

But relevant to the OP...I generally try to save useful tutorials like this on my pinboard, which often doesn't pick up the meta-description text. So I double-click to copy the first paragraph and paste it into pinboard...except in the OP, I kept on clicking on text that was hiding links underneath.

It's a strange UI decision, and one that seems to discourage the use of outbound links...if you can't see the links, then what is the purpose of them? For spiders?

Re: A 30 minute introduction to Rust

#12
This isn't so much an introduction to Rust as it is an introduction to Rust's concurrency model.

The example of returning a reference to an automatic variable isn't super compelling, since every competent C/C++ programmer knows not to do it. That bug does pop up every once in awhile, but almost always in the context of a function that returns a reference to one of many different possible variables depending on some condition in the function.

Does Rust really call its threads "green threads"? Green threads have a weird reputation.

Copy like "this allows you to, well, read and write the data" could be tightened up; it's an attempt at conversational style that doesn't add much. "That doesn't seem too hard, right?" is another example of the same thing.

How much of Rust concurrency is this covering? How much of its memory model? Does the whole concept of Rust concurrency and memory protection boil down to "the language provides an 'unsafe', and then people write libraries to do things with it"?

Re: A 30 minute introduction to Rust

#13

Thanks for the the tutorial! Rust seems a bit too complex to me. Like a C++ on steroid that wants to do and be everything. Nothing wrong with that but not my cup of tea. I'd rather stick to C if I need tight memory management, it is way simpler and straight forward. And if I need concurrency, I'll stick to Golang (or erlang). Really, it's such a pleasure to read some golang after reading this 30 minutes of Rust. Anyw…

> I'd rather stick to C if I need tight memory management, it is way simpler and straight forward.

Well, if you don't want your C to segfault, you have to understand these concepts anyway, they're just implicit to the language. C's memory management may be simple, but it's surely not easy.

Re: A 30 minute introduction to Rust

#14
post #11

A little OT...but what's with Svbtle's apparent default styling of links? There's no indication that any particular word or sentence contains a link, which basically makes those links invisible to readers. Or do lots of people read web articles by randomly hovering the mouse around the text? But relevant to the OP...I generally try to save useful tutorials like this on my pinboard, which often doesn't pick up the met…

Yeah, I think that they have been made lighter recently. Bummer :/

Re: A 30 minute introduction to Rust

#15
post #11

A little OT...but what's with Svbtle's apparent default styling of links? There's no indication that any particular word or sentence contains a link, which basically makes those links invisible to readers. Or do lots of people read web articles by randomly hovering the mouse around the text? But relevant to the OP...I generally try to save useful tutorials like this on my pinboard, which often doesn't pick up the met…

> There's no indication that any particular word or sentence contains a link

There is a subtle grey underline, which I'm sure can be nearly invisible depending on your screen.

Re: A 30 minute introduction to Rust

#16
The last time I touched C code was my sophomore year in college, so maybe 12 years ago? As a result, the last time I had to deal with pointers and such was back then, as well.

I'm primarily a web-dev. Ruby, PHP, and Javascript are the languages I'm most familiar with at the moment.

Are there any Rust for Dummies-style tutorials floating around? As simple as this introduction is, it was still over my head...

Re: A 30 minute introduction to Rust

#17
I think we can be a little bit more charitable towards C++. Modern compilers will let you know if you try to do something as obviously incorrect as returning a pointer to a stack variable.

    $ cat > foo.cpp  int *dangling(void)
    > {
    >     int i = 1234;
    >     return &i;
    > }
    > EOF
    
    $ clang++ -Werror -c foo.cpp
    foo.cpp:4:13: error: address of stack memory associated with local variable 'i'
          returned [-Werror,-Wreturn-stack-address]
        return &i;
                ^
    1 error generated.

Re: A 30 minute introduction to Rust

#18
post #12

This isn't so much an introduction to Rust as it is an introduction to Rust's concurrency model. The example of returning a reference to an automatic variable isn't super compelling, since every competent C/C++ programmer knows not to do it. That bug does pop up every once in awhile, but almost always in the context of a function that returns a reference to one of many different possible variables depending on some c…

Green threads are the standard term for language-level threads that are not OS-level threads.

Re: A 30 minute introduction to Rust

#19
post #12

This isn't so much an introduction to Rust as it is an introduction to Rust's concurrency model. The example of returning a reference to an automatic variable isn't super compelling, since every competent C/C++ programmer knows not to do it. That bug does pop up every once in awhile, but almost always in the context of a function that returns a reference to one of many different possible variables depending on some c…

Salespeople qualify leads by determining if you're ready to buy or not. If you're not, they stop wasting time on you. The general idea for a quick introduction is to qualify your lead. So this isn't a "introduction to Rust's syntax" it's "an introduction to why you should (or should not) care about Rust."

> since every competent C/C++ programmer knows not to do it.

Everyone knows, yet programs still segfault. The point is that the language helps you be competent. Static analysis is very useful.

> Does Rust really call its threads "green threads"? Green threads have a weird reputation.

I agree. Rust has N:M mapped threads by default, but recently added 1:1 as well.

> it's an attempt at conversational style that doesn't add much.

I happen to write like I talk, it gets good and bad reviews. A more neutral style would be more appropriate if/when this gets pulled into Rust itself, thanks, that's a great point.

> Does the whole concept of Rust concurrency and memory protection boil down to "the language provides an 'unsafe', and then people write libraries to do things with it"?

I think this is an unfair characterization, but I gave it to you, so that's a criticism of me, not you. I tried to point out that unsafe exists for exceptional cases only: it's not something that you need unless you're doing something dangerous for a specific reason. I personally have only ever written unsafe when wrapping something with FFI.

Introductions are hard because you never know how much depth to go into; maybe I should go into these bits a little more in depth.

Thanks for the great feedback. :)

Re: A 30 minute introduction to Rust

#20

The last time I touched C code was my sophomore year in college, so maybe 12 years ago? As a result, the last time I had to deal with pointers and such was back then, as well. I'm primarily a web-dev. Ruby, PHP, and Javascript are the languages I'm most familiar with at the moment. Are there any Rust for Dummies-style tutorials floating around? As simple as this introduction is, it was still over my head...

I have you covered in that case as well: http://www.rustforrubyists.com/

I want to provide a version of the 30 minute intro that's not strictly for systems people as well, but you have to start somewhere.

Post reply on HN