137 points · by jamesmunns · 10y ago · 43 comments
But before i explain my reasoning, i will the define the term 'embedded development' for this comment as follows: - No gigahertz (not even close). - No multi core. - No giga- and no megabytes of RAM. - No OS. - Micro second respond time, but truck loads of computation. - No ARM processors.
So here goes.
1.In my world memory safety is simply not an issue, because we don't allocate dynamically. So neither the borrow checker nor lifetimes are an advantage.
2.The micro controllers are piloting a complex machine with all kinds of actuators and sensors. So the code is actually (and that is really a rough generalization) a big state machine. So the functional elements of Rust don't help that much because, although functional programming and state machines are doable, the code is IMO far from ..... let's say elegant.
3.If you do real time systems with micro second respond times (like i do), you really want to know what kind of code will be generated from a specific line of code just by looking at it. Maybe experienced Rust developers are able to do that, input would be appreciated here (looking at you Steve ;-).
4.I'v read about the guaranties the Rust developers give regarding stability of features, breaking changes etc. This combined with the (at least in this domain) neck breaking speed of development (i see the Rust community already talking about optional GC) is pretty much a show stopper in this domain. Why? Because (warning generalization coming) most embedded developers are already dealing with really hard problems, they simply don't have the time to keep up. Furthermore, if you have code that needs to be not only compilable, but also functionally working after twenty years (yes you read that right), you do not want things developing that fast. Remember, this kind of code is keeping all the infrastructure we all rely on working.
5.Rust is a complex language to build a compiler for. You will have to persuade Keil and friends to invest the time and money to do that. And no, LLVM is no option, because it does not target enough architectures.
6.Rust is perceived as too complex by my peers. Don't say it is easy. It is may be easy for you or me, but not for everyone. And you know, those people are valuable too and need a job too.
So there you have it. Rust just does not buy you enough in that kind of environment.
so sorry
Ever since Rust was announced, I've been eagerly awaiting it's practicability as a replacement for C/C++. The only place you really have to use either of those these days is embedded systems, so this is kind of the final step towards getting modern languages in every subfield of software development.
Disagree. It's nice enough as an Arduino-alike, but it doesn't have any debugging capabilities -- the only commands exposed by the loader[1] are "write block" and "reboot".
As an ARM development board, I'm much more a fan of ST's Discovery series[2]. Most of their boards are in the $10-$20 range, and they all include a USB-based programmer/debugger compatible with open-source tools.
Unless you are doing it for work, there are alternatives although not as safe as Rust.
Rust makes you come to grips immediately with the things that will bite you in C later.
Keep at it. It's a continuing process regardless of language.
C is more like chess: the rules are not that complicated and you can figure out how to write code. It will be a long time to learn to write good C code.
With Rust it is hard to figure out the rules, even to get start writing code. They are more like complicated board games with lots of rules to learn.
As an aside, after I wrote that it reminded me of this map: http://goldns.ru/cppmap-2012.png C++ devs will get all the inside jokes there, Alexandrescu's castle, curiously recurring template, exceptional swamps and others...
My biggest struggle so far is overcoming the differences in the implementation of generics. I have yet to "fight the borrow checker," but the generics implementation is something of a hurtle for me.
I've only scratched the surface of the language and I can agree that it's not simple.
I've gotten lots of help from #rust on IRC and places like /r/rust. https://users.rust-lang.org might be good too, but I've only lurked there.
But yeah, beyond that, we love helping new people: my sibling commenter already gave you all the good links :)
C is an easier language to learn that Rust because it's simpler. That is deceptive though - you may understand the language, but it takes years to understand how to use it properly and safely. Rust has a bit of a learning hurdle at the start, but once you understand the language it's much clearer how to use it effectively and safely.
(C++ is the worst of both worlds)
That said, some concepts hit you in the face right away, making the language have an initially steep learning curve, but after that it becomes much easier.
http://www.ptc.com/developer-tools/perc
https://www.aicas.com/cms/en/JamaicaVM
http://www-03.ibm.com/software/products/en/real-time
The problem with D's garbage collector is that it just a very old implementation, with performance problems and they lack contributions to improve it.
Those won't run on an ARM Cortex M chip, where your current options are effectively ASM, Ada, or C if you want high performance and low price and power consumption.