Backbone: OFFICIAL opinion needed [underscore vs. lodash]

Created on 6 Aug 2015  ·  7Comments  ·  Source: jashkenas/backbone

Can someone give me OFFICIAL opinion by Backbone.JS how stable is migration/usage of Lodash.

I know these 3:

I've read Lodash Migration notes but still I want backbone community opion also. I wanna make sure ALL of above lodash version will work correctly with ANY version of backbone starting from 1.1.x.

UPD-1: Trying to digest: https://github.com/jashkenas/underscore/issues/2182

UPD-2: In fact personally me, closer to use Underscore - as a first, original library for similar purposes. I think that John-David SHOULD NOT HAVE forked and create new whell, but instead he should have contributed with/to Underscore and help Jeremy with improving underscore. WHAT bad is in this collaboration? But I'm not so good in history of both libs, so I may be mistaken. So sorry in advance.

UPD-3: Backbone tests. Special thanks to @RusAlex for triggering thinking in that way. So I took 2 versions of backbone and ran tests with different lodash versions.

_Backbone 1.1.2 and_

  • lodash 3.10.1 - no failed tests
  • lodash.compat v3.10.0 - no failed tests
  • lodash from my prj. frozen v. 2.4.1 - no failed testes
  • lodash.underscore v2.4.1 - no failed tests:

_Backbone 1.2.1 and_

  • lodash 3.10.1 - no failed tests
  • lodash.compat v3.10.0 - no failed tests
  • lodash from my prj. v.2.4.1 - 4 failed tests (68, 69, 200, 202)
  • lodash.underscore v2.4.1 - 20 failed tests (68, 69, 200, 202, 342-345, 355-363, 366, 368, 370)

So I assume, that using "latest versions of libraries on the release moment" of both of them is appropriate and not risky. And obviously - using different releases/versions is risky.

question

All 7 comments

Im not an official. But a programmer.

Try to replace undescrore with lodash and see backbone tests.

Backbone is well tested library this is why tests exist.

@RusAlex your answer is almost the the same as I already googled - many developers say like that. IT'S not for me. I want official opinion. Nevertheless, thank you for the reply, no need to follow up this, just to reduce amount of comments.

_Note_: I already migrated to lodash/backbone approach (and my project works fine), but my project-top-level architecture community is not yet sure it's correct way to go with, so I am eager to get proper - OFFICIAL answers here to be 100% on right way.

After reading underscore issue #2182 I realized, that sooner or later we might have underdash, and I MORE that AGREE with such collaboration between @jashkenas and @jdalton. I'm sure, these "Gods" are busy now, so there is very low probability they will answer me here.
Anyway, it would be answer for me equal to OFFICIAL !!!

So I assume, that using "latest versions of libraries on the release moment" of both of them is appropriate and not risky. And obviously - using different releases/versions is risky.

Yap. Lodash includes Backbone and Underscore tests and has run them for each commit up to the current stable release. In the future Lodash may fail a handful because several tests use non-Backbone related Underscore methods but we'll excuse them so there won't be any surprises on the Lodash side of things.

Lots of projects go Lodash first with Backbone.
I think Backbone has an official statement here.

We don't test for Zepto and Lo-Dash compatibility but they both should work fine. If you need a stronger guarantee, stick with jQuery and Underscore.

lodash runs and passes all of the backbone tests in their CI. Further Marionette runs its unit tests with multiple version of underscore (1.4 - 1.8) and lodash (>= 2.4.0). Takeaway: backbone should work fine with lodash 2.4-3.10 (use lodash.backbone for 2.x series)

There are browserify methods to replace underscore with lodash in the wild for dependencies (https://github.com/thejameskyle/marionette-wires/blob/master/package.json#L96-L103) which seem to work, but are kind of sketchy (as there are a number of API differences between the libraries).

@jdalton THANKS for your reply.
I've read that part of backbone docs, and it's enough for me. But not all developers in my project-community are confident in this sentence:

tend to work, with varying degrees of compatibility...

which tells us some level uncertainty. And I agree for 1% with such developers. And that is why I started this discussion.

@megawac

  • Thanks for pointing that out. I do really happy for the Marionette team, and in my dreams they should merge with original Backbone team and double development forces.
  • As far as I researched there are:

    • lodash-for-backbone which is in fact weird and not exactly I want.

    • backbone-lodash which is in fact Backbone 1.1.2 contributed by @jashkenas and @brandonpapworth. In fact it's one of dozen forks of Backbone. So not interested at all (unless Jeremy will tell us - that that version will replace backbone at all).

  • "browserify way" is used in one of my community-projects. I think it's "LIE" to developers by doing simple substitution one library under the name of another. Not for me.

But once again, thanks for comments.

@akre54
Yes, I need stronger guarantee. And for now it's Backbone tests results (one more proven fact that #TDD is needed and works), they show me more than holy wars over the Internet. Thanks for closing issue, looks like resolved for the time being, and I have some solution for me:

I will migrate to Lodash for sure and will wait for Underdash :) I do really hope for that.

Oy, backbone-lodash is a blast from the past. In my use cases, I didn't run in to issues using Lodash compared to Underscore. Another change I made to the library was giving the ability for View elements to be created using document.createElement(someTagName) as opposed to $('<' + someTagName + '>'), but I honestly haven't used Backbone in a very long time. Aside: I've realized that looking back at my old, unmaintained code can be very entertaining/depressing.

My vote would definitely be for Lodash if it works for people and doesn't cause tests to create a singularity that sucks all of existence into it.

Was this page helpful?
0 / 5 - 0 ratings