Learning Rust :safe:

I’m learning a bit of Rust and starting this topic in case anyone is interested in discussing Rust or wants to help each other out with learning the language.

No need to be a programmer, anything to do with Rust is relevant to this topic including n00b questions. We can always create extra topics if needed, or maybe start a developer focused topic in the Dev forum.

What is Rust?

Rust is the programming language used to create the core of the SAFE Network, and was chosen because it is designed for building secure, reliable code in ways that avoid bugs and make difficult things easier to do well.

Official Rust Resources

  • Rust-Lang (website) is a good place to start. Lots of good resources and answers to your early questions can be found here, along with links to lessons, examples, tools etc.
  • The Rust Programming Language (book).
    An excellent tutorial style walk through all the features of Rust, free online and available in print.
  • Asynchronous Programming in Rust (book). How to use Rust’s asynchronous programming features (async, await etc.)
  • The Rust Standard Library (web reference)

Other Resources

  • Async programming in Rust with async-std (book). An alternative book on asynchronous programming in Rust.
Tools
  • VSCode/VSCodium works well as an integrated development environment with syntax highlighting, language and library reference using ‘intellisense’, debugger, clippy linter, and code formatter. See using VS Code with Rust.

Share What You Are Doing With Rust

I’d love to hear from anyone about their adventures with Rust! Please post as little or as much as you like on this topic about what you are up to, or are thinking about doing:

  • might be an idea for an app you are figuring out
  • maybe you’re reading something
  • maybe you are trying to understand something that just doesn’t make sense yet
  • maybe you are working on a Maidsafe issue
  • or building a simple game for the hell of it
  • maybe there’s a particular area that you are interested in, such as concurrent or parallel compassion
  • or tell use what you’ve done recently, hope to do soon etc
  • anything really

What are you up to, or thinking about with Rust?


This topic is a Wiki so anyone can add resources to this post.

23 Likes

To kick things off here’s what I’m up to. I’m interested in learning Rust because I think it will be a useful skill, particularly around the SAFE Network. This has begun now because I came across syncer, which is written in Rust and I’m trying to modify it to work with SAFE. I managed to do that, but found I can’t get it fully working without some extra features being added to the SAFE CLI, and am learning more to see if I might have a go at them.

To learn Rust, I’m reading The Rust Programming Language (see the OP), which is an excellent book and a very good way to get up to speed fast if you already know a systems language like C++. I’m a little over half way in a few days, have made quite a few notes, and getting to the hard bits :smile:

Before that I had a look at the SAFE CLI code and realised I would need to understand Rust much better before thinking about modifying it.

I’ve got a development environment set up in VS Codium (the privacy version of VS Code), which makes working with Rust very nice, and saves a lot of the work in catching errors, formatting code and helping me find what I need all in one place. And it has a built in source code debugger. :sunglasses: (Here’s a topic on using VS Code with Rust)

8 Likes

abc excercises https://exercism.io/tracks/rust/exercises/
and
lists of what crates there are https://crates.io/

6 Likes

Rust by Example
https://doc.rust-lang.org/rust-by-example/

24 days of Rust
https://zsiciarz.github.io/24daysofrust/index.html

Building a Roguelike game
http://bfnightly.bracketproductions.com/rustbook/chapter_0.html

5 Likes

Good work @happybeing

I have not much to add other than to say I read that rust had entered a top 20 popularity ranking, so it seems its been a good choice by David and the team: https://www.zdnet.com/article/programming-languages-rust-enters-top-20-popularity-rankings-for-the-first-time/

Apparently 86% of devs on stack overflow said they are keen to use it but only 5% are currently using it. Opportunity? https://insights.stackoverflow.com/survey/2020#overview

5 Likes

Thanks @happybeing for starting this wiki. I started reading Rust’s “the book” this weekend. I love the memory safety but ownership and borrowing require a bit of getting used to for me.
I initially had path and linking errors while setting up both the VS Code and Eclipse Corrosion IDEs on Mac Catalina. If you encounter that, try updating the Xcode app before digging into anything else. While I am not using the Xcode app at all, the update resolved the system configurations issues for the other IDEs.
Good luck all.

Eclipse Corrosion - provides development tools for Rust and Cargo inside the Eclipse IDE. https://projects.eclipse.org/projects/tools.corrosion

5 Likes

Great that you are reading this book too, I’ll be interested to hear more and chat about things like ownership.

I think ownership seems weird at first, because Rust is making it visible and has added checks to stop you screwing it up. With other systems languages your code would just crash! [Ed: If you’re lucky! h/t David]

Rust stops you screwing it up, helps you understand why it won’t compile, and requires you to think about what you want to happen so you can tell the compiler explicitly.

I think it starts to look very complicated because the power of Rust is in how concisely you can describe and how precisely you get to control several things like ownership, generic types, and closures. I was finding this tricky yesterday, but it helped a lot to look at each code example in those chapters and try to understand what the hieroglyphics mean. It will take practice, hard at first, but eventually will begin to gel I hope!

I expect to re-read those sections quite a few times, and have made notes with links so I can get back to where each feature is described quickly. I always find making notes helps me learn new stuff, even if I never look at them again which is usually the case.

I am both excited about and intimidated by the power of what I’ve just read about, and there’s quite a bit of the book still to go.

4 Likes

It’s actually better, other languages might not crash and do worse (crash is really best case). Many langs like c/c++ will let you read an apparently cleared/freed mem location and it might work. It’s based on the fact the system may not have allocated that mem yet so it knida still works. Even worse the allocator does use the mem and something unexpected is in there. It might still “work” but now your system is in undefined behavior state.

So I see rust mem handling and also immutable by default values as saying to you the dev, “I understand what you are doing, I have confirmed there are no memory safety issues and you won’t be suprised”.

5 Likes

List of some less known crates I’ve found useful:

  • nohash-hasher – useful for hash maps of simple primitives
  • qcell – alternative for RefCell, which is compiled time checked.
  • ring – hmac, digest with good performance
  • snmalloc-rs – faster allocations
  • coarsetime – fast time access
4 Likes

Share What You Are Doing With Rust

I’d love to hear from anyone about their adventures with Rust! Please post as little or as much as you like on this topic about what you are up to, or are thinking about doing:

  • might be an idea for an app you are figuring out
  • maybe you’re reading something
  • maybe you are trying to understand something that just doesn’t make sense yet
  • maybe you are working on a Maidsafe issue
  • or building a simple game for the hell of it
  • maybe there’s a particular area that you are interested in, such as concurrent or parallel compassion
  • or tell use what you’ve done recently, hope to do soon etc
  • anything really

What are you up to, or thinking about with Rust?

7 Likes

Me and a few others are building a kinda network thing :slight_smile:

17 Likes