r/rust•
azerupi

Giving a talk about Rust at my university, any pointers?

I proposed to give a talk about Rust at my university and they are very enthusiastic about it. My audience will consist mostly of engineering students with a specialization in Programming and Software engineering. They should have experience with C / C++ so I would like to talk about the benefits of using Rust and show a couple of examples where Rust would have caught a memory bugs.

The talk should stay approachable for people with no systems programming experience and I would maybe also like to compare Rust with garbage collected languages.

This is the kind of style and content I am going for: Presentation by Alex Crichton

I remember watching a lot of good presentations introducing Rust when 1.0 came out, but I don't remember where to find them. If you have a link to a presentation you found really good, that would really help me. Or If you gave a talk in the past and could give me some pointers, things to watch out for, .. that would be immensely helpful too :)

Edit: I should also add that I will be giving the talk in French

Posted Jan 27, 2016, 10:15 PM UTC · edited

1937
steveklabnik1rust•

Here's some:

  • &T
  • &mut T
  • Box<T>
  • Arc<T>

(Sorry, I couldn't help myself 😉)

If you like Alex's style, look for Niko's talks as well. They're good!

53
DroidLogiciankiss-ui · img-dup · rust•

[Relevant XKCD] (https://xkcd.com/138/)

Mods feel free to delete if this violates the "no memes" rule. You know I mean well.

13
birkenfeldclippy · rust•

One more instance of me thinking "if only this one worked in German too..."

7
llogiqclippy · rust•

Yeah that's the problem with puns. They usually don't translate well. Case in point: As a hobby, I translate thecodelesscode into German. The number of puns I had to somehow work around has to have four digits already.

2
llogiqMODclippy · rust•

Why should we? It's a constructive comment, and OP may perhaps use it on their slides. Or isn't the party hearty enough?

6
DroidLogiciankiss-ui · img-dup · rust•

I just figured the whole "Relevant XKCD" thing would fall under the "Meme" category, even if it is relatable to the topic at hand.

5
llogiqclippy · rust•

I guess we mods would delete stuff like that if it was off topic. In this case, I feel it's sufficiently relevant.

2
xkcd_transcriber•

Image

Mobile

Title: Pointers

Title-text: Every computer, at the unreachable memory address 0x-1, stores a secret. I found it, and it is that all humans ar-- SEGMENTATION FAULT.

Comic Explanation

Stats: This comic has been referenced 100 times, representing 0.1026% of referenced xkcds.


^xkcd.com ^| ^xkcd sub ^| ^Problems/Bugs? ^| ^Statistics ^| ^Stop Replying ^| ^Delete

2
Denommusrust•

I was expecting this joke. Thank you.

6
azerupiOP•

Haha, of course you couldn't ;)

Does Niko have other talks than the one from RustCamp? That's the only one I have seen from him I think.

5
steveklabnik1rust•

Looking around, it looks like the ones I've seen may not have been recorded :/

1
azerupiOP•

Ah too bad, maybe he kept the slides?

u/nikomatsakis do you have slides of your past presentations? :)

1
shadowmint•

If you're pitching to a C/C++ audience I would recommend you focus on things they'll be interested in rust for, not on the low level syntax or semantics, which they may not particularly care about (the rust book covers a lot of this stuff).

Some high level ideas:

  • Traits vs. Concepts (https://en.wikipedia.org/wiki/Concepts_%28C%2B%2B%29)

  • Every type in rust is like unique_ptr, automatic memory management without a GC.

  • Rust has a package manager, and it's actually pretty darn good.

  • Rust can implement 'black box' modules that are directly invokable from C/C++ via c calling convention code.

  • Rust can call existing libraries with a C api; you can keep using your existing code.

  • cfg() and how Rust is strongly cross platform without #ifdefs

  • Runtime performance compared to C/C++ in benchmarks

It's also always worth mentioning a few pain points, because nothing is perfect:

  • Calling C++ from rust can be tedious, as your have to write a C api for it.

  • The windows support is a bit flakey.

  • The IDE support and tooling is ok, but it's not on par with C++ (yet).

  • Exceptions and recovering from panics, the state of https://github.com/rust-lang/rust/issues/27719

If you're specifically planning on focusing on memory safety, I'd really strongly recommend to compare your solution to C++ static analysis tools and using unique_ptr in C++ to show how rust is actually better; because similar sorts of tools exist in C++ too, so a 'look what you can do!' approach may fall somewhat flat.

10
llogiqclippy · rust•

I'd also at least skim the concurrency and parallelization support (e.g. show a short crossbeam or simple_parallel example, and how borrowck keeps you from introducing data races).

8
shadowmint•

Yep, especially contrasting to a GC language like golang for example, would give you a good idea of the power (and limitations) of using rust closures.

3
azerupiOP•

That's a wonderful idea!

Do you know of a simple example that could show off crossbeam without being to complicated to explain during the talk?

3
llogiqclippy · rust•

I think u/steveklabnik1 's OreDev talk "Concurrency in Rust" has a good small example. Also I enjoy watching him live coding. :-)

3
azerupiOP•

Ah yes, I remember that talk. Thanks for the link! :)

3
DroidLogiciankiss-ui · img-dup · rust•

Gotta nitpick, sorry.

Every type in rust is like unique_ptr, automatic memory management without a GC.

Box<T> is usually equated to unique_ptr since it's an RAII managed heap pointer; objects on the stack in C++ get their destructors run at the end of the scope just like in Rust. Rust just has some extra bits to make this safer and more ergonomic to use (ownership, lifetimes, move-by-default).

The big win Rust has over C++ is that the static analysis is part of the language instead of in third-party, often proprietary and expensive tooling.

6
shadowmint•

I said 'like unique_ptr' not 'exactly the same as unique_ptr'. :P

Anyhow, my point was mainly that C++ professionals do use those tools, so although 'built in tools' is a win, it's not necessarily a killer use case for people who already have an equivalent.

1
DroidLogiciankiss-ui · img-dup · rust•

My concern is just that your comparison to a heap-allocated pointer might lead some to believe that Rust allocates on the heap by default. What we want to show, IMO, is how much easier and safer Rust makes it to work with the stack.

3
azerupiOP•

Thanks! Some really good points

If you're pitching to a C/C++ audience

I don't expect my audience to be experienced C / C++ programmers. They will have had a couple of classes using C / C++ but not much more experience than that.

I'd really strongly recommend to compare your solution to C++ static analysis tools and using unique_ptr in C++ to show how rust is actually better

Most of the audience will probably never have used any static analysis tools, so I am not sure it's a good idea to talk about that too much.

My goal is more to introduce Rust, make my audience curious and explain the advantages of using Rust instead of a full comparison with C/C++

4
lambdaburritorust•

Quelle Université? C'est Université de Strasbourg? Je suis curieux parce que je suis en Alsace prochaine semaine. Le présentation de Alex Crichton est la foundation perfait pour votre conversation. Bonne chance!

5
azerupiOP•

Non pas du tout, je suis de Belgique. Je vais faire ma présentation à l'ECAM à Bruxelles mais il n'y à pas encore de date prévue. C'est une haute école enfaite mais je ne suis pas sur qu'on fait la distinction en Anglais.

Je suis tout à fait d'accord avec toi, la présentation d'Alex est excellente!

Merci pour l'encouragement :)

4
Denommusrust•

It's amazing how much of those are somewhat understandable to me as a Portuguese speaker because of the common roots on latin.

6
sigma914•

To be fair I can extract the gist of this and I only speak English, context is a wonderful thing

2
Sean1708•

Uhhh.... fetchez la vache?

1
lambdaburritorust•

De rien et désolé parce que je suis inculte mais je connais Stromae! :p J'ai un autre conseil pour toi. Parler de "Pattern Matching" parce que c'est très puissant.

(I go back to English to not loose what I want to say in translation)

Pattern matching provides a powerful way to express "if you see this kind of node with that kind of node inside it, do this thing". You can do really cool symbolic manipulations like deforestation of a AST, prove theorems (à la Coq), verification of correctness, etc.

Here's an example. You could also make evaluation optimizations to this example using laws of boolean algebra like Not(Not(x)) => x to reduce the number of evaluations.

C++ doesn't have algebraic data types so it's quite awkward to write equivalent. We have boost::variant but it's not baked into the type system.

Another thing is not just the memory safety but writing statically correct code. For example, if I missed a match, say Expr::Not(), then the compiler will complain that I haven't matched it.

I am happy to review your presentation to give feedback as it will be good practise to improve my French.

1
azerupiOP•

Thanks, that's a good idea too. I remember that when I first saw the match syntax I was amazed! I am not too experienced with algebraic data types though, I don't think I have ever used the more powerful features it offers. Do you have some good reading material about that?

I am happy to review your presentation to give feedback as it will be good practise to improve my French.

Sure, that would be great. I will need people to review it to make sure that what I am telling is correct ;)

1
kouteiheika•

If the audience is going to consist of students without huge amounts of experience I'd focus on making the presentation a little more, hmm, flashy instead of being very technical.

For example:

  1. Slide N: show a relatively simple C++ program that looks correct; tell the audience that there is an error in it - ask them if they can pinpoint it.
  2. Slide N+1: show the C++ program being run; a wild segmentation fault appears!
  3. Slide N+2: show exact same program written in Rust.
  4. Slice N+3: show that Rust, unlike C++, refuses to compile the program.
  5. Explain.
  6. Jump to 1.

Basically try to make an impact instead of just throwing technical details at them which are not going to be as convincing nor memorable. Also try to include some interactivity (e.g. the "do you see the error in this program?" mentioned before).

5
azerupiOP•

Yes! That's exactly what I am planning to do :) I will of course talk about other aspects but that will be a major part of the presentation.

1
MrMarthog•

I once gave a talk about RAII and Ownership at my university. It was a similar audience (computer scientists, at least java and basic C knowledge), although the topic was a bit different, because I did not just talk about rust alone and focused on a single aspect of it.

It seemed to be quite understandable, although there was a question about the syntax of the lifetimes example, especially in the combination of lifetimes and generics.

3
azerupiOP•

Thanks, very interesting read!

1
gnuvince•

Rust is a large and complex enough language that you could talk about it for 6-7 hours, so I think it makes sense to pick one aspect that you'd like to discuss and concentrate on that. My suggestion would be to go with a talk about move semantics, ownership, borrowing and lifetimes: it's the thing that will most likely stump people who decide to try Rust, it's interesting to both C/C++ developers (because they need to worry about that stuff) and to Ruby/Python programmers (because they never had to really think about those issues). At least, that's what I'll be doing for my own talk to my lab.

1
azerupiOP•

Yes, I am at the stage where I need to choose what I will be talking about, it's so hard because there is so much to say! I am not sure I want to pick one (or two) aspects and explain that in detail. I would prefer to offer an overview of why Rust is awesome and make the audience curious enough to look into it on their own.

1
gnuvince•

I feel that since there are so many good intros to Rust already online, I can just link to those and talk about something different.

1
azerupiOP•

That is totally understandable. But the point of the presentation is to introduce Rust to students and profs who have probably never heard about it. Going deeper in one area is probably better for people who have already been exposed to Rust or have enough programming experience to know exactly what the equivalent would be in their language (e.g. c++). At least that's what I think :)

1
[deleted]•

[deleted]

-1