TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Languages for safety-critical embedded work?

14 pointsby randomacct44about 9 years ago
I&#x27;m interested to hear from the HN crowd what&#x27;s out there in terms of languages &#x2F; frameworks for doing safety-critical embedded development on commonly-available hardware like the ESP8266. Think at the safety level of implantable medical devices or flight control software.<p>My usual Google skills aren&#x27;t getting me anywhere on this one :)

13 comments

danielvfabout 9 years ago
1. If you are developing for the ESP8266, your current choices are C, Lua, and Arduino. So you are pretty much using C by default.<p>2. The automotive industry has a standard for safety critical C code. It&#x27;s called MISRA C. A few of the rules are stupid, but others will save you worlds of issues. You have to buy the PDF from the committee&#x27;s website for about 15 bucks, but it&#x27;s worth reading and mostly following.<p>3. If you are actually writing medical or flight control software, you cannot depend on a single proccesor or computer. Perfect software is not enough. Airliners have three separate computers, each containing three different processor architecture processors, each processor running code compiled on a different compiler, and all checking each others work. SpaceX runs at least five separate embedded linux computers for any critical systems. These communicate in such a way that they can tolerate even malicious actions by any two computers. Google &quot;byzantine fault tolarance&quot;
评论 #11704701 未加载
burfogabout 9 years ago
Don&#x27;t overlook the fact that lots of bug-finding tools support plain old C best. Yes yes, it needs them more, but... at least the tools exist!<p>Get all the tools. There are free tools like &quot;sparse&quot;, a tool Linus wrote for his kernel. There are expensive tools like Coverity. Get them all. Use them all.<p>Build your code with all the warnings enabled. Use multiple compilers, even if they don&#x27;t compile for your target.
atomicalabout 9 years ago
<a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;MISRA_C" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;MISRA_C</a>
viraptorabout 9 years ago
Ada is known for those kind of applications. Very restrictive types &#x2F; contracts make it a good choice.<p>Of course a lot of safety critical stuff is still written in C or C++. They may not be perfect, but they&#x27;re not terrible choices.
评论 #11703550 未加载
Tomteabout 9 years ago
Depends on the field. Aeronautics and reactor control seem to use &quot;safer languages&quot; like Ada quite a bit.<p>In factory automation I have only ever seen C, and AFAIK automotive is the same (they seem to be more open to C++, though).<p>Most of safety-critical development (as I know it -- again, no satelites or nuclear stuff) is documentation, testing and FMEAs. Quite a bit of &quot;patterns&quot; or procedures, as well, like memory testing in the background, redundant variables, cross checks between controllers, plausibility checks etc.<p>But very, very little focus on saner programming languages.
eric_bullingtonabout 9 years ago
Ada. I personally lean more and more toward functional languages these days, but despite that, I&#x27;m incredibly impressed with modern Ada. Particularly the Spark subset of Ada, which is perhaps the best-thought out, more coherent, most secure language around for general programming. It&#x27;s the epitome of a well-engineered project, with excellent tooling, and formal verification options to boot. If I had to build something safety critical, I wouldn&#x27;t hesitate to choose Ada.<p>And it looks like some folks have already been using Ada on the ESP8266, here are instructions: <a href="https:&#x2F;&#x2F;github.com&#x2F;RREE&#x2F;esp8266-ada&#x2F;wiki&#x2F;Steps-for-building-on-Linux" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;RREE&#x2F;esp8266-ada&#x2F;wiki&#x2F;Steps-for-building-...</a>
kognateabout 9 years ago
The Power Of 10 is a good place to start.<p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;The_Power_of_10:_Rules_for_Developing_Safety-Critical_Code" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;The_Power_of_10:_Rules_for_Dev...</a><p>The summary would be:<p>Use vanilla C with some rules about things like memory, testing, and recursion. Testing and static analysis are your friends.
probinsoabout 9 years ago
+10 points for Ada. Great language. Barnes book is a great resources
samfisher83about 9 years ago
I work on industrial control and we typically just use C.
technionabout 9 years ago
This is a tangent, but Wikipedia says this about that chip:<p><pre><code> The ESP8266 is a low-cost Wi-Fi chip with full TCP&#x2F;IP stack and microcontroller capability produced by Shanghai-based Chinese manufacturer, Espressif. </code></pre> Am I alone in the concern that in a safety critical environment, the phrase &quot;low cost&quot; should be more of a concern than the choice of language?
评论 #11704715 未加载
superboumabout 9 years ago
If you want to go further, you might be interested by proving your software and formal method, something like the B-Method ; <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;B-Method" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;B-Method</a><p>Unfortunately, I only know their name and never use it.
spraakabout 9 years ago
Really out of my realm but maybe Rust?
评论 #11703514 未加载
jotuxabout 9 years ago
Just do what JPL does: <a href="http:&#x2F;&#x2F;lars-lab.jpl.nasa.gov&#x2F;JPL_Coding_Standard_C.pdf" rel="nofollow">http:&#x2F;&#x2F;lars-lab.jpl.nasa.gov&#x2F;JPL_Coding_Standard_C.pdf</a>