152
feroza
6y

“Any application that can be written in JavaScript, will eventually be written in JavaScript.” — Jeff Atwood

Fast-forward 20 years, a plane crashes, they find and open the black box and in the flight logs they can see the cause clearly: ”undefined is not a function”.

Comments
  • 16
    I doubt that JS (and PHP) hackers even know what DO-178 is. Failing to fulfill that means you won't get the software on an aircraft in the first place. :-)
  • 7
    @Fast-Nop you made me go check. Now i know, thanks :)
  • 3
    Also, you have languages like PureScript that compile to an airtight, reasonable subset of JavaScript, those are very, very stable.
  • 6
    @RememberMe The main issue is that JS is usually executed in some interpreter (e.g. a browser) on top of an OS like Linux. You'll never get any of them certified for critical things because already DO-178 level C software requires code coverage and manual explanation for lines not covered. This is not feasible for the millions LOC for the Linux kernel alone. Any update requires the whole thing again.

    That leaves level D and E software, which is for systems where there is either no impact at all or just a minor inconvenience. So, harmless stuff like inflight entertainment, or ground service maintenance racks.
  • 3
    @Fast-Nop agreed, but the massive complexity of JavaScript engines is because of the extremely aggressive performance optimisations they have to do, right, and because of how free JS is as a language.

    So theoretically, if you use a restricted, well-formed, and sane subset of JavaScript (like asm.js), a JavaScript engine that doesn't aggressively go for performance and goes for soft (or hard) realtime and is checkable via formal proof, and runs on something like Integrity or VxWorks, then it could be done, right?

    I don't know enough about JS to say whether it's even possible to make it hard realtime, but I'm assuming that as long as you remove its traditional web dependencies, it's possible.

    (It would be absolutely pointless, but eh.)
  • 0
  • 0
    It's not wise to use JavaScript in such critical task where lives depends on its functioning.
    Let's just keep it simple
    JavaScript for web application **only** no matter what everyone thinks.
  • 0
    Love so much language like Rust (currently learning it, looks so cool and fun to program with) and Swift that replaced all those null and undefined things with an enum that has to be unwrapped before being used

    Rust example:

    let g = Some(3)
    let a = 2 + match g {
    Some(int) => int,
    None => 0,
    };

    //a is equal to 5, but if g was None, it wouldn’t crash

    //can be compacted with other methods, but that’s the most basic way to handle it
  • 0
    @RememberMe There’s also WebAssembly, which is quite interesting for performance wise tasks like games, + the fact it’s not limited to web so that it could become a Java-like bytecode which is readable and available to a lot of systems
  • 1
    @-vim- in js you could write
    let a = 3 + g || 0;
    and it would not crash either
  • 0
    @AdrianD But is it safe? No. You want a programming language that will generate the less errors possible.
  • 1
    @-vim- how is it not safe? What could go wrong? (I know I am asking for it XD)
  • 1
    @AdrianD Because in Rust, you can try to compile something with None and handle it as normal, it won’t work. It forces you to solve common errors, and removes the need to check if a value is None.
Add Comment