Hacker News new | ask | show | jobs
by mercer 3384 days ago
Do you have experience with NPM and Yarn (javascript/node) and if so, how do the package managers and ecosystem compare?

I'm asking because I'm primarily a js dev with a bit of Ruby and Ruby on Rails experience, and I'm wondering if Python/Ruby are worth investing in at this point and if perhaps instead it makes more sense to stick with js (Yarn in particular for package management) and explore more fundamental (C/C#/C++/Swift/Objective-C) or exotic (Haskell, Clojure) communities/languages/environments at this point.

2 comments

Imho it's greatly valuable to have a "real scripting language" in you tool-belt. Node doesn't qualify like one to me, unless you're one those mutants with brains twisted in particular ways that actually like explicit-async code everywhere. Considering the age we live in, one with good interfaces to machine-learning stuff would be great, so Python is great to know well imho.

The kind of prototypes that I can hack together with Python + whatver frontend in a day can take 4x as much to do with Nodejs for me, simply because there are so many micro-decisions to make at every point (libA or micro-libC + micro-libB or mega-lib-D kind of stuff). And the way it leaves you with you "brains fried" after wrangling with some async bug... not worth it imho. Better to have the boring technical micro-decision made by someone else for you so you can concentrate on the cool stuff.

If you're working on anything where the product OR idea OR algorithm OR ux-process is much much much more important that "ecosystem" or scalability bulshit, nodejs will always feel at least 2x slower to develop in than either Python (if you're into AI/ML-ish things) or Ruby or Go or Elixir...

For web apps my alternative receipe would be to keep the web app nodejs and more the smarter-than-crud stuff to microservices written in anything but Nodejs.

Yeah, I have worked with js/npm more than ruby or python lately. I've looked into yarn, but haven't used it on a project yet.

I like npm. For package management, I think npm is on par with bundler (ruby) and thus a bit better than pip. I like the ease of use of package.json scripts and find myself using them more and more. They feel lighter and easier to set up than the ruby equivalent (rake tasks, usually), although when you start doing fairly complex stuff (e.g., custom asset management), they can get a bit unwieldy.

As for the ecosystems, I find javascript is more in flux. It is more work to keep dependencies up to date or to decide what library to use when you need one, and I've had apps break on minor and patch updates to dependencies fairly often.

There is also a focus on small libraries that just do one thing. Nothing wrong with that, but the number of dependencies some projects have is a bit crazy.

If you work with Ruby or Python for web stuff, you inevitably end up using JS for the frontend, so it is certainly a reasonable choice to use Express as the server and go full Javascript.

And my company does that a fair amount, but when we need an app to do something more complicated than serve web pages and talk to the database, we end up moving over to flask/python to take advantage of python's better libraries (esp. for math/science/data stuff).

So, I still see some value in picking up python. Nothing wrong with any of the other languages though, and you can learn a lot from any language. Depends on your interests and needs really.

> For package management, I think npm is on par with bundler

NPM is non-deterministic and doesn't have lockfiles, so it's a bit of a stretch to say it's on par with Bundler.

Yarn solves both those problems for JavaScript projects, and it's much faster.

Right, you have add on npm-shrinkwrap if you want to lock everything down (which I do use for some projects).

Yarn may well be better than npm, in fact, as far as I can tell it is, but, frankly, npm works well and I'm tired of switching js dependencies, especially really core dependencies like a package manager.

I'm hoping npm just steals whatever yarn does better than it so that I never need to switch...

Bundler is pretty great.

pip... pip... I don't know what to say about pip. It's probably my fault, but I can never seem to get pip to fully understand that what I put in requirements.txt should always always always be used for the project no matter what system level libraries are installed. If yarn were available for python, I'd switch to it today...

> Yarn may well be better than npm, in fact, as far as I can tell it is, but, frankly, npm works well and I'm tired of switching js dependencies, especially really core dependencies like a package manager...

Yarn still uses your package.json. I think it will definitely win out over directly using npm since it is better in a couple of ways and, from a user perspective, is just a thin wrapper around the things you're already used to doing. Ways my workflow has changed:

npm install . -> yarn

npm save --dev pkg -> yarn add --dev pkg

npm save pkg -> yarn add pkg

npm run command -> yarn run command

If you start using it and dislike it, just npm uninstall -g yarn, rm the yarn.lock file and bam, you've still got a normal npm dependency management setup.

> If yarn were available for python, I'd switch to it today

Project worth keeping your eye on: https://github.com/kennethreitz/pipenv/blob/master/README.rs...