6 ms·
Maybe you're looking for D? :) Anyway, what is "not simple" about Rust's syntax?
by floatboth 7y ago
Maybe you're looking for D? :)
Anyway, what is "not simple" about Rust's syntax?
- jokoon 7y agoUsing "let thing: type" seems bloated, I prefer the C style "type thing;" ; can also make a lot of difference, which is a little weird. I don't understand why there is both str and String, seems complicated for nothing. Option things are not really clear yet, and I don't understand what is their use, it seems like an alternative to unions, but few developers use unions anyway... Pattern matching seems powerful but I fail to understand its usage, and I'm a little skeptical about the machine code it generates. D is fine, but I think that even D is not simple enough. Rust seems like it's awesome, but it requires to entirely rethink how you write code, and I've never been a fan of high level abstraction.
- floatboth 7y agoMost of the time, just `let thing`. Let (ha) type inference do its thing. Explicit type annotations are for when it fails. `String` is roughly a Java `StringBuffer`, `&str` is roughly a C++ `string_view`. Yes, you need to rethink how you write code. Rust relies a lot on the basics of typed functional programming. Reading a Haskell tutorial up until the M word would help a lot. But surely there's a lot of good guides written for Rust specifically. tl;dr the core concept you're looking for is sum types, aka discriminated/tagged unions. If you're going "up" from C level abstraction, imagine a C union starting with an enum that indicates which value is there. That's essentially what it is at the memory level (modulo optimizations). But conceptually, you just have a "this OR that" type. Pattern matching is how you access values of that kind of type. https://doc.rust-lang.org/book/ch06-01-defining-an-enum.html https://doc.rust-lang.org/book/ch06-01-defining-an-enum.html