meteor / meteor

Meteor, the JavaScript App Platform
https://meteor.com
Other
44.07k stars 5.16k forks source link

Investigate swapping Underscore w/ Lo-Dash or upgrading Underscore #1009

Closed jdalton closed 6 years ago

jdalton commented 11 years ago

_86 Upvotes_ It's been mentioned a few times, so I figured I'd track progress/questions with an issue.

_85 Upvotes_

felixrabe commented 10 years ago

Any updates on this?

richieb commented 10 years ago

Any update. I need some of LoDash's methods, including _.cloneDeep()

glasser commented 10 years ago

In Meteor, you probably want EJSON.clone.

Lodash continues to be something I/we are curious about but never seems to rise to the priority level of, eg, making the Mongo connector scale better. Maybe next bug week.

richieb commented 10 years ago

Thanks very much, David. I wasn't aware of EJSON.clone.

jdalton commented 10 years ago

Thanks for the interest in lodash. Let me know if you all revisit the issue in the future.

richieb commented 10 years ago

Hi, JDalton,

I am confident the Meteor Devs (also known as MDG, for Meteor Developer Group) will no doubt add LoDash to Meteor. But they started with Underscore as the safe bet at the time, I suppose. On top of that, I think they like to do their due diligence to make sure any package they add to the core Meteor platform is sufficiently tested and reliably integrated.

Therefore, I think they really just need a little push and the the time to include LoDash, but they wouldn't act unless there is enough interest. And based on the activity on this Github issue, there is not enough interest to rise to "sufficient."

LoDash is amazing and incredibly useful, btw. I have been using it with Backbone and Ember. And now that I am using Meteor, I expect to continue to use it. Thanks for your work on LoDash.

glasser commented 10 years ago

Lodash looks great. But just like every time we upgrade a Node minor version, the day I swap in lodash will be a day where I do a full automated and manual QA of Meteor. Which is something we're trying to make more and more automated, but we're not there yet.

Minor underscore version bumps have caused regressions for Meteor. Swapping out the entire implementation probably will too. (Usually it's a a matter of a place where Meteor needs an improvement because it was using Underscore wrong.)

jdalton commented 10 years ago

Minor underscore version bumps have caused regressions for Meteor.

Yap, that's because Underscore, and Backbone as well, don't follow semver. Lodash follows it though, which is why we've pushed passed v2.0 ;) We'll keep at it on our end. Ping me for questions/issues :email:

dalgard commented 10 years ago

+1

reezer commented 10 years ago

+1

Doing some benchmarks and profiling most time in our application is spent on underscore (and minimongo). So I am sure performance of many applications could be improved by switching. See the lodash website for in-depth benchmarks.

sbking commented 10 years ago

+1

ghost commented 10 years ago

:+1:

yasinuslu commented 10 years ago

+1

dohomi commented 10 years ago

+1

mxab commented 10 years ago

:+1:

frozeman commented 10 years ago

+1

Lobosque commented 10 years ago

+1

On Sun, Mar 16, 2014 at 5:15 PM, Fabian Vogelsteller < notifications@github.com> wrote:

+1

Reply to this email directly or view it on GitHubhttps://github.com/meteor/meteor/issues/1009#issuecomment-37768810 .

Lauricio commented 10 years ago

+1

ghost commented 10 years ago

+1

MauroJr commented 10 years ago

+1

aknuds1 commented 10 years ago

+1

I find lodash a great replacement for underscore, and use it whenever I can. I'm having problems fitting it into Meteor though, due to that integrating underscore already :(

bestwestern commented 10 years ago

+1

ByScripts commented 10 years ago

Voting for this too. Lodash is better and more reliable.

darkadept commented 9 years ago

I want Lodash too please!

fungilation commented 9 years ago

+1

timbrandin commented 9 years ago

+1

ghost commented 9 years ago

By the way. You can use Lodash instead of Underscore for your own code without problems. Just remove the dependency on standard-app-package and depend on the listed packages instead (select the release version you use). Make sure to remove underscore from your package.js. Then you can use the Lodash atmosphere package with mrt add lodash (or create your own).

I hope that helps some people, because I myself realised it quite late that there is no namespace conflict with _ because of the way that Meteor bundles the packages.

pajooh commented 9 years ago

+1

RichardLitt commented 9 years ago

+1

jaulz commented 9 years ago

+1

Replacing underscore with lodash can easily be achieved using the following approach:

  1. Install lodash by mrt add lodash
  2. Somewhere in your code simply use _ = lodash;

Though that also means that underscore is still loaded but later replaced by lodash.

lifeinchords commented 9 years ago

+1

shaneMangudi commented 9 years ago

+1

wizonesolutions commented 9 years ago

+1

rijk commented 9 years ago

+1

spencern commented 9 years ago

+1

subhog commented 9 years ago

+4

kyv commented 9 years ago

+1

evenfrost commented 9 years ago

+1

andresberrios commented 9 years ago

+1

janbaykara commented 9 years ago

+1

tkh44 commented 9 years ago

+1

JamesMGreene commented 9 years ago

:+1: for the :heart: of :godmode:

bobiblazeski commented 9 years ago

+1

igregson commented 9 years ago

+1

avital commented 9 years ago

Lots of people have been +1'ing this ticket, looks like people really want this. As Glasser describes, this isn't a trivial update. To help us prioritize, it would help to understand what particular problems you are having that switching to Lo-Dash helps with. Can some of the +1'ers elaborate?

raix commented 9 years ago

@avital The problem I had with underscore was https://github.com/meteor/meteor/issues/594 - Using _.each for an universal iterator had its issues - it ended when @glasser wrote a modified version of each to solve this. Imho it would have made more sense to use the lodash iterators instead. (more details in #594) - I do fully understand the implications switching regarding QA etc. a scary job.

I've tried to highlight the pro/cons/status in https://github.com/raix/Meteor-community-discussions/issues/8 and keep a track of things.

evenfrost commented 9 years ago

@avital As for me, the biggest advantage is speed. I believe this is mostly because Lo-Dash uses fast primitive loops and conditions instead of falling back to relatively slow native JS implementations (forEach-map-reduce etc.) as Underscore does. And this gap increases for web apps being developed with aim to provide really fast and pure experience on any platform — not talking about PhoneGap-like webviewers, but about REAL seamless (homescreen) web apps. And from this point, strict Meteor dependency on Underscore has always been a fly in the ointment (another one is jQuery, though this is off-topic for sure).

bobiblazeski commented 9 years ago

@avital I switched to lodash due to lack of cloneDeep and so far haven't looked back.Everytime I need some new feature I just look at documentation and 99% find it there. Lodash is very fast, feature rich and very high quality code. Due to my lisp heritage I code in heavily functional style and use lodash extensively where other people would use for loops (Steve Apter http://nsl.com/ style) and so far lodash always delivered both stylistically and performance wise. Here's how my code usually looks like

function raze(arr, keys) {
    return _.reduce(keys, function (res, key) {
        return res.concat(_.map(arr, function (d) {
            return {
                Year: d.Year,
                Name: key,
                Value: d[key]
            };
        }));
    }, []);
}

function  distribute2(people, amount){
        return _.reduce(_.sortBy(people,'need'),function(memo,person){      
           var ration = Math.min(person.demand,memo.amount);
          memo.amount -= ration;
          memo.people.push(_.assign(person,{ ration: ration}));
          return memo;
        },{ amount: amount, people: [] }).people;
      }

Just give lodash a shot and I'm sure @jdalton will help you in any roadblock you hit on. Whatever bug you fixed on underscore there's a big chance its already fixed on lodash.

timbrandin commented 9 years ago

For me, I haven't used it as I like to stick to Meteor defaults, but I like that its feature rich, well documented and has deep cloning. :)

Cheers, // Tim

2014-11-24 21:35 GMT+01:00 slobodanblazeski notifications@github.com:

@avital https://github.com/avital I switched to lodash due to lack of cloneDeep and so far haven't looked back.Everytime I need some new feature I just look at documentation and 99% find it there. Lodash is very fast, feature rich and very high quality code. Due to my lisp heritage I code in heavily functional style and use lodash extensively where other people would use for loops (Steve Apter http://nsl.com/ style) and so far lodash always delivered both stylistically and performance wise. Here's how my code usually looks like

function raze(arr, keys) { return .reduce(keys, function (res, key) { return res.concat(.map(arr, function (d) { return { Year: d.Year, Name: key, Value: d[key] }; })); }, []); } function distribute2(people, amount){ return .reduce(.sortBy(people,'need'),function(memo,person){ var ration = Math.min(person.demand,memo.amount); memo.amount -= ration; memo.people.push(_.assign(person,{ ration: ration})); return memo; },{ amount: amount, people: [] }).people; }

Just give lodash a shot and I'm sure @jdalton https://github.com/jdalton will help you in any roadblock you hit on. Whatever bug you fixed on underscore there's a big chance its already fixed on lodash.

— Reply to this email directly or view it on GitHub https://github.com/meteor/meteor/issues/1009#issuecomment-64259518.

Cheers, // Tim Brandin @timbrandin https://twitter.com/#!/timbrandin http://timbrandin.com http://studiointeract.com

patmoore commented 9 years ago

I would like to use lodash ( and will if I get time to test and make conversion ). I WAS worried about interfering with Meteor functionality but I see from earlier comments that lodash can be used without messing with Meteor.

For myself, I would be happy with an official way to use lodash in our code. I have no need to care about what Meteor uses internally - if I can independently use lodash.