News for hackers. Stuff that matters.
Re:The JavaScript Problem by Peaker on Sunday April 27, 2014 @01:53AM (#7654132)
IMO the biggest problem, even worse than type coercions, is the error silencing regarding wrong argument counts.

This can easily hide so many bugs, it's amazing it is acceptable to anyone.

Re:The JavaScript Problem by briantakita on Sunday April 27, 2014 @11:57PM (#7658159)
In practice, this issue is rarely (like 1-2 times a year) encountered. And then functional tests catch the error. It would not be acceptable if it was a constant thorn.
Re:The JavaScript Problem by Kiro on Sunday April 27, 2014 @04:51AM (#7654421)
Do you have an example?
Re:The JavaScript Problem by Peaker on Sunday April 27, 2014 @05:56AM (#7654535)
Call a function "foo" that expects 3 arguments with 5 or 2 arguments, instead.

Javascript will gladly accept that and not yield any error, not just at compile-time, but even at run-time!

Unless the function explicitly checks that the argument list is correct, it will simply hide the bug.

When changing function signatures in any language, it is the programmers' collective responsibility to fix all callers (some of which in the same working tree, some hidden in others' branches, etc). In a static-language, it is very easy, you get compile-time errors at some point. In dynamically typed languages, it is slightly harder -- you get an error (ideally under a test suite) and fix it there. In Javascript you get cryptic bugs. No compile-time error. No run-time error. Happy debugging!

Re:The JavaScript Problem by LunaSea on Sunday April 27, 2014 @07:54AM (#7654772)
How is that an issue ?
Re:The JavaScript Problem by Peaker on Sunday April 27, 2014 @12:29PM (#7655688)
How is a common change (updating a function signature) easily causing cryptic bugs rather than a visible compile-time or run-time error an issue?

Bugs are bad?

Re:The JavaScript Problem by implicit on Sunday April 27, 2014 @11:09AM (#7655350)
Guess the result of this fragment:

    ["1", "2", "3"].map(parseInt)
Re:The JavaScript Problem by Kiro on Monday April 28, 2014 @12:49PM (#7661126)
Ok, that's crazy.

Here's the explanation for anyone interested:

http://stackoverflow.com/questions/14528397/strange-behavior...