6 ms·
My thoughts Probably will work with a specific compiler. If it fails it'll likely fall on it's face fail. Which with embedded is the best type of failure. Als
by Gibbon1 9y ago
My thoughts
Probably will work with a specific compiler. If it fails it'll likely fall on it's face fail. Which with embedded is the best type of failure.
Also you probably can force the behavior you need with pragma's (not portable)
Portability is usually completely unimportant in embedded.
C89 just don't.
C++ in embedded. Lord god no, if you want to do that use rust instead. Or embedded python or lua, anything but C++.
- pjmlp 9y ago> C++ in embedded. Lord god no, if you want to do that use rust instead. Or embedded python or lua, anything but C++. First Rust needs to reach C++'s tooling maturity on embedded space. When there is High Integrity Rust certification, compiler backends for all major CPUs, SDK support on OSes like INTEGRITY or Mbed, UI embedded tooling for IoT displays, maybe we can start seeing production code there.
- Gibbon1 9y ago> First Rust needs to reach C++'s tooling maturity on embedded space. Yeah and that's soon. Anyone starting an embedded project in C++ is making a grave mistake. > Mbed Those guys make a bad mistake and will pay for it.
- pjmlp 9y agoTouching C is an even bigger one. It took C++ about 20 years to reach maturity in this space, with help of several OS and compiler vendors. You might be willing to bet the house on Rust, most business aren't, not in the current state of its toolchain. In 10 years from now, yeah I can clearly see it.
- v_lisivka 9y agoI use Rust for embedded right now. Part of project is in C, part is in C++, part is in Rust. NRF52 and i.MX6. Can you point me to the problem with Rust or toolchain, which I missed, so I will be aware? Thank you in advance.
- pjmlp 9y agoSome ideas: - LLVM backend is limited regarding the supported CPU architectures; - Rust compiler is not certified for high integrity domains, where human lives might be endangered; - Features like SIMD are still nightly - Lack of integration with closed source toolchains from OEMs for mixed debugging and other development workflows, e.g. Keil, Microchip These issues might be complete irrelevant, or showstoppers, depending on the company.
- steveklabnik 9y agoSIMD is stable in five weeks, incidentally.
- pjmlp 9y agoFrom what I understood it is just phase I from SIMD support, right?
- steveklabnik 9y agoYes, but also the most foundational part. There’s already high level libraries written on top.
- pjmlp 9y agoThanks, will have a look into it.
- steveklabnik 9y agoSpecifically what I'm referring to is https://doc.rust-lang.org/beta/std/arch/ https://doc.rust-lang.org/beta/std/arch/ (last two modules are stable, note this is beta docs for the next release) Next step is https://doc.rust-lang.org/beta/std/simd/index.html https://doc.rust-lang.org/beta/std/simd/index.html but you can use https://crates.io/crates/stdsimd https://crates.io/crates/stdsimd in the meantime to try it out, as they're the same. Stuff like https://crates.io/crates/faster https://crates.io/crates/faster is already built on top of this and is just waiting for the initial intrinsic stabilization, too.
- Gibbon1 9y agoC++ would have died except for three things, Java, the JRA and the web/Javascript. Java is a partial replacement for C++ that isn't quite good enough for desk top applications. Hence C++ is still alive in that space. The JRE was a anvil that language grabbed a hold of, which set them back about 10 years. because every language that depends on the JRE also suffers it's limitations. And the web diverted resources away from native programming for 20 years. However in the last 5-10 years we've seen a couple of well designed native compiled languages being developed. And those are going to replace C++. And LLVM project and work done on KIT compilers provides a strong alternative to the JRE for language development. Seriously, go is better than C++ now. And Rust is very rapidly getting there.
- pjmlp 9y agoWhen Java came into the scene, it was still a bit of a pain to write portable C++ code with the compilers catching up with the ongoing standard and indeed Java was a bit of fresh air in that regard. However, C++ was going strong in all relevant desktop environments, OS/2, Windows and Mac OS. Even on commercial UNIX systems everyone was jumping into CORBA as the next big thing, and I surely wouldn't ever bothered to touch CORBA with plain C stubs. Java had a lost opportunity with Sun being religiously against AOT compilation, an option only available via commercial JDKs, mostly for embedded deployment. Graal and SubstrateVM are changing that, but it will still take a couple of years to actually change everything. Project Metropolis calls the Java on Java plan, the next 20 years. Not only are those web browsers written in C++, throughout those 20 years C++ has been present on web pages via plugins and now WebAssembly. We cannot have LLVM and kill C++ as well, unless you are planning to rewrite into something else. Go is a better C, but definitely not something worthwhile against C++. Using Git urls as package names and writing generic code as if using Borland C++ 2.0 for MS-DOS with BIDS pre-processor macros is definitely not something enjoyable. Rust is improving at a good pace, but until it cuts its dependency on LLVM it will always depend on C++ tooling. Love the language, but suggesting that it is at the same tooling level as C++ to business using it for the last 20 years is just irresponsible. There are lots of domains, even on embedded where Rust eco-system just isn't there nor does it seamlessly integrate with existing workflows. Using a programming language is much more than just installing a command line compiler and hacking away on a text editor. It took C++ almost 20 year to replace C in many high performance domains, and for better or worse, it is mostly copy-paste compatible with C89. Any language that wants its place needs to account for similar uphill battle in all domains.
- InitialLastName 9y agoCuriosity: What's the issue with Mbed? I've toyed with it; it seems nice enough, and is good for getting working code close to the metal without much development time. I'm very interested in what pitfalls come from using it.
- stinos 9y agoC++ in embedded. Lord god no Note so sure, maybe depends on what 'embedded' exactly means to you. I mean, years ago I was working on some TI C6x series DSPs and needed a circular buffer. Hadn't one in C, did have a templated one in C++. Didn't think twice: if the compiler would swallow it, and it did, why would I go through the hassle of doing the work again in C possibly beeding different implementations for different type or a bunch of rather ugly void* stuff? Everything worked out. So for that particual case, C++ in embedded, god yes, as it meant: less development time, reuse existing implementation both for float and int types, etc. And that's +10 years ago so I'd imagine there's now more compilers which would do it.