FAQ

Why Use The Rust Package Even If I Don't Know Rust Language?


From a language perspective we believe Dart is sadly lacking in a few areas, of which this package solves:

  • Dart utilizes unchecked try/catch exceptions. Handling errors as values is preferred for maintainability, thus the Result type.
  • Dart has nullable types but you cannot do null or non-null specific operations without a bunch of if statements and bugs may be introduced due to T?? not being possible. Option<T> fixes this with no runtime cost and you can easily switch back and forth.
  • Dart is missing the functionality of Rust's early return operator (?) operator, so we implemented it in Dart.
  • Dart is missing a built in Cell type or equivalent (and OnceCell/LazyCell).
  • Dart's List type is an array/vector union (it's growable or non-growable). This is not viewable at the type layer, which may lead to runtime exceptions and encourages using growable Lists everywhere even when you do not need to, which is less performant. So we added Arr (array).
  • Dart has no concept of a slice type, so allocating sub-lists is the only method, which is not that efficient. So we added Slice<T>.
  • Dart's between isolate communication is by ports (ReceivePort/SendPort), which is untyped and horrible, we standardized this with introducing channel for typed bi-directional isolate communication.
  • Dart's iteration methods are lacking for Iterable and Iterator (there are none! just moveNext() and current), while Rust has an abundance of useful methods. So we introduced Rust's Iterator as Iter.
  • Dart does not have built in path manipulation. So, we added Path, a zero cost extension type of String for path manipulation.
  • Dart's File/Directory/Link abstraction was the wrong choice and prone to exceptions. We believe Fs and Path are a stronger and safer alternative.
  • No built in cross-platform environment introspect - Platform does not work on web. So we added Env which is cross-platform.

I Know Rust, Can This Package Benefit My Team and I?


Absolutely! In fact, our team both programs in and love Dart and Rust. From a team and user perspective, having one common api across two different languages greatly increases our development velocity in a few ways:

  • Context switching is minimized, the api's across the two languages are the same.
  • Shrinking the knowledge gap between Rust and Dart developers.