4 ms·
This seems like a nice guide and I'll certainly peruse it further. But I'm just going to add my personal observation as a lifelong embedded C developer: I hate
by joezydeco 5y ago
This seems like a nice guide and I'll certainly peruse it further.
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.
- TheMerovingian 5y agoYou're not the only one. Been coding for 15 years in C and I had an easier time getting into Python, Assembly, Java, and Go. There is something about Rust that just seems harder than it should be. I think since it's close to C, my mind wants to read it like C. It's a problem with my brains prefetcher.
- zibzab 5y agoI feel with all the special compiler directives needed to get Rust working on embedded it is starting to look like APL. 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
- melissalobos 5y agoI don't mind the syntax, the bigger issue for me is that a lot of necessary features have been locked into nightly forever, like inline asm. If the language can ever mature enough to have these features in stable I would use it in a heartbeat. Well, that and the usual issue with it having a severely limited back-end selection compared with gcc.
- joezydeco 5y agoMy secondary peeve is that Rust is still evolving. I get that all languages do this at some velocity, C++ being one of them, but the fact this 'safe' language is adding 'unsafe' feedbags on the spec just gives me an uneasy feeling about the ecosystem.
- ameliaquining 5y agoGood news! Inline assembly will be available in stable starting next month. In fact, it's available in beta (which is a lot less bleeding-edge than nightly, with a lot fewer bugs) right now. The rustc_codegen_gcc project aims to solve the backend-availability problem.
- steveklabnik 5y agomost of inline asm is being made available, but not all. My embedded project still needs stuff that's not stable yet. Still extremely excited that it's shipping.
- ameliaquining 5y agoI've heard this from quite a few people, and I believe that it's an experience they're having, but I'm having a hard time understanding it. If you could try to give some impression of what you find difficult and how, even it's subjective or fuzzy, I'd appreciate it as a way to get a better understanding. (Exception: Rust's syntax for closures is terrible and I don't know anyone who defends it.)
- steveklabnik 5y agoRust's syntax for closures is extremely close to Ruby's; the only bad thing about it is that it's extremely close but not identical, hahah. (Only said half seriously. I think the syntax is fine, and possibly the best syntax possible, but understand others may not agree and that's fine.)
- ameliaquining 5y agoOkay, I suppose it has any defenders. I still don't like how || can be either logical-or or the parameters of a nullary closure, especially with move closures since "move" looks like an identifier. Personally, I would have gone with Java's or JavaScript's syntax.
- joezydeco 5y agoI'm not going to get into nitpicking because then it becomes a chain of "well maybe you're too stupid to get it", which I probably am but considering you're hearing from a few people then maybe there's something else going on. 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.
- zibzab 5y agoI started learning Go and Rust simultaneously. With Go I was up and running in a week, had real non-trivial projects done in a few months. With Rust it took many months to get started and im still not very productive. 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.
- klyrs 5y agoI'm with you here. Relatedly, I'm a big fan of zig the language, but... zig the grammar is kinda ugly. I'll probably get used to it, though.
- ryukoposting 5y agoAs a cranky (but not old) embedded C developer, I'm with you. Rust has a lot of great ideas, and it's a hell of a lot more readable than modern C++, but it's still like reading hieroglyphics sometimes. 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.)