0

I was compiling a list of comparison of top 10 programming languages (JavaScript included). I was doing it from this Wikipedia page.

However, in the third table (Failsafe I/O), there is no row for JavaScript. I find it a bit weird because JavaScript is included in the first two comparisons (General comparison and Type Systems).

So my question is, is JavaScript fail-safe? If Yes, what would the row for JavaScript in the fail-safe I/O table look like?

1
  • 3
    The question should be "does JavaScript have I/O"?
    – Euphoric
    Commented Apr 7, 2015 at 6:52

3 Answers 3

2

Javascript is indeed a fail-safe language, since it also raises exceptions in case of an error (like Java or Python). However, the specific language is not included in this list, because this list refers to fail-safe programming languages taking into account the occasions of errors in I/O operations and system calls. Javascript has been a client-side programming language for various years, so I/O and system calls are were out of scope in this language.

However, with the prevalence of Node JS, which is a server-side implementation of Javascript, I think this language should be included in this list from now on.

4

It depends on what kind of I/O you're after. I think that table is primarily looking at system calls, and the stdin/stdout interface to a console windows or terminal. System calls simply don't exist in Javascript, and there's no stdin/stdout-style console window either, so I assume that's why it's not listed (though you can make a case for node.js here).

The closest thing I know of to failsafe-ness in vanilla Javascript is that calling a function that doesn't exist or accessing a resource that hasn't been loaded will throw an exception. But everything that is available generally "just works" without any error codes or exceptions. Assigning text to innerHTML or using HTML5 canvas methods won't throw if the browser "fails to render" the result somehow (at least, if it does, that's not documented/standardized behavior). Also note that Javascript has no (cross-browser) filesystem API, which is the one thing I can think of where error codes/exceptions would effectively be mandatory. And, Javascript's closest equivalent to console I/O--the console.log() function--also isn't standard, meaning you're never supposed to use it in production code anyway.

So as far as I can tell, the sort of "I/O" where "failsafe" is a meaningful property to ask about doesn't really exist in Javascript. Simply leaving it out of the table probably was the best way to represent it.

2

JavaScript does not have any I/O at all, and thus the question whether or not it is "failsafe" doesn't make sense.

2
  • Isn't XMLHttpRequest IO?
    – svick
    Commented Apr 10, 2015 at 0:57
  • XMLHttpRequest is I/O but it's not part of JavaScript. Commented Apr 10, 2015 at 3:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.