IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New JSLint opinions?
Courtesy of SlashDot, I've been playing with YSlow on the website code I look after. The results were instructive. Then I saw it linked with JSLint. :-O

JSLint's standards strike me as very arrogant. Is there any particular reason why one should insist on braces around if() and while() codeblocks? Or semi-colons after statements (they're technically a statement separator)? It also doesn't like var statements that assign, prefers === over == in a lot of cases (but I don't understand why) and doesn't like ++ and --.

This is the first time I've used any sort of "lint" tool, though, not counting the W3C HTML Validator, so perhaps it's supposed to be uber-anal and the coder needs to understand when to ignore it's complaints. (Grammar checkers work the same way.)

Wade.


Is it enough to love
Is it enough to breathe
Somebody rip my heart out
And leave me here to bleed
 
Is it enough to die
Somebody save my life
I'd rather be Anything but Ordinary
Please



-- "Anything but Ordinary" by Avril Lavigne.

· my ·
· [link|http://staticsan.livejournal.com/|blog] ·
· [link|http://yceran.org/|website] ·

New Depends

Some of the things it complains about are silly. Others will come back to help you later (semicolons after everything are a great help to automated minimizers, for example); play with it a bit and learn what's safe to ignore.

--\r\nYou cooin' with my bird?
New Well, I'm glad someone else thinks it can be semi-ignored.
After all, I fed it code that had been fairly carefully hand-optimized. :)

Wade.


Is it enough to love
Is it enough to breathe
Somebody rip my heart out
And leave me here to bleed
 
Is it enough to die
Somebody save my life
I'd rather be Anything but Ordinary
Please



-- "Anything but Ordinary" by Avril Lavigne.

· my ·
· [link|http://staticsan.livejournal.com/|blog] ·
· [link|http://yceran.org/|website] ·

New Re: Well, I'm glad someone else thinks it can be semi-ignore
How does leaving out braces or semi-colons "carefully hand optimize" Javascript?

If you're worried about code size, just run all of your code through a squeezer before you push it into production.
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New That wasn't what I was referring to.
I can understand it complaining about braces and semi-colons. But it also complains about things like assigning to variable declarations, and for some reason it didn't like multiple clauses in if statements.

Then, too, the optimization wasn't purely for code-size; I was trying to make the code efficient as far as I understand Javascript execution. I certainly don't claim to be a great Javascript programmer, either, in case I mistakenly gave that impression.

Wade.


Is it enough to love
Is it enough to breathe
Somebody rip my heart out
And leave me here to bleed
 
Is it enough to die
Somebody save my life
I'd rather be Anything but Ordinary
Please



-- "Anything but Ordinary" by Avril Lavigne.

· my ·
· [link|http://staticsan.livejournal.com/|blog] ·
· [link|http://yceran.org/|website] ·

New Re: JSLint opinions?
Not using braces and semi-colons are the kinds of things that can bite you later on.

Braces should always be used, even if there is only one line in the if/while block:
1) it sets things off visually, and
2) if you add another line, indent it, and forget to add the braces, you've created a hard to see bug if your eyes are already used to seeing blocks without braces.

Semi-colons, ditto.

Another one that you didn't mention:
if (foo = "one")
vs.
if ("one" = foo)

If you forget the double = in the first one, you've created an always-true assignment. The second one will throw an error and alert you to the problem. I got saved by that habit yesterday.

So YSlow is out finally? Do you have a link? I've been waiting to see it.
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New Debugging and programming styles differ.
[link|http://developer.yahoo.com/yslow|Link for YSlow].

I'm probably being stubborn, but I like the freedom of semi-colons being optional and tend to omit then when I can. Since they're required in widespread languages C, Java, PHP and Perl, I think some people that argue for their use in Javascript may simply be highly unfamiliar with programming without them. But I program in Icon, too, where (like in Javascript) semi-colons are optional for the same reasons and with the same rules. I have not ever had Javascript's semi-colon insertion do something unpredictable, BTW.

Similarly, for braces around single-statement blocks. I look for the indent, anyway, so braces in that case are not a help.

At least JSLint doesn't apply its normal whitespace rules: I much prefer if( a == b ) over if (a == b). JSLint prefers the latter. A colleague in a former workplace thought I was mad, but wasn't going to argue over it. Some weeks later he voluntarily said he decided he liked my method because it was more readable! :-D

The = vs == one has caught me on occassion over the years, in C, PHP and Javascript, though not very often. I like your solution. I might try that.

Wade.


Is it enough to love
Is it enough to breathe
Somebody rip my heart out
And leave me here to bleed
 
Is it enough to die
Somebody save my life
I'd rather be Anything but Ordinary
Please



-- "Anything but Ordinary" by Avril Lavigne.

· my ·
· [link|http://staticsan.livejournal.com/|blog] ·
· [link|http://yceran.org/|website] ·

New Bleah... 'if' is not a function.
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New No, it is a method on Boolean



We posture as apostles of fair play, as good sportsmen, as professional knights-errant-- and we throw beer bottles at the umpire when he refuses to cheat for our side...We save the black-and-tan republics from their native [statesmen]--and flood them with "deserving" democrats of our own. We deafen the world with our whoops for liberty--and submit to laws that destroy our most sacred rights...We play policeman and Sunday-school superintendent to half of Christendom--and lynch a darky every two days in our own backyard.


H.L. Mencken, 1914
New Hey Todd - welcome back!
Always enjoy the duelling er, Certainties of programming logic - plus, natch, the occasional pits of fique, when a fav oxen is gored -- with or without a smashing pile-on melee ;^>

(Sometimes programming seems a lot like a soccer fest :-0 -- 'cept Everyone's a Referee.)




oTpy

Expand Edited by Ashton Aug. 6, 2007, 07:07:09 PM EDT
     JSLint opinions? - (static) - (9)
         Depends - (ubernostrum) - (3)
             Well, I'm glad someone else thinks it can be semi-ignored. - (static) - (2)
                 Re: Well, I'm glad someone else thinks it can be semi-ignore - (admin) - (1)
                     That wasn't what I was referring to. - (static)
         Re: JSLint opinions? - (admin) - (4)
             Debugging and programming styles differ. - (static) - (3)
                 Bleah... 'if' is not a function. -NT - (admin) - (2)
                     No, it is a method on Boolean -NT - (tuberculosis) - (1)
                         Hey Todd - welcome back! - (Ashton)

You keep using that word, but I do not think that it means what you think it does.
62 ms