Re: 10 biggest JS pitfalls

2013-01-07 Thread Andrea Giammarchi
Axel, here ... that chapter is really a tiny one and every dev should read that at least once if JS is, by accident, their programming language: http://webreflection.blogspot.com/2010/10/javascript-coercion-demystified.html br On Sun, Jan 6, 2013 at 6:10 PM, Axel Rauschmayer wrote: > Note that

Re: 10 biggest JS pitfalls

2013-01-06 Thread Axel Rauschmayer
> Note that == does not respect truthiness or falsiness: > > > 2 == true > false > > 2 == false > false > > > '2' == true > false > > '2' == false > false > > None of these (above) abstract comparison operations represents "truthy" or > "falsy" behaviour. > > 0

10 biggest JS pitfalls

2013-01-06 Thread Rick Waldron
On Sunday, January 6, 2013, Axel Rauschmayer wrote: > > Exactly Brendan, I could not agree more and this is my No. 1 pitfall > about JS: developers often not doing real work complaining about stuff that > developers doing real work don't even care about or never ever had to worry > about. > > I do

Re: 10 biggest JS pitfalls

2013-01-06 Thread Claude Pache
>> >> On Sun, Jan 6, 2013 at 5:06 AM, Axel Rauschmayer wrote: >>> >>> This is not about pointing out how bad JavaScript is, it is about >>> collecting things that confuse people who are new to the language. They >>> help those people to learn what you already know. Many people really ha

Re: 10 biggest JS pitfalls

2013-01-06 Thread Axel Rauschmayer
[cc-ing es-discuss again] Yes. I like the idea of JS(L|H)int as a teacher for newcomers! On Jan 6, 2013, at 15:52 , Andrea Giammarchi wrote: > I think for your latter point and about haters, JSLint can help there. Put in > this way ... I hate JSLint :D > > > On Sun, Jan 6, 2013 at 5:06 AM,

Re: 10 biggest JS pitfalls

2013-01-06 Thread Andrea Giammarchi
Axel, it wasn't referred to you explicitly, rather to all those developers still wining about this == null problem which has never been in my daily, real work, code. choose one: value === undefined || value === null in a language where undefined and null are different and for a good reason (not d

Re: 10 biggest JS pitfalls

2013-01-06 Thread Axel Rauschmayer
> Exactly Brendan, I could not agree more and this is my No. 1 pitfall about > JS: developers often not doing real work complaining about stuff that > developers doing real work don't even care about or never ever had to worry > about. I don’t follow. Who are these people not doing “real work”?

Re: 10 biggest JS pitfalls

2013-01-05 Thread Benoit Marchant
:-) Well put Andrea. Benoit On Jan 5, 2013, at 22:38, Andrea Giammarchi wrote: > Exactly Brendan, I could not agree more and this is my No. 1 pitfall about > JS: developers often not doing real work complaining about stuff that > developers doing real work don't even care about or never ever

Re: 10 biggest JS pitfalls

2013-01-05 Thread Andrea Giammarchi
Exactly Brendan, I could not agree more and this is my No. 1 pitfall about JS: developers often not doing real work complaining about stuff that developers doing real work don't even care about or never ever had to worry about. In any case they can learn and understand the feature/problem using th

Re: 10 biggest JS pitfalls

2013-01-03 Thread Quildreen Motta
I'm still amazed to see people rant about other people's perfectly fine coding styles, when those are an overtly subjective matter, and therefore no argumentation on whether "Yes ASI" or "Nay ASI" can be right. The only facts about ASI are: 1.) It's a syntax error; 2.) Such syntax error is spec'd

Re: 10 biggest JS pitfalls

2012-12-31 Thread Brendan Eich
Yes, see the thread starting at https://mail.mozilla.org/pipermail/es-discuss/2012-December/027419.html if you haven't. The SpiderMonkey implementation was "first", for what it's worth -- from 1997. ES3 did not specify any function in block production, of course. The intersection with IE semant

Re: 10 biggest JS pitfalls

2012-12-31 Thread Claude Pache
I've just discovered that someone is fallen in the following pit: Change of the semantic of function declarations in Firefox when included in block (spoiler: hoisting issue). (Not standard ES for sure, but definitely JS.) Enjoy: http://statichtml.com/2011/spidermonkey-function-hoisting.html —Clau

Re: 10 biggest JS pitfalls

2012-12-31 Thread Brendan Eich
Jorge Chamorro wrote: On 31/12/2012, at 15:55, Juan Ignacio Dopazo wrote: I'm surprised not to see Automatic Semicolon Insertion in the list. Yes I would ditch ASI altogether if only to force the javascrhipsters to put back each and every semicolon where it belongs: they are *delimiters*.

Re: 10 biggest JS pitfalls

2012-12-31 Thread Brendan Eich
I don't think ASI _per se_ is the problem. Rather, the restricted productions bite people: function foo() { return very + long + expression() + goes + here; } and of course, the expectation of ASI where there's no error to correct: a = b (function () { ... // lots of line

Re: 10 biggest JS pitfalls

2012-12-31 Thread Claude Pache
Le 31 déc. 2012 à 18:58, Axel Rauschmayer a écrit : >> Personally, I have issues with from- and to-String conversions when working >> with HTML form field values and data-* attributes. More precisely, I am >> careful to make these conversions manually, and I regret that JS doesn't >> warn me

Re: 10 biggest JS pitfalls

2012-12-31 Thread Axel Rauschmayer
> Personally, I have issues with from- and to-String conversions when working > with HTML form field values and data-* attributes. More precisely, I am > careful to make these conversions manually, and I regret that JS doesn't warn > me if I forget to do them. Indeed the following cases are prob

Re: 10 biggest JS pitfalls

2012-12-31 Thread Jorge Chamorro
On 31/12/2012, at 15:55, Juan Ignacio Dopazo wrote: > I'm surprised not to see Automatic Semicolon Insertion in the list. Yes I would ditch ASI altogether if only to force the javascrhipsters to put back each and every semicolon where it belongs: they are *delimiters*. No ASI would force them t

Re: 10 biggest JS pitfalls

2012-12-31 Thread Claude Pache
Le 31 déc. 2012 à 10:17, Axel Rauschmayer a écrit : >>> I’d be interested in other examples of implicit conversions stumping people. >> >> What stumped who, when? Any bugs/github issues/blog posts to cite? > > No, I think I agree with your assessment that implicit conversion to boolean > (the

Re: 10 biggest JS pitfalls

2012-12-31 Thread Juan Ignacio Dopazo
I'm surprised not to see Automatic Semicolon Insertion in the list. Juan ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: 10 biggest JS pitfalls

2012-12-31 Thread Axel Rauschmayer
>> I’d be interested in other examples of implicit conversions stumping people. > > What stumped who, when? Any bugs/github issues/blog posts to cite? No, I think I agree with your assessment that implicit conversion to boolean (the most prevalent implicit conversion) is manageable, possibly eve

Re: 10 biggest JS pitfalls

2012-12-30 Thread Brendan Eich
Axel Rauschmayer wrote: JS is functional first, not OOP first. APIs that want methods to be extractable as bound to the object from which they were extracted must do extra work, which can be self-hosted via getters for specific methods, or a general proxy. Again, not sure if that’s feasible,

Re: 10 biggest JS pitfalls

2012-12-30 Thread Brendan Eich
Axel Rauschmayer wrote: - Implicit conversions are messy (and a superset of pitfall #2), but seem to surprise people much less than the above items. I think you have it backwards. My experience, so far. I’d be interested in other examples of implicit conversions stumping people. What stump

Re: 10 biggest JS pitfalls

2012-12-30 Thread Axel Rauschmayer
> You don't mean for-of, you mean for (let i...) in any form. We want all > for-let forms to make fresh let bindings per iteration. That's what your > resolution for (7) should say, and ES6 does indeed aim to do this. Yes, thanks. I thought only for-of did this. >>> We can work around it by cha

Re: 10 biggest JS pitfalls

2012-12-30 Thread Axel Rauschmayer
>> - Implicit conversions are messy (and a superset of pitfall #2), but seem to >> surprise people much less than the above items. > > I think you have it backwards. My experience, so far. I’d be interested in other examples of implicit conversions stumping people. >> - Modules close another i

Re: 10 biggest JS pitfalls

2012-12-30 Thread Brendan Eich
Axel Rauschmayer wrote: You did not include variants of var i, a=[]; for (i=0; i < 10; i++) { a.push(print(i)); } print(a[3]); /* output is 9 */ in your list. I see related bugs on a regular basis. That would be (7). The above should work. The problem only exists with functions (or rathe

Re: 10 biggest JS pitfalls

2012-12-30 Thread Axel Rauschmayer
Yes, tripped me up a few times. Then I remember to use a regular expression with a /g flag as the first argument. I wouldn’t consider it a major pitfall, but it is definitely a pitfall. On Dec 30, 2012, at 23:06 , gaz Heyes wrote: > I'd say String.replace needs to be there: > http://blog.minde

Re: 10 biggest JS pitfalls

2012-12-30 Thread Axel Rauschmayer
seems that strict equals is usually faster. > On 30 December 2012 16:22, Axel Rauschmayer wrote: > [Starting a new thread, just in case.] > >>> I made a list of the 10 biggest JS pitfalls and most of them will be gone >>> under ES6. Much less to worry about, much easi

Re: 10 biggest JS pitfalls

2012-12-30 Thread Brendan Eich
Axel Rauschmayer wrote: 1. Both undefined and null [not too much of a problem, easily learned] 2. Truthy and falsy values [not pretty, but I’ve grown used to them and the convenient but sloppy “has a value” checks via `if`] These are usually winning. Dart makes you be explicit in testing and

Re: 10 biggest JS pitfalls

2012-12-30 Thread Anne van Kesteren
On Sun, Dec 30, 2012 at 10:22 PM, Axel Rauschmayer wrote: > 5. Array-like objects [not completely fixed (DOM...), but `arguments` Specifics welcome, though probably better posted to www-...@w3.org. We've made some effort towards changing some of this, but legacy content is against us. :/ -- ht

Re: 10 biggest JS pitfalls

2012-12-30 Thread Wes Garland
that == is faster than === in at least one implementation, because that's what sunspider tests. On 30 December 2012 16:22, Axel Rauschmayer wrote: > [Starting a new thread, just in case.] > > I made a list of the 10 biggest JS pitfalls and most of them will be gone > under ES6. Mu

Re: 10 biggest JS pitfalls

2012-12-30 Thread gaz Heyes
I'd say String.replace needs to be there: http://blog.mindedsecurity.com/2010/09/twitter-domxss-wrong-fix-and-something.html http://www.thespanner.co.uk/2010/09/27/string-replace-javascript-bad-design/ Also the fact that no built in html encode/decode exists. __

RE: 10 biggest JS pitfalls

2012-12-30 Thread Domenic Denicola
> From: es-discuss-boun...@mozilla.org [mailto:es-discuss-boun...@mozilla.org] > On Behalf Of Axel Rauschmayer > Sent: Sunday, December 30, 2012 16:22 >    9c) using methods as callback functions The single biggest feature on my ES7 wishlist is the bind operator strawman: http://wiki.ecmascript

10 biggest JS pitfalls

2012-12-30 Thread Axel Rauschmayer
[Starting a new thread, just in case.] >> I made a list of the 10 biggest JS pitfalls and most of them will be gone >> under ES6. Much less to worry about, much easier to learn. > > Could you share your 10-biggest list? 1. Both undefined and null [not too much of a problem,