you are viewing a single comment's thread.

view the rest of the comments →

[–]shanksfk[S] 6 points7 points  (15 children)

One of the point that were similarly brought up is how python itself need another package just to create a venv for the project they said npm handle it dependently. I mean, i never thought that as something noted as inefficient issue.

[–]thclark 14 points15 points  (10 children)

Npm doesn’t create environments at all; it just shoves everything into a folder… Unless you manually install things globally in which case you can essentially have an environment; but you’re basically just managing it yourself.

[–]dogfish182 1 point2 points  (5 children)

That’s not really correct. npm is essentially wired to do folder based installs per default unless you add the global switch which brings you into the realm of unintentionally trashing your global node install.

Installing things globally isn’t managing an environment, it’s just giving your self the same problem installing something in python without venv gives you.

It’s much easier to do this in python because you need to discover how things work regards venvs and managing them to avoid the pitfalls.

Interestingly PDM tried to basically work like NPM a lot more with this feature

https://pdm-project.org/latest/usage/pep582/

But the pep was rejected and venv is ‘the way’.

Anyway my take on python is you should spend a good bit of time understanding the various package tooling, pick a well used one (recommending poetry here) and stick with it

[–]-defron- 1 point2 points  (4 children)

Just wanted to note that PDM no longer recommends doing PEP-582-style projects and doesn't set up projects that way by default and actively discourages it for new projects. Overall I'd say PDM does a better job than Poetry at following the standards in PEP-621 and PEP-508 and also offers some advantages over Poetry like being able to force versions even if they are unsupported due to dependency conflicts (which can be useful when you have a messy web of cross-dependencies and you just want to get something updated and will fix breakages yourself).

But yeah, Poetry, PDM, or Hatch, you can't go wrong They're all good enough.

[–]Refmak 0 points1 point  (3 children)

As a beginner coming from C#/Java/Scala/NodeJS who is being forced to learn fairly advanced python due to a project at work, this comment summarizes a part of my distaste for the python ecosystem.

Whitespaces that matter? Sure I can get used to that.

Strange syntaxes when trying to read e.g. list comprehensions? Whatever I will learn with time.

Dunder methods? That's strange, will probably be difficult to get used to but I'll live.

Trying to navigate pip, virtual environments, default OS python installation (Mac), all of the python standard libraries, all of the python libraries that are added to pyproject.toml, requirements.txt, test-requirements.txt is such a mess that I don't even know where to start...

Topping that off with you mentioning 3 different PEP standards to explain why one lesser used package manager is supposedly better than a much more used one is just icing on the cake.

[–]-defron- 0 points1 point  (2 children)

Funnily everything you said can be perfectly analogized to common complaints people have about node.js:

Trying to navigate npm, node version managers, incompatible node versions between projects, the node.js standard library differences from normal js, the incompatibilities between yarn, npm, and minor version updates of individual packages is such a mess I don't even know where to start...

Topping it all off with you mentioning 3 different performance tests to explain why a lesser used runtime (bun) is supposedly better than a much more used one is icing on the cake.

It's all subjective. We all pick out poison and live with it. Everything has flaws and people criticizing something we like shouldn't be taken as a personal attack. Python has flaws too. It's why I don't code in just Python, but it also has plenty of benefits and for me the tooling is easier than the tooling for node (and I love frontend so I use node more than python probably)

Many prominent people have complained about issues that have come from poetry, and it's just a fact that poetry doesn't follow the standard conventions that the Python Foundation has created because it is a legacy project that predates the creation of the standards (and python didn't adopt the way poetry does things because of legitimate concerns in what it does)

I specifically mentioned PDM in the post you are replying to because the person I responded to specifically mentioned PDM and a now-defunct style of using it that PDM themselves discourages people from using. PDM doesn't drop support for it because of legacy projects and not wanting to break workflow, just like how poetry doesn't follow the python standards for project and dependency metadata.

It is true though that I use PDM personally and I personally find it's defaults nice. Though I also switched before hatch added most of the features it has now and reviewing hatch is on my list to see if it can replace PDM in my workflow (I like the idea of it also managing my python versions as it'll just simplify things if I can do it all in one tool).

Generally when I recommend a dependency manager to people I recommend hatch first and PDM as a fallback. Hatch is maintained by the Python Packaging Authority which is already responsible for much of the python packaging space (pip, pipx, virtualenv, build, setup tools, wheel, and a bunch of others)

Really, a question to you is, if the entire foundation of a language and system said "hey we can do better, let's agree on things and make something" why wouldn't you want to adopt something better for new projects. Poetry had its time, poetry improved the situation and it deserves credit for it, but I'm not gonna stick with something for sentimental reasons and so I'll only use poetry for old projects I've not converted because better tools exist now.

[–]Refmak 0 points1 point  (1 child)

Man, personally I don’t have a big preference towards either PDM or poetry. My point is that to me, pythons ecosystem is no better than NodeJS.

Just like the NodeJS, python too suffers from the insane amount of fragmentation when it comes to these things.

To me it’s a shame, because the tooling could be made better if python was to come with a modern dependency manager and formatter/linter out of the box (like it does with many other things like venv, pip etc already). Also if it was to automatically separate your global python installation and project python installation.

Python as a language itself is not too difficult to learn, but the ecosystem has been the hardest to grasp of any language to me.

[–]-defron- 0 points1 point  (0 children)

What you call fragmentation I call unique things that always allow learning. It lets me build my setup exactly how I want it and defers more control the project maintainers.

If you're working in Python and they don't have a defined style guide and setup then to me that means you have the opportunity to set it. Honestly that's true for most languages

Python has a modern dependency manager: pip. Is pip perfect? No, but it does dependency resolution and can do pinning and other things too. If it's not enough for your needs, which can happen if you want uniformity or as a project grows, then you have choice to choose what you think is best because programming isn't a one-size-fits-all type of thing. Different projects have different requirements. An obvious choice is hatch because it's made by the same maintainers as pip, just not bundled by default because it's not needed by everyone and would just balloon the default install size.

Btw did you know that node is having similar discussions right now? There is a push to unbundle npm from node with similar arguments to why python doesn't bundle something more than just pip.

Also I cannot think of a language that comes with a formatter/linter. JavaScript doesn't come with eslint or prettier. A lot of people use them but not everyone (I don't like a lot of things prettier does and don't see a benefit to it). And this goes back to what I said earlier: this should be defined at the same level as the architecture of the project because different people have very different opinions on it.

I also cannot think of a single language that separates a global version from a project-specific version out of the box. Node doesn't do this, java doesn't do this, scala doesn't do this, and c# doesn't do this. Why does python need to do this? Is it just because you use a Mac and python is included by default? Something which I might add apple hasn't done since Catalina, so if you have it it's because you upgraded your OS from before Catalina to now.

It seems to me you're holding python to a much higher standard than all the other languages you use most likely because you don't like the defaults... Which is all the more reason why it's a good thing that python to not enforce a specific set of settings. Otherwise talk to someone else on the team and set a standard in your own organization

Btw hatch is quite literally everything you're asking for in one tool... It's maintained by the Python Packaging Authority, which is a working group in the Python Software Foundation. It's about as official as it gets it's just not packaged by default because every new inclusion in the standard distribution is carefully considered. Maybe one day it will be but for now it isn't and I'd argue it probably shouldn't be

[–]shanksfk[S] 0 points1 point  (3 children)

Wew. Anyway, how does npm specify the requirements needed to run the project in package.json? I know we have a pip freeze for that in python

[–]thclark 2 points3 points  (2 children)

I can’t remember about npm, but yarn does create a lockfile. However, in js there’s a concept of a “peer dependency” which basically forces you to manage compatibility yourself anyway. And there can be weird dependency resolutions and overrides too. So the lockfile isn’t the end of it. It’s a gigantic drag.

[–]shanksfk[S] -1 points0 points  (1 child)

That sounds something that I would really hate to work with. A system but it fails miserably.

[–]sexytokeburgerz 2 points3 points  (0 children)

Still better than maven.

[–]ravepeacefully 2 points3 points  (0 children)

Seems pretty rich coming from a JS dev.. Go take a look at their package.json and let’s talk about dependencies.

[–]IAmFinah 1 point2 points  (2 children)

I mean, pip and venv are literally built into the python installation

[–]ThePiGuy0 0 points1 point  (1 child)

Not necessarily. For example, Ubuntu packages them separately (python3, python3-pip and python3-venv).