Live data from Hacker News

Lodash v3.0.0

lodash.com

41–50 of 82 posts

Re: Lodash v3.0.0

#42
post #6
post #2

Already submitted: https://hn.algolia.com/?query=lodash&sort=byPopularity&prefi... Seems like no one cares. Strange.

I use Lodash but i see not point in this announcement in its current form - what changed exactly? [edit] Changelog is there https://github.com/lodash/lodash/wiki/Changelog Some decisions sound really weird, such as the fact that forEach is now lazy. It is not a standard replacement anymore, and probably break the compatibility for quite a few apps (even if I'm deeply convinced that we should all use the native functi…

It's only lazy when using the chaining syntax - and that one was never a standard replacement since `_.map(arr, fn)` returns a wrapper around a value and not a value.

Re: Lodash v3.0.0

#43
post #36
post #34

Q: "What does it do?" A: "A utility library delivering consistency, modularity, performance, & extras." Q: "Yeah, but what does it do?" A: "Oh, nothing but it does it consistently, modularly and performant. We also have functions for string handling in the extras module."

It's extra stuff that should be in the standard library but isn't. These days, a lot of it is actually in the standard library - for example, array maps - and invoking lodash just calls the es5/es6 built in, with a slightly uglier syntax.

The most important feature is chaining and lazy evaluation.

I think the most useful functions are the typechecking utilities (typeof in javascript is the most useless keyword the human kind engineered in a language).

In the end is a very nice library to work with when it does not get in the way (of course, if you are using `_.each([], fn)`, you should think again and use `Array#forEach` or a nice `for`)

Re: Lodash v3.0.0

#44
Lodash is an incredible accomplishment, and having it vastly improves the Javascript authorship process over the standard library.

That being said, I still can't believe we don't have a flatMap:

https://github.com/lodash/lodash/issues/812 https://github.com/jashkenas/underscore/issues/452 (Underscore repo, but still Mr. Dalton, author of Lodash, opposing.)

Re: Lodash v3.0.0

#45
post #36
post #34

Q: "What does it do?" A: "A utility library delivering consistency, modularity, performance, & extras." Q: "Yeah, but what does it do?" A: "Oh, nothing but it does it consistently, modularly and performant. We also have functions for string handling in the extras module."

It's extra stuff that should be in the standard library but isn't. These days, a lot of it is actually in the standard library - for example, array maps - and invoking lodash just calls the es5/es6 built in, with a slightly uglier syntax.

But if you want backward compatibility, you still probably want to use something like Lodash. I'd also argue that Lodash's/Underscore's interface is far better thought out than the standard library. The standard library has so many absurd gotchas, like `["2", "2", "2", "2"].map(parseInt)`. The verbosity of Javascripts lambdas also makes composition of simple parts more arcane looking than necessary, and having a whole bunch of composable/chainable utility functions does a lot to help people write self-documenting code.

Re: Lodash v3.0.0

#46

Earlier quoted context omitted.

Lazy.js claims to be even faster than both with support for lazy evaluation to boot. Not quite a drop-in replacement like lodash is, but I think it only requires a minor tweak.

A new feature in 3.0 is that lodash now supports lazy evaluation using the chaining API from 2.x.

So 2.0 code which used chaining is now broken if it doesn't explicitly exhaust the chain?

Re: Lodash v3.0.0

#47
post #37

Earlier quoted context omitted.

Thanks - it sounds as if you could use it as a drop in replacement for underscore.

Yes, you can. I've successfully done so in a Backbone/React app. The _.chain() method furthermore gives a nice functional style ways of building lists which is useful when building UI in React, like so: var list = _.chain([1, 2, 3, 4, 5]) .filter(function (value) { return value > 2; }) .map(function (value) { return value; }); console.log(list); // prints: // [3, 4, 5]

That's not "furthermore". chain/value also exists in underscore.

Also your code was broken in Lodash 2 (it'd return a lodash object, not a list) and is more broken in Lodash 3 (chains are now lazy), so your code does just about nothing until you force the iterator's evaluation)

Re: Lodash v3.0.0

#48
post #36
post #34

Q: "What does it do?" A: "A utility library delivering consistency, modularity, performance, & extras." Q: "Yeah, but what does it do?" A: "Oh, nothing but it does it consistently, modularly and performant. We also have functions for string handling in the extras module."

It's extra stuff that should be in the standard library but isn't. These days, a lot of it is actually in the standard library - for example, array maps - and invoking lodash just calls the es5/es6 built in, with a slightly uglier syntax.

Interestingly, in practice lo-dash actually doesn't proxy through to the native implementation for things like map and forEach. Just using loops ends up being more performant because of some edge cases in the ES5 spec for those methods that lo-dash and underscore don't follow.

http://benmccormick.org/2014/11/12/underscore-vs-lodash/

Re: Lodash v3.0.0

#49
post #9
post #4

Really nice to see that there's now an auto-curried, function-first version, lodash-fp! I've been really attracted by Ramda JS recently for this reason. https://www.npmjs.com/package/lodash-fp

I've been looking for some real-world examples of how currying might be useful in javascript. Haven't not used a language which supports currying for any real world project, I'm interested to know how it can help. I found a page [1] which talks about currying in javascript, then says "Are there practical uses for currying in JavaScript? Not really." Can you point me at anything which will help me see why it's useful?…

There is an excellent talk called "Underscore, you're doing it wrong!". The talk explains how well designed param order with currying leads to very short and expressive code -- and how underscore missed the boat. This aspect of it should be interesting as it's related to this post. It's well worth the watch.

https://www.youtube.com/watch?v=m3svKOdZijA

Re: Lodash v3.0.0

#50

See release notes and changelog: - https://github.com/lodash/lodash/releases/tag/3.0.0 - https://github.com/lodash/lodash/wiki/Changelog

I dig laziness, but why is `forEach` lazy? That's the only one that invokes immediately in libraries like Lazy.js.
Post reply on HN