Live data from Hacker News

A 30 minute introduction to Rust

words.steveklabnik.com

51–60 of 161 posts

Re: A 30 minute introduction to Rust

#51

Earlier quoted context omitted.

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.

Do you see Rust as a language that people will write the business domain type applications in or as a supplement to languages like Ruby, Python, etc. to write those "gotta have performance here" parts of the application?

The second ever (that we know of) use of Rust in production is by Tilde, who are using Rust embedded in Ruby for Skylight to help ensure that memory usage stays down and to get more consistent performance. Garbage collection while doing performance monitoring is bad news.

I'm not entirely sure yet. I wrote another post that touches on this: http://words.steveklabnik.com/rust-is-surprisingly-expressiv...

I think that it's possible that Rust might eventually be useful as an application level language. We'll see how it shakes out. We've been in love with scripting languages for the past few years, but now their drawbacks are becoming more apparent. Look at all the Rubyists and Pythonistas flocking to Go, for example...

Interesting times indeed.

Re: A 30 minute introduction to Rust

#53
post #43

I think the emphasis on "unsafe" isn't helpful. As far as I can tell, the only thing that "unsafe" is enabling is that Arc and RWArc are written in Rust rather than in C in the runtime (the way they'd be in Go, or Erlang, or Haskell). The things that make Rust able to do what it does are ownership and tasks and lifetimes and affine types -- all the things the post covers before talking about "unsafe". Also, it gives…

> Also, it gives the impression that there's something fundamentally unsafe about all of this, whereas the whole point is that these abstractions are _safe_ to use.

Right, this is my point. I should find a way to make it a bit more clear.

I wrote it this way because the systems people I talk to are skeptical at times that a compiler knows best. After all, there's a reason you want that low-level control in the first place, right? The ability to escape things when you have to relaxes people.

Re: A 30 minute introduction to Rust

#54
post #32

Earlier quoted context omitted.

Ha! Bummer, maybe I will just need to re-write this paragraph. A RWArc is shared mutable state: you can have two references to the Arc in two different tasks. Yet I said that Rust throws a compiler error for shared mutable state. > (at first I thought it was implemented in C/C++). There's very little C++ in Rust anymore. :) > Seems easy, one needs a "backdoor" to implement RWArc in Rust Yup, this is exactly the point…

> Maybe I should just straight-up remove them. Or be explicit that you'll now talk about RWArc implementation .

Yes. This.

I found it a bit worrying, as when I read that I had to go back and re-read the code a few times to make sure that there wasn't an unsafe block in the code, or perhaps that the use of RWArc implied unsafe, and would then turn that whole function into an automatically unsafe block.

Nevertheless, very cool. I really liked the tutorial, I'm getting quite excited by Rust.

Re: A 30 minute introduction to Rust

#55
post #33

Earlier quoted context omitted.

I wasn't trying to undermine your argument. Rust is solving real problems. Use after free and double free are still issues in the C world. In modern C++ we are (hopefully) using smart pointers (std::unique_ptr, std::shared_ptr) to manage heap-allocated object lifetimes.

> In modern C++ we are (hopefully) using smart pointers (std::unique_ptr, std::shared_ptr) to manage heap-allocated object lifetimes. Those aren't safe. There are many ways to cause use-after-free with unique_ptr: for example, placing a uniquely-owned object in a vector and clearing the vector in a method call on that object.

True, and hopefully the likes of D, Rust and Go will improve the situation.

In the mean time, we can take advantage of modern C++ safe constructs instead of keep on using C, as new language adoption always takes time.

Re: A 30 minute introduction to Rust

#56
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…

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

They are hard to come by, in this time and age, of cutting down costs everywhere while offshoring components.

Re: A 30 minute introduction to Rust

#58

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…

> C if I need tight memory management, it is way simpler and straight forward

If you work alone yes. Good luck on a 50+ developer team size, with high atrition rates.

Re: A 30 minute introduction to Rust

#59
post #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.

Allow me to save everyone from opening their devtools:

  background-color: #FFF;
  border-bottom: 2px solid #F4F4F4;
In RGB, that's the difference between 255 and 244. It's more than a little absurd.

Re: A 30 minute introduction to Rust

#60
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 poi…

> I happen to write like I talk, it gets good and bad reviews.

There's nothing wrong with writing casually for a web page that is meant to be inviting to newcomers.

I've ignored Rust links on HN until the subject of your link got me to take a look. The style was fine and you did a good job in at least showing a few snippets of code while advocating the benefits of the language.

Contrary to tptacek's criticisms, I wasn't looking for a dry or comprehensive manual - just something to read in a couple of minutes that would give me an indicator of whether or not I should look further into the language.

Thanks for the article.

Post reply on HN