Bob Ippolito (@etrepum) on Haskell, Python, Erlang, JavaScript, etc.

JavaScript Sucks (volume 2)


JavaScript sucks (1-14 here):

  1. Functions can't be used as a prototype, and you can't do new Function(anotherFunction), so you can't "clone" a function unless you reliably have access to its source code(!!).
  2. While accessing the source code to a function is possible, accessing the scope it was defined in is not. So, you still can't "clone" a function reliably.
  3. All JavaScript implementations are broken. Some more broken than others (*cough*JScript*cough*). They're all broken in different ways.
  4. When you run into a broken JScript.. er JavaScript... interpreter, it will either crash, or behave in a completely unexpected way. Good luck debugging either.
  5. There's no import statement. Good luck writing re-usable code. There are workarounds (e.g. XMLHttpRequest + eval, document.write("..."), etc.), but all are pretty hackish and don't work everywhere all the time or don't get cached by all browsers.
  6. It's terribly hard to find something that tokenizes JavaScript correctly. Hell, most JavaScript interpreters don't even get that far.
  7. No coroutines, continuations, generators, threads (please don't!), or equivalent. That means implementing iterators, cooperative multitasking, or anything else asynchronous is only slightly more fun than a good caning.
  8. Despite its terrible facilities for doing so, writing asynchronous code is necessary. JavaScript interpreters nearly always have the capability to block a browser, sometimes indefinitely.
  9. When they can't block a browser indefinitely, the user gets a stupid "Do you want to terminate this script?" modal dialog. Regardless of the user's choice, they probably have to terminate the process anyway.
  10. alert() is a modal dialog, which means that if the script invokes it repeatedly fast enough, you have to terminate your browser's process. Of course, there really isn't a better way to get debugging output.
  11. JavaScript's caretakers don't seem to be interested fixing any of its problems, just adding new ones. Optional type declarations, classes and interfaces, inline XML, etc. Whee!