40 points · by tempodox · 4y ago · 23 comments
But I'm just going to add my personal observation as a lifelong embedded C developer: I hate the Rust language syntax.
I'm not sure what it is but just trying to grok Rust code grinds my cognitive gears. I'm sure it all serves a purpose and I'm just a cranky old dude that will be left beind someday but, jesus, it just doesn't flow for me.
I think since it's close to C, my mind wants to read it like C. It's a problem with my brains prefetcher.
Also, finding ` on a non-US keyboard is a pain. Not really related to embedded, but I just had to get it off my chest
(Exception: Rust's syntax for closures is terrible and I don't know anyone who defends it.)
For starters, the reference/borrow checking stuff is opaque. The tick is a lousy visual choice of operator as is 'mut'. The idea that some statements need semicolon terminators while others do not? I don't even want to explore what that's about.
Admittingly Rust solves a harder problem. But I think a huge part of this is also Go language and libraries being very well designed, which Rust could learn a few things from.
Anyway, why did I mention all that? Because Rust makes me feel "well maybe im too stupid to get it" all the time, and now I have realised that a large portion of that is due to ba design choices made by the Rust team and not my own stupidity.
1) Really short keywords and basic type names - pub, mut, fn, impl, i8/i16/i32, etc. They're not hard to understand on their own, but in practice they make the language visually choppy.
2) Maybe it's because I learned Kotlin and Typescript shortly before taking on Rust, but "->" feels inconsistent with the rest of the language. It should be a colon.
3) Rust's if statements follow the normal "if <condition> { <result> }" syntax. Yet, for some reason, each branch of a match statement goes "<condition> => <result>." What would have been wrong with "case <condition> { <result> }"? I know it's more characters, but putting a keyword at the beginning of the block would help to visually separate each branch.
4) Rust's closure syntax looks strange (and I've used Ruby before). Maybe that's just me, though.
Rust isn't perfect, but I don't want to discourage other embedded C programmers from giving it an honest shot. The embedded library support isn't really there yet, but the language itself is a huge upgrade over C and C++.
(edit: I, for one, like the 'lifetimes.)
The rustc_codegen_gcc project aims to solve the backend-availability problem.
I saw something I didn't understand and wanted to understand better. Not much more to it.
It reads like a diff, and is very effective, I'd say, for any programmer.