다음을 통해 공유


Is Javascript code always so full of bugs?

Slightly off topic... The "debugging options" got turned on in my browser recently. I think this happened when I was debugging some web code in Visual Studio.

From this, it's been interesting to see how regularly my web browsing experience is now interrupted by what must surely be outright bugs in Javascript code. Very often these are null object errors. I've always been more than sceptical about Javascript as a language for writing reliable, correct, reusable, efficient code (something F# is obviously good at - and yes, you can compile it to Javascript). But is this kind of bug really the new black? 

Separately, I've noticed an extremely disturbing increase in the number of "this web page is not responding" errors. A good time for those working on automated termination proofs to apply their talents to termination of Javascript code...

What really surprises me is that basic code correctness issues such as programming-without-the-curse-of-nulls do not seem to feature on the minds of those on the Lang.NEXT panel. I guess that when your language doesn't control nulls, you don't think its a problem.

Don

Comments

  • Anonymous
    April 11, 2012
    I agree with this problem

  • Anonymous
    April 11, 2012
    The comment has been removed

  • Anonymous
    April 12, 2012
    Is it really a surprise that web developers tend to write less robust code? I don't think Javascript is to blame here.. [ Don says: Sorry, I really don't agree with that.... nearly all of the errors shown above are basic things that would be prevented in a strongly-typed language (missing identifiers, undefined variables), or null errors that would have likely been prevented in a language such as F# that greatly restricts the use of null values ]

  • Anonymous
    April 13, 2012
    Maybe the language could help more than it does (I'm a HUGE fan of F#, don't get me wrong), but when any language is targeted almost exclusively at unskilled developers, poor code is bound to be the result. Would that same unskilled demographic endure the 'tedium' of fixing compiler errors in a strongly, statically-typed language? Personally, I suspect they would instead just jump ship to an 'easier' language (why do you think PHP is so popular?).

  • Anonymous
    April 15, 2012
    A language which didn´t works correct in all browsers isn´t a language. That´s the problem. Point

  • Anonymous
    April 17, 2012
    I challenged readers to do this same experiment a few years back for the same reason www.damonpayne.com/.../Return-of-the-Smart-Client.aspx . Of course, my predictions may not have turned out so well...

  • Anonymous
    April 17, 2012
    I saw this so often that I just shut off the display of those JS errors.  I can't believe all those coders could be that sloppy so I figured it was because of different conformance to the JS "standard" by various browsers.

  • Anonymous
    April 17, 2012
    Don, can you post more on the errors please? This dialogs are not very detailed and could be misleading. I.E console undefined is standard is Safari,Chrome,Opera and Firefox. $ undefined is likely jQuery, prototype or so other framework. Thank you.

  • Anonymous
    April 17, 2012
    I think that's ildjarn's point.  Web developer languages like javascript have taken off because they are so "fast" and "easy" to work with.  A better language stops a lot of these bugs in their tracks by forcing you to deal with the possibilities -- which is "harder" and "less efficient".  It's like the old VB -- getting an app that appears to work was a lot easier than other languages at the time; getting an app that worked reliably was at least as hard, if not harder.

  • Anonymous
    April 17, 2012
    Don, the authors of the code are to blame. Yes, a statically typed language would expose the error(s), but so does "use strict";. [ Don says: I doubt "use strict" would have fixed the errors above. And not the null-reference errors, of course. ]

  • Anonymous
    April 18, 2012
    Don, I agree with you. I think it's perfectly understandable to have a language like javascript for unskilled, non-professional developers to use. But why punish professional developers who are willing to write good code by not providing a strong typed language as an alternative standard... I just don't understand. Personally, I love F# and Silverlight!!!