TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: Languages for safety-critical embedded work?

14 点作者 randomacct44大约 9 年前
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 条评论

danielvf大约 9 年前
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 未加载
burfog大约 9 年前
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.
atomical大约 9 年前
<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>
viraptor大约 9 年前
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 未加载
Tomte大约 9 年前
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_bullington大约 9 年前
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>
kognate大约 9 年前
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.
probinso大约 9 年前
+10 points for Ada. Great language. Barnes book is a great resources
samfisher83大约 9 年前
I work on industrial control and we typically just use C.
technion大约 9 年前
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 未加载
superboum大约 9 年前
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.
spraak大约 9 年前
Really out of my realm but maybe Rust?
评论 #11703514 未加载
jotux大约 9 年前
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>