News for hackers. Stuff that matters.
Re:Anders Hejlsberg: You Can't Maintain Large Programs in Ja... by riffraff on Monday June 04, 2012 @06:11PM (#4066222)
I think there is a bit of an issue with _the code you don't write_ , because you rely on third parties.

Today, I spent five minutes tracking down a

    SyntaxError: Unexpected token u
It was honestly hard to read this as "don't give an un-itialized value to this function or it will end up being passed to JSON.parse that will happily treat undefined as a string".

I'd take a NullPointerException with a proper stacktrace everyday.

Re:Anders Hejlsberg: You Can't Maintain Large Programs in Ja... by ZenPsycho on Monday June 04, 2012 @09:34PM (#4066895)
in chrome, error objects have stack traces attached. All you would have needed to do is wrap the problem code in a try/catch, catch the error, and print out the stack trace, assuming you can't figure out how to find the stack trace just using chrome's web debugger. https://code.google.com/p/v8/wiki/JavaScriptStackTraceApi
Re:Anders Hejlsberg: You Can't Maintain Large Programs in Ja... by riffraff on Tuesday June 05, 2012 @04:58AM (#4067960)
You are missing my point, the issue is not that the error does not have a stacktrace, it's that it looks like:

    SyntaxError: Unexpected token u foo.js:123
    h foo.js:456
    g foo.js:789
    f
The issues are

* no reference to JSON.parse which is where the error occurred

* the error is not "object has no attribute toString", which would have made it clear what it's happening, but something else derived from having silently coerced "undefined" to string, which obscures what is happening.

As I wrote, it was a five minutes thing, not hours, but it's five minutes I would not have spent if it had been:

    TypeError: Cannot read property 'toString' of undefined: [native code]
    JSON.parse [native code]
    h foo.js:456
    g foo.js:789
    f