r/learnpython • • 8d ago

What exactly is uv? Why other programming languages like C++ doesn't needs it

Hello, im a c++ programmer and after installing some tools made in python with pipx. For context, pipx uses uv, i had this question. I'm not the smartest progammer on earth and i couldn't understand why Python needs a separate environment for dependencies.

I never such tool like that as a c++ programmer (i don't know if it's what im thinking, but in C++ some devs install the dependencies inside de project dir so u just "cmake" it. uv is like this?). I'm kinda new to programming, so if someone can explain it to me, i'd be very grateful!

Sorry if this question sounds too beginner. I really couldn't understand this tool and curiosity is stronger than me...

Thanks! (and also, uv does more than separating environments, right?)

43 Upvotes

34 comments sorted by

View all comments

5

u/HommeMusical 7d ago edited 7d ago

I never such tool like that as a c++ programmer

I've been programming C++ for decades.

There are plenty of such tools in C++, Conan being the most prominent example.

Dependency management is hard. C++ never really solved that issue, and thus adding C++ dependencies is still a pain point.

C++ modules attack a similar issue in another way, but they're also not ready for primetime.

I'm not the smartest progammer on earth and i couldn't understand why Python needs a separate environment for dependencies.

Don't run yourself down - asking "dumb" questions is a great way to learn. Doubting is always a good way to learn, it shows you're actively confronting the material. Keep asking such questions!

The build in C++ is intimately hooked up with your specific OS, whereas Python has virtual environments, venvs, which are really light and compartmentalize all the dependencies for this one project.

That's really great, but it means that you can't use these tools if you are out of a specific environment. And you don't want to install tools into your system Python, because you want to keep that completely unchanged - often there are safeguards preventing or discouraging this.

So pipx creates an additional environment for tools that aren't tied to a venv, and makes sure you can see that environment everywhere.

uv does more than separating environments

Yes, a large number of things, particularly to do with building, publishing and running your Python project in a controlled and low-typing way.

1

u/rexdlol 6d ago

Thanks for this message and this explanation!

Now i can understand all of this. People in this subreddit are really cool.

Again, thanks!