Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust? 🤓 #103

Open
3 tasks
nelsonic opened this issue Sep 2, 2022 · 6 comments
Open
3 tasks

Rust? 🤓 #103

nelsonic opened this issue Sep 2, 2022 · 6 comments
Labels
discuss Share your constructive thoughts on how to make progress with this issue enhancement New feature or enhancement of existing functionality epic A feature idea that is large enough to require a whole sprint (5 days) and has smaller sub-issues. question A question needs to be answered before progress can be made on this issue research Research required; be specific technical A technical issue that requires understanding of the code, infrastructure or dependencies

Comments

@nelsonic
Copy link
Member

nelsonic commented Sep 2, 2022

Context

Rust has been at the TOP of the "most loved" programming languages list for the last few years: 🔝
https://survey.stackoverflow.co/2022/#technology-most-loved-dreaded-and-wanted

stackoverflow-most-loved-programming-languages

This year Elixir was finally allowed on the survey again and no surprise, it's #2! 💧 😍
In previous years it was excluded from the survey so obviously it didn't appear in the results ... 🤦‍♂️

What?

Rust is a multi-paradigm, general-purpose programming language. Rust emphasizes performance, type safety, and concurrency.

The aspects that appeal to me about Rust are:

  1. Types + compile-time type-checking. This is mega helpful in a larger team building more complex software/systems. 👌
  2. Memory safety; not crashing mid process! (looking at you JavaScript - and all compile-to-JS languages!) 🦺
  3. Performance: execution speed is similar to C so if we need to perform lots of ops fast ... 🚀
  4. "Recruit-ability" don't know if that's a word, but you get the idea: finding team members who are passionate about solving problems and writing high-performance code. i.e. the best engineers. Ref: paulgraham.com/pypar 💡

These pros are all great, but the learning curve for Rust is considerably steeper than for Elixir. 📈

We have all dabbled with Rust informally, but haven't had a need for it in a project yet. 🧑‍💻
Recently I've enjoyed watching "Code to the Moon" videos on Rust:

Rust Demystified 🪄 Simplifying The Toughest Parts: https://youtu.be/TJTDTyNdJdY
image

Rust's Alien Data Types 👽 Box, Rc, Arc:
image

They have been an acute reminder of how much more complex Rust code is when compared to Elixir.

I feel that we already have a superb Tech Stack with PETAL + Flutter until we need Rust for performance or safety reasons.
All the practical reasons why Elixir is a great choice for the product/services we are building are still relevant. And the learning curve for new contributors is virtually flat for Elixir whereas having a Rust-wall to contribution on our core App might put a lot of people off ... the counter-argument is obviously that using Rust would be evidence of our focus on performance i.e. "Never waste anyone's time"

How?

There is a great Free / Open Source Book: https://doc.rust-lang.org/book
and we have a repo waiting to be populated: https://github.com/dwyl/learn-rust

There is evidence that Rust works on iOS and Android so we could explore those options but AFAIK it's all very experimental ... 🧑‍🔬
But where Rust would shine would be in handling a specific aspect of compute for us such as transforming large data structures.
We don't currently have the need for it. Which is why I haven't invested the time to get good at it.
I want to resist the temptation to invent a "reason" to use Rust until we have a legit need.
But if anyone else reading this wants to proactively learn Rust and populate the dwyl/learn-rust repo ...
It would be awesome if it could match the dwyl/learn-elixir in terms of getting setup, basic syntax and examples.
I wouldn't be opposed to adopting Rust for a specific performance/safety-focussed element in the stack.
For that we could either run it as a Erlang NIF function e.g: https://github.com/rusterlium/rustler or an independent "microservice" e.g. on AWS Lambda or Fly.io 💭

Todo

If you want to work on this.

  • Show your interest in learning Rust by commenting below.
  • Start reading the docs/book
  • Create a branch and make notes in the dwyl/learn-rust repo.
@nelsonic nelsonic added enhancement New feature or enhancement of existing functionality question A question needs to be answered before progress can be made on this issue discuss Share your constructive thoughts on how to make progress with this issue technical A technical issue that requires understanding of the code, infrastructure or dependencies epic A feature idea that is large enough to require a whole sprint (5 days) and has smaller sub-issues. research Research required; be specific labels Sep 2, 2022
@nelsonic
Copy link
Member Author

Why Rust is actually good for your car: https://medium.com/volvo-cars-engineering/why-volvo-thinks-you-should-have-rust-in-your-car-4320bd639e09

Volvo using Rust in their infotainment.
Via: https://news.ycombinator.com/item?id=32960768

@nelsonic
Copy link
Member Author

Flutter Rust Bridge: https://github.com/fzyzcjy/flutter_rust_bridge
image

@nelsonic
Copy link
Member Author

nelsonic commented Oct 7, 2022

Web Scraping with Rust: https://github.com/kadekillary/scraping-with-rust 👀
Looks like there are already quite a few useful libraries in this space! 🎉
https://github.com/causal-agent/scraper appears to be maintained. 👌

@nelsonic
Copy link
Member Author

Using Rust with Elixir for code reuse and performance:
https://blog.doctave.com/2021/08/19/using-rust-with-elixir-for-code-reuse-and-performance.html
image

@nelsonic
Copy link
Member Author

Still no built-in/Native Websocket in Rocket? rwf2/Rocket#90 🤷‍♂️

@nelsonic
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss Share your constructive thoughts on how to make progress with this issue enhancement New feature or enhancement of existing functionality epic A feature idea that is large enough to require a whole sprint (5 days) and has smaller sub-issues. question A question needs to be answered before progress can be made on this issue research Research required; be specific technical A technical issue that requires understanding of the code, infrastructure or dependencies
Projects
None yet
Development

No branches or pull requests

1 participant