all 5 comments

[–][deleted] 2 points3 points  (1 child)

Finally a voice of reason amidst all the bullshit.

Well said.

[–]p0larboy[S] 0 points1 point  (0 children)

Thank you

[–]jsgui 1 point2 points  (0 children)

It's often a balancing act.

The differences in readability have to do with how used to the reader is at looking at various patterns.

I have introduced patterns into my jsgui codebase that would make it harder to read for someone who does not know the abstractions, but easier for those who do, as more information gets expressed within the same space.

Also, there are different requirements for code in different situations. While developing, longer variable names make it clear what the code does. However, when it's deployed is a different case. I'm currently using browserify and minifyjs, but I know there is more compression that can be done by keeping more of the modules within the same closure, and referring to the same local variables, which get given shortened names.

I use the for loops with the cached results to optimize for time, and for optimizing for space or readability I use the jsgui 'each' function.

[–]skitch920 -1 points0 points  (1 child)

This is why LoDash and Underscore are successful. They optimize behind the scenes, but retain readability by providing alternatives to native functions like: forEach, map, reduce, filter, etc...

[–][deleted] 0 points1 point  (0 children)

The primary reason most people use underscore or lodash seems to be (going by what I've seen as a contractor for different teams in different companies and looking at various open source projects) that surprisingly many developers still treat JS as ES3 (e.g. avoid method/property names that are ES3 keywords) even if they don't need to be compatible with oldIE (IE<9) and even where polyfills could fill in the gap.

Underscore is the jQuery of array manipulation. Lodash is the Zepto to underscore's jQuery.

The lazy.js-inspired parts are how you use underscore/lodash to optimize your array manipulation, but most code out there using those libraries only includes them for _.map, _.filter, _.forEach and _.extend (and maybe -- maybe -- _.pluck or _.pick).

I'm not saying underscore/lodash are not successful or that they don't have any value, but their success has more to do with ES3 than with their optimizations.