Ah yes, David Mark. This guy trashes other JavaScript frameworks (usually quite pedantically) in order to promote his own "My Library". Not a good strategy if you ask me. We were the target of a highly superficial "review" by him soon after Cappuccino was made public: http://groups.google.com/group/comp.lang.javascript/msg/1799... (for the record, YES and NO are there for compatibility with Objective-C, and we benchm…
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 cases where a simple indexOf would be better, and, best yet, he doesn't bother to cache them in any of the dozen or so cases that I examined. Wasn't that one of his criticisms of someone else's code?
- His treatment of camelCase is truly embarrassing, relying on an ugly RegExp every time it's called. Try something like this instead:
_camelCases = {width:'width', height:'height'};
_camelCaser = function (p) {
return typeof _camelCases[p] != 'undefined' ? _camelCases[p] : _camelCases[p] = p.replace(/\-(.)/g, function(x, y){return y.toUpperCase()});
}
There, now you only need to camelCase the property for anything once. JavaScript's object handling makes caching this kind of stuff soooo easy. And, if you do have to have a camelCasing function, try to do it with as little overhead as possible -- use the tools that JavaScript gives you, instead of capturing the string parts in a match and then .join()ing them and all that other nonsense.His library doesn't demonstrate any of the kind of specialized language knowledge that he accuses other library developers of lacking, and it has at least some of the same weaknesses that he criticizes others' works for.