My experience learning Rust
It's both a cool and uncool language for me.
I have been writing Go code for more than a year now, and I still remember the moment I fell in love with Go’s simplicity: The few number of keywords, the built-in standard libraries, errors as values, and don’t get me started on the goroutines. All those things really enlightened me on how a language can be powerful while preserving its simplicity.
And I’m learning Rust lately. I know, that came out of nowhere. Two reasons for it:
I have been super interested in system programming lately. The idea of interacting with lower level systems fascinates me.
I was curious about Rust and the hype surrounding it.
There is some FOMO here and there too, I have to admit. I’m going through the book “Command-Line Rust: A Project-Based Primer for Writing Rust CLIs” and it has been a great reading experience so far. The book focuses on writing common UNIX tools in Rust and the author is very detailed on how things work together (sometimes things get a bit repetitive but that’s okay for me).
Some of the things I really like about Rust:
Rust is so explicit. Go has one thing that I still cannot tolerate: The implicit interface implementation. Let’s say you have an interface like this
type SampleInterface interface {
Method()
}If a struct implements this interface, we would have no idea if it has implement enough method signatures of it until we compile the code. I hate it, especially every time I deal with some interfaces that have a long list of signatures.
Rust uses Trait for interfaces and we have to explicitly declare impl Trait. And other languages have that too! But this blog is not to complain about Go, so I will just stop here.
Rust is such a cool mixed of paradigms. I first learned the term “procedural” when writing C and Go, and “functional” when learning how to write pure-functional JavaScript. What is so nice with Rust is that it brings home a familiar feeling of procedural code while integrating functional concepts so well like higher-order functions, immutability and declarative style.
Rust helps me understand concepts that I had a hard time understanding. Take closure for example, I could not wrap my head around it back then, and I was constantly wondering “What is the closure in this case?” or “What does it enclose over”. The explicit syntax of Rust for closure like
|i: i32| -> i32 { i + outer_var }enlightened me: Oh, so it’s just a function that accepts variables that are not in its scope. I don’t know, but learning about closures while writing Go or C did not help me understand it at all.
Rust is nice so far, but there are some annoying things. I don’t expect it to be the same, given the tales about its performance outpacing Go’s. There must be some verbosity as trade-offs, I assume, for using borrow-checker to manage memory instead of relying on a garbage collector. Here are my two cents:
Familiar things have to have a unfamiliar name. This might be because of my inexperienced-ness with different programming paradigms plus my background intiallly in object-oriented programming, but why is interface has to be renamed to trait? Why do we have to “implement the trait” and not “implement the interface”? I know this does not impact performance or verbosity (Heck might be reducing it even!). This causes some friction during the learning, as I have to map back-and-forth the terms.
Immutable variables. I know, another one due to my inexperienced-ness. Maybe because I was quite familar with the readability of Go that I had a hard time reading through Rust code with
muthere and there (But luckily it’s still much less verbose compared to Java).Chaining methods/functions. I don’t know where Rust get this from, but for me it’s hard to determine a variable’s type when it goes through many chained methods. I have to use type hinting functionality a lot for this and it adds so much noise to the editor, while with other languages the type transformation is just much more explicit.
Still, there are things that I find to be neither nice or annoying. Take vectors for example, like I get it, vectors can shrink or grow just like arrays and that is acceptable, but initally it confuses me a lot with all the vector stuff that we have with complex statistics programming. Sum types, or union types, are very cool too, but having to add unwrappers and checks here and there for either Some or None just discourages me with that kind of verbosity and unpredictability.
It’s hard to say for now if I like this language or not. So far I still think it’s really cool, and I will try to build more things with it :)


