From 7a2ffda266c265ec7080de7d0288ef2d2b719926 Mon Sep 17 00:00:00 2001 From: Marko Zagar Date: Thu, 12 Jan 2023 18:50:46 +0100 Subject: [PATCH] Mention ADT and zero-cost abstractions among modern features --- src/why-rust/modern.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/why-rust/modern.md b/src/why-rust/modern.md index 2ed58096..85375e6c 100644 --- a/src/why-rust/modern.md +++ b/src/why-rust/modern.md @@ -7,6 +7,7 @@ Rust is built with all the experience gained in the last 40 years. * Enums and pattern matching. * Generics. * No overhead FFI. +* Zero-cost abstractions. ## Tooling @@ -18,6 +19,15 @@ Rust is built with all the experience gained in the last 40 years. Key points: +* Zero-cost abstractions, similar to C++, means that you don't have to 'pay' + for higher-level programming constructs with memory or CPU. For example, + writing a loop using `for` should result in roughly the same low level + instructions as using the `.iter().fold()` construct. + +* It may be worth mentioning that Rust enums are 'Algebraic Data Types', also + known as 'sum types', which allow the type system to express things like + `Option` and `Result`. + * Remind people to read the errors --- many developers have gotten used to ignore lengthly compiler output. The Rust compiler is significantly more talkative than other compilers. It will often provide you with _actionable_