Getting hands wet with Rust

Hi everyone,

Before I ask my question, I would like to compliment the people who take the time to answer questions and run the forum how great a job they are doing. Till now my learning experience with Rust has been pleasant. The Rust Forum has an almost calming effect on me (who knows, maybe I am stupid like that !!!) So to all who help run the forum, Thank you ! You are helping a lot of people who would either never get their questions answered or worse, would be too scared or shy to ask in the first place. (although I am sure you knew this already, but I felt like saying it) :upside_down_face:

Its been about two months now that i am learning Rust using the Rust Book and am getting close to finishing it. I am looking for advise on how to move forward to some real world programming.

My interests involve web/cloud applications (and lately simulations). I have my eye on this page, that I think might lead me to interesting places.

4 Likes

The standard answer to this (which I often find completely unhelpful) is to pursue something that interests you.

Often when I learn a new language I'll come in with a particular application in mind (e.g. because it may have really nice libraries or be required for a particular platform). For example, I might learn Kotlin so I can write Android apps or Python so I can use the pandas and matplotlib libraries for data analysis and plotting.

Simulations are a really good use case for Rust because it's useful to have precise control over how memory is managed or use the Send and Sync traits to ensure thread-safety when you try to distribute work across multiple threads. I'd recommend trying something where you can get visual results really quickly because that can give you a real sense of accomplishment, for example you could simulate the heat equation in 2D. A simpler form of this sort of simulation is Conway's Game of Life (instead of using thermodynamics to figure out the next state for a particular spot you just look at the neighboring cells).

One of my first projects when learning a new language is to write a parser and interpreter/compiler for a toy programming language (typically a Lisp). I like this because it provides a healthy mix of string manipulation, data structures, memory management, is really easy to test (source code goes in, output or errors come out), and can be written equally nicely in OO, functional, or procedural style. There are loads of tutorials for implementing a Lisp parser and tree walking interpreter on the internet, but this one looks alright.

Another thing you might do is have a look at random crates on crates.io and see if any catch your fancy. There are some really awesome libraries out there and by skimming through their API docs or examples you may come up with a cool project idea. Here are a couple that interest me:

  • wasmer - a WebAssembly runtime
  • wasm_bindgen (book/docs) - a crate which helps you write code that can be called by JavaScript from inside the browser
  • serde (book/docs) - the main crate for converting Rust types to/from various formats (JSON, YAML, TOML, etc.)
  • clang - bindings to the clang compiler for parsing and inspecting C or C++ programs (you could use this to read in a C program and automatically generate Rust bindings, for example)
  • pyo3 (book/docs) - write bindings which let people use your Rust code from Python
  • reqwest - a really nice HTTP client
  • actix-web (website/docs) - a fairly popular web framework

Yeah, each community will have its own culture and behaviors it rewards or punishes. Normally if I come across one that doesn't work for me I'll walk away to find something better.

It's a good idea to avoid naming specific communities/people though because people may take offence (you did just insult their community after all) and you'll get dragged into arguments or :poop:-slinging matches... Which propagates the exact situations you were trying to avoid in the first place.

1 Like

The way to move forward is to move forward. Take the first step. "A journey of a thousand miles starts with a single step" according to Chinese proverb.

Be aware that the first step can be the hardest.

In the case of getting into Rust I feel it's essential to read and understand a lot of the Rust Book before trying to make anything real: The Rust Programming Language - The Rust Programming Language. That includes trying out all the snippets of code and examples you find in there.

I say this because Rust has such significantly new and different features compared to pretty much any other language you may know that it's not so productive to think "I'll just dive in to a Rust project and pick up the details of syntax as I go along, can't be much different from C or Javascript or whatever". I know this because that was the mistake I made!

If web/cloud is something that has attracted your curiosity then how about then moving on to getting familiar with a web server frame work like Rocket https://rocket.rs/ or Actix https://actix.rs/. They have great documentation and enable one getting something nice up and running pretty smoothly.

2 Likes

Thanks for such a detailed response ! I've also removed any references to specific external sites as per your suggestion.

Thanks @ZiCog I will check out the two frameworks you mentioned. Cheers !

1 Like