- pattern matching is quite expressive and ubiquitous in Rust, as in "stuff on the left" is almost always a pattern even in places that you might not expect at first
- lifetime annotations, a form of generics, are quite unique and make the code more verbose/noisy if you are not familiar with them
- Rust is expression based (a bit lispy) so you might not quite see the flow of the program as well if you are used to statement based syntax
- traits are are an important part of the language and some of the methods and method chains you see there might look arbitrary, but many of them are very common. A more experienced reader can identify many of them and see the code very differently.
- there is no syntax highlighting on the article's snippets so you already have to know how to parse them
I think the author wanted to replicate the code as closely as possible, so it's more a case study than an educational piece if that makes sense?
Reason being that you have to unlearn your paradigm before you’re able to learn the new paradigm; and it’s made slightly worse by giving the appearance of similarity (since certain concepts map directly, like flow control and loops).
Once they realize that the tooling is actually working _with_ them, not _against_ them, they start to pick things up much quicker.
Without going much further, to me it's the syntax. I can write some Rust lines of code, and I appreciate the compiler output to correct my syntax. But it's really difficult to me to read code written by others. I can't open a random file of a Rust project and have a minimal clue of what's going on
After years of C and some C++, I have a parser implanted in my cerebellum, and it's hard to adapt it to Rust. To me, reading Rust feels like forcing an optical nerve to see something very small.
Case in point, the code in this article.
That is incredibly hard, yes. But at least if you are ok with the overhead of GC or RC then this is a solved problem - the bug in question here wouldn't happen in Go/Swift/C#/Java/JavaScript/Python/Ruby/etc. And that is most software today.
(But when you need maximal performance and maximal safety then Rust is an incredible option!)
As far as I can tell, that’s normal Rust code, but yes it’s unreadable if you come from C++ or another language and don’t know Rust syntax. The funny thing is that this kind of code is supposed to be the readable part of Rust :-)
I skipped all the code and only read the text. I got to the point where it mentions that the language prevented them from storing a pointer to a stack object in a heap object, and that's really great, but boy oh boy, the code presented, and the error messages, where very difficult for me to grok even after the first few times...
It seems to me that the more sophisticated the safety a language provides is the more complex its error messages/code are. It would be so nice if we could solve both problems at the same time...