Live data from Hacker News

I'll sue you if you use my common-sense JavaScript tests

groups.google.com

61–70 of 82 posts

Re: I'll sue you if you use my common-sense JavaScript tests

#61

Earlier quoted context omitted.

What's even more hilarious is the code in his "My Library". I'm far too much of a generalist to consider myself a JavaScript expert. However, even I can pick out a number of items in his lib that shouldn't have been handled the way they are: - He declares $ in a global context without first checking for its existence; - He uses RegExp objects constantly -- in 50 different places in his full "mylib.js" -- including in…

There's a tradeoff between download time and execution speed there, and download time usually wins. I wrote the camelCaser in Google Websearch (basing it off Closure), and I used a simple regexp without memoization. You can burn a lot of cycles in the time it takes to download a hundred bytes over 56.6k, and often a camelCaser is used in situations like an animation loop where speed doesn't matter as long as you come…

I don't really disagree with you, however:

- minifying and gzipping the javascript files is considered standard practice now, and the code I posted as-is is actually shorter than David Marks' case [* I lied! It's not, by 100 chars. Even shortening the object references kept it a bit longer. I don't think this defeats the rest of my points though.]. It could further be shortened, a lot -- to the point that for all practical purposes it's as small as a non-memoizing version.

- I tend to use a camelCaser in much more than simple animation loops -- any time for example that the style attributes for any element are referenced. i.e., it qualifies as an inner-most function.

- Although it's true that in animation loops you just have to beat the frame rate, let's keep in mind that there are a wide variety of processors and systems in use, and not everyone is using the latest dual-core Intel system with 3 gigs of RAM.

As a point of personal style, I much prefer to take the shortest, fastest, least-resource-intensive path for any given task, even if it's not strictly necessary to do so. As an end-user, I'm disgusted beyond description with the mindset that has become so prevalent among programmers, where efficiency is something that should be solved in hardware. It's absolutely frustrating that there are sites where the programmers have made so many concessions to speed in the name of rapid development that I can't even get the site to load in a few seconds on a 1.5 ghz G4.

So, yes, you're right, but I think the bit from David Marks' code is still naive and still does not make best use of the language:

    camelize = function(name) {
      var m = name.match(reCamel);
      return (m)?([m[1], m[2].toUpperCase(), m[3]].join('')):name;
    };

Re: I'll sue you if you use my common-sense JavaScript tests

#62

Earlier quoted context omitted.

There's a tradeoff between download time and execution speed there, and download time usually wins. I wrote the camelCaser in Google Websearch (basing it off Closure), and I used a simple regexp without memoization. You can burn a lot of cycles in the time it takes to download a hundred bytes over 56.6k, and often a camelCaser is used in situations like an animation loop where speed doesn't matter as long as you come…

I don't really disagree with you, however: - minifying and gzipping the javascript files is considered standard practice now, and the code I posted as-is is actually shorter than David Marks' case [* I lied! It's not, by 100 chars. Even shortening the object references kept it a bit longer. I don't think this defeats the rest of my points though.]. It could further be shortened, a lot -- to the point that for all pra…

Actually, I take some of it back!

You had a good point about total size of the code being downloaded, so I went back and tried to see if I could shrink mine a bit without pulling any dirty tricks -- when I realized that a chunk of his code is 'hidden' in the reference to the regular expression object he's created elsewhere.

With that added, and matching my code style to his, my version is less than 20 characters longer than his -- and that's without doing anything sneaky.

But, maybe there just isn't a big difference in speed? So, I set up a quick test. Again, I wanted to be fair, so I could understand what was going on. The two tests are identical, I didn't advantage mine in any way or disadvantage his.

The results?

Given a list of 11 valid CSS properties to "camelize", some with dashes and some without, my code can camelize the set 20 times over in 1 to 2 milliseconds.

The non-memoizing version can camelize the set 20 times over in ... 1034 to 1212 milliseconds.

That's a significant difference, IMO.

Tested on Firefox 3.5/Mac.

...all that said, thanks for reminding me about function size and download speed. I try to keep my own library at under 1000 source lines of code, but there are definitely some areas where I can sacrifice a few lines to lose a chunk of text. (Like, wrapping "typeof object != 'undefined'" into an "undef(object)" function.)

Re: I'll sue you if you use my common-sense JavaScript tests

#63

Earlier quoted context omitted.

I don't really disagree with you, however: - minifying and gzipping the javascript files is considered standard practice now, and the code I posted as-is is actually shorter than David Marks' case [* I lied! It's not, by 100 chars. Even shortening the object references kept it a bit longer. I don't think this defeats the rest of my points though.]. It could further be shortened, a lot -- to the point that for all pra…

Actually, I take some of it back! You had a good point about total size of the code being downloaded, so I went back and tried to see if I could shrink mine a bit without pulling any dirty tricks -- when I realized that a chunk of his code is 'hidden' in the reference to the regular expression object he's created elsewhere. With that added, and matching my code style to his, my version is less than 20 characters long…

You missed the point. Well, several points. My Library was written years ago and the idea was to support "ancient" browsers like Safari 2 as well as all future browsers. As the fairly torturous test page still works in IE8 (all modes), Safari 4 and Chrome it would seem a rousing success. In the meantime, jQuery has been virtually rewritten to get rid of the browser sniffing. Guess where they got the ideas (and figure they botched their implementation).

Yes, memorizing camelized styles would be more efficient, but then the library doesn't deal with hyphenated ones in the first place. It's used in exactly two places and neither has anything to do with styles. Instead, it deals with (very rarely encountered) hyphenated _attributes_ (you should have guessed, or God forbid read the code you were criticizing).

And aren't you just picking one (tiny) bit that you can sort of relate to and mouthing off without any real clue about what you are talking about? And why didn't _you_ report it to the author to be constructive, build a community, etc. What an awful jerk!

BTW, your version will blow up in Safari 2 due to the function passed to replace. Good luck with that!

Re: I'll sue you if you use my common-sense JavaScript tests

#64
post #55

His latest, on a bug report I filed against google closure: http://groups.google.com/group/comp.lang.javascript/browse_t... I'd like to see him write cross browser key-event handling code without doing UA sniffing. Honestly, I would like that. He committed an attempt to a branch of Dojo but it's not in service and doesn't actually work.

And you don't know what you are talking about either. To save time, responses are aggregated here:-

http://groups.google.com/group/comp.lang.javascript/browse_t...

Re: I'll sue you if you use my common-sense JavaScript tests

#65
post #55

His latest, on a bug report I filed against google closure: http://groups.google.com/group/comp.lang.javascript/browse_t... I'd like to see him write cross browser key-event handling code without doing UA sniffing. Honestly, I would like that. He committed an attempt to a branch of Dojo but it's not in service and doesn't actually work.

And you don't know what you are talking about either. To save time, responses are aggregated here:- http://groups.google.com/group/comp.lang.javascript/browse_t...

His response is typical. He denies saying things which can easily be disproved. He makes basic factual errors and in the same sentence validates most of the criticism in this thread:

"Cappuccino. That's something built on top of Sproutcore, right? No need to get any deeper than that."

Of course, Cappuccino isn't built on Sproutcore, but even if it was this sentence illustrates the fact that David has long ago made decisions about what he perceives to be the state of javascript frameworks, and isn't interested in anything other than those opinions, however baseless those opinions may be.

Re: I'll sue you if you use my common-sense JavaScript tests

#66

Earlier quoted context omitted.

Actually, I take some of it back! You had a good point about total size of the code being downloaded, so I went back and tried to see if I could shrink mine a bit without pulling any dirty tricks -- when I realized that a chunk of his code is 'hidden' in the reference to the regular expression object he's created elsewhere. With that added, and matching my code style to his, my version is less than 20 characters long…

You missed the point. Well, several points. My Library was written years ago and the idea was to support "ancient" browsers like Safari 2 as well as all future browsers. As the fairly torturous test page still works in IE8 (all modes), Safari 4 and Chrome it would seem a rousing success. In the meantime, jQuery has been virtually rewritten to get rid of the browser sniffing. Guess where they got the ideas (and figure…

Hi, welcome to HN! I sincerely hope that you will bring a different tone here than you do on comp.lang.javascript.

People tend to measure the "success" of their libraries or other code based upon whether or not it accomplishes their goals. If your goal was to simply build a set of abstractions, continue support for ancient browsers, and ensure that it continues to work for future browsers, then you've accomplished it and that's great.

However, you fail then to recognize the goals of other frameworks and libraries which differ from your own. That is, they sacrifice compatibility with very old browsers for the sake of improved performance and support for newer browsers; or they sacrifice strict correctness for improved rates of development; or they sacrifice other aspects of Javascript-specific techniques for the sake of readability or establishing patterns familiar to novice programmers.

The authors of other frameworks can no more be criticized by you for failing to meet your goals, than we could criticize your library for failing to meet our goals.

Indeed, you're correct that I did not read every one of your more than 9,000 lines of code (almost 330K!) for the complete library. Rather, given your penchant for reading a few lines of some framework, critiquing them, and then declaring them to be no longer worth your time -- I thought I'd try the same.

...Actually, I'm being needlessly rude there. The truth is, I did attempt to review portions of code inasmuch as I had time for. Much of it was simply not notable; I picked out the camelization for one point because I had been tuning my own just a few nights ago.

Thanks (seriously) for pointing out the Safari 2 incompatibility. I'll consider whether adding support for Safari 2 is worth re-working that line. (Probably not, but maybe.)

We could continue to dicker back and forth on the relative merits of one bit of JavaScript versus another, but I'd rather keep working on mine, other people would rather start writing their own obvious unit tests, and you would hopefully rather update your library or something.

Re: I'll sue you if you use my common-sense JavaScript tests

#67
post #48

The worst kind of trolls are the ones that are knowledgeable and articulate, but arrogant, dogmatic crusaders. Many programming mailing lists I've been on ended up acquiring somebody like this, at which point I usually have to unsubscribe in order to resist the temptation to get into pointless flamewars.

Actually, the worst trolls are the ones that are knowledgeable and articulate, but are more dedicated to trolling than to any particular beliefs. Dogmatic trolls are at least somewhat constrained by their dogmas.

Re: I'll sue you if you use my common-sense JavaScript tests

#69

It would be useful that instead of praising one person and denegrating another, supporters of jquery, capucinno et al addressed each of the many concerns that have been raised about those libraries in a manner that can be objectively evaluate.

It's difficult to have a rational discussion with someone who has already staked out an extreme position and offered little to no evidence to support that opinion.

Also, it's spelled Cappuccino. And since David's superficial review contained virtually nothing of substance, there isn't much to objectively respond to.

Example:

           

     > Nice markup. 
Yes, one file in 280 Slides (not Cappuccino) has spaces between the attribute, equals sign, and quote. We must be incompetent.

    > Yeah, I guess "false" is harder on the fingers. 
Or, maybe, we're going for an easier transition for people from an Objective-C background...

    with (new prototype_bug()) 
        member = true; 

    > Ugh. 
How insightful. Hilariously enough, this is actually doing real feature detection to detect a real bug in real browsers.

    > I've seen enough.
So, in other words, he made no substantive evaluation. If you ask us questions, and aren't a dick about it, we're more than happy to give answers. We readily admit our own faults, and we're vocal about what our framework is not designed to do.

Re: I'll sue you if you use my common-sense JavaScript tests

#70
post #65

Earlier quoted context omitted.

And you don't know what you are talking about either. To save time, responses are aggregated here:- http://groups.google.com/group/comp.lang.javascript/browse_t...

His response is typical. He denies saying things which can easily be disproved. He makes basic factual errors and in the same sentence validates most of the criticism in this thread: "Cappuccino. That's something built on top of Sproutcore, right? No need to get any deeper than that." Of course, Cappuccino isn't built on Sproutcore, but even if it was this sentence illustrates the fact that David has long ago made de…

"cloverfield" is David Mark, FYI -- it seems someone went and pointed him here.

I noticed in several parts in his response, he's trying to claim credit for aspects of jQuery's development -- something that I think most people would find patently ridiculous. Given David's recent threats, if I were Resig, I'd be tempted to start using the word "defamation" and tell David to put up some evidence or shut up.

Fortunately, I'm sure Resig's more level-headed.

Post reply on HN