"Now is the point I’d like you to say: you should have used CoffeeScript, and hey TameJS while you’re at it. You’d be right." Perfect example of a developer hating JS just because he/she didn't bother to learn it first and got burned.
How One Missing `var` Ruined our Launch
51–60 of 223 posts
Re: How One Missing `var` Ruined our Launch
#52Do I understand this right -- global variables are shared across all requests in node.js? If so, that is an insane design.
In my opinion it wouldn't be quite as scary if js didn't make it so damn simple to accidentally define a global variable (like in this instance, where it was never actually declared in globally-scoped code).
Re: How One Missing `var` Ruined our Launch
#53Do I understand this right -- global variables are shared across all requests in node.js? If so, that is an insane design.
So you just don't use them and everything's good. Which brings you to the real problem: JavaScript makes it distressingly easy to use a global variable where you meant to use a local one.
Re: How One Missing `var` Ruined our Launch
#54Why has it become popular for dynamic languages to conflate establishing a binding with assigning it a new value? Ruby, Python, and Javascript are all guilty of this. Scheme got it right sometime in the 1970's. (let ((x initial-value)) ; binding (set! x new-value)) ; assignment Or in infix syntax (Dylan): let x = initial-value ; x := new-value ;
https://en.wikipedia.org/wiki/ALGOL_58#ALGOL_58.27s_influenc...
Re: How One Missing `var` Ruined our Launch
#55Of course it doesn't prove that your code is bug-free, but if you have concurrency issues, this will help shake them out. I've used this many times to reveal problems with DB connection pooling, concurrency issues, and excessive session size.
Re: How One Missing `var` Ruined our Launch
#56Sorry, that's incorrect. If you cannot fully simulate your environment for purposes of validation, you're not covering your bases.
Re: How One Missing `var` Ruined our Launch
#57This is why I like both Scala and Coffeescript approaches. On Coffeescript vars are created for you, and on Scala, you can't not use it (you either use var or val, making it easy to change from re-assignable variables to final ones). Note that nowadays going to Coffeescript from Javascript is quite easy: http://js2coffee.org/
Re: How One Missing `var` Ruined our Launch
#58Reminds me of one of the more confusing bugs I've ever encountered in my life. I was throwing together a quick UI with Adobe Flex, and for some reason every time you clicked a particular button, the entire UI would shift 20 or so pixels to the right. I spent hours scratching my head until I noticed this for loop: for (x=0;x I wasn't declaring the x variable, so it was using the x part of the x/y positioning of the UI…
It also doesn't happen in languages where you must say self.x to access a property/field called x.
Re: How One Missing `var` Ruined our Launch
#59Am I right in thinking that the javascript /* "use strict" */ construct would have caught this mistake (just like it would have done for me in perl code)? Seems to me that some such feature is absolutely and utterly necessary in any environment where you're doing a lot of closure creation ..
Re: How One Missing `var` Ruined our Launch
#60Why has it become popular for dynamic languages to conflate establishing a binding with assigning it a new value? Ruby, Python, and Javascript are all guilty of this. Scheme got it right sometime in the 1970's. (let ((x initial-value)) ; binding (set! x new-value)) ; assignment Or in infix syntax (Dylan): let x = initial-value ; x := new-value ;