Why learning Rust ?

By clecam, 30 September, 2024

I see several advantages to learning Rust. 

 

Technically speaking:

  • First of all, it is a very safe language, more than Scala.  I’m starting to explore the world of multithreading in Rust with the Actix library. It looks like Akka Actor in Scala. I’ve just realized its power in terms of control. For example, a method (a class function) that returns a Future on an internal variable is not valid. Indeed, the class might have been deallocated from memory because it’s no longer in use, while the Future is still running. We can clone the internal variable and pin the Future’s code location. with Box::pin, we ensure it is stored in the heap.

 

  • Secondly, Rust is an elegant language. It natively integrates type classes. In fact, there is no other option since there is no inheritance, only ad-hoc polymorphism. We just declare a trait behavior, a struct and then implement the trait for the struct. That's it. There is no need to use a complex syntactic sugar like in Scala. 

 

  • Finally, there is object safety required for use with dynamic dispatch. A function inside a dynamic trait cannot return Self since size must be resolved

For use cases, we can imagine several purposes:

  • LLMOps,
  • Long term compatibility with newer versions of Rust
  • Others: WASM, Data ingestion, ...

For expected gains:

  • Fast code execution (with benchmarking and again safety)
  • Energy saving

As regards complexity, Rust becomes very accessible with help of AI.

 

 

 

Comments