7 ms·
To me, a clear benefit of rust over python, and I love python is that once you write something in rust, you have an executable that you can give to someone that
by daft_pink 2y ago
To me, a clear benefit of rust over python, and I love python is that once you write something in rust, you have an executable that you can give to someone that doesn’t know how to program.
Python is great for something I will use myself, but not so great for when I want someone else to use my code.
- Levitating 2y agoI don't agree with this. If I give somebody a binary, I have to compile this binary for their operating system and architecture. If they don't know how to program they'll be confused as to why they cannot share this program with others. If I share somebody a python script, they can still execute it as a program as long as a shebang is set. They can use this script on any operating system and can open it with at text editor to view it's inner workings. This makes scripting languages like Python much more accessible for single-file scripts.
- greener_grass 2y ago> they can still execute it as a program as long as a shebang is set Not if you use any libraries.
- NoboruWataya 2y ago> If I share somebody a python script, they can still execute it as a program as long as a shebang is set. As long as they have the right version of Python and all of your program's dependencies installed, which they most likely won't. > They can use this script on any operating system and can open it with at text editor to view it's inner workings. Someone who doesn't know how to program most likely isn't going to be using multiple operating systems and isn't going to want to open the script in a text editor to view its inner workings. I agree with the parent comment that distributing binaries is way more seamless when your users are not very technical.
- wrenky 2y agoAND holy shit I have to install another venv to run special-snowflake-3 script I will literally lose it. I literally have a folder of all the venvs I need to run one-off shit people pass me. I get the lack of wanting to compile things but thats not a problem with modern build systems like Rust/Go have- Beyond trivial.
- awesomebytes 2y agoI have recently started to use uv, and you can just do "uvx tool" and it executes the tool (https://docs.astral.sh/uv/guides/tools/ https://docs.astral.sh/uv/guides/tools/). Sure, the tool needs to do something to be able to be executed like that, but it seems pretty easy. And there's also a way to embed the dependencies with a comment at the top of a python script: https://docs.astral.sh/uv/guides/scripts/#running-a-script-with-dependencies https://docs.astral.sh/uv/guides/scripts/#running-a-script-w... The venv created for this is ephemereal (it can not be if you want), so you don't need to keep in mind cleaning up stuff and so. Also uv is really fast in creating the venv and installing whatever is needed. Coming from using plain pip and venvs (and having pain setting up different python version interpreters for projects), and poetry just after that, I am pretty happy with the improvements.
- blackfawn 2y agoYeah, really... Python tries to hide some of the insanity behind venvs, conda, etc. but it often ends up some dependency nightmare that's barely holding together. Everyone that tells me "oh Python is so great, it just works" is either only using it for the absolute most basic tasks or kidding themselves. I'd often get a blank stare when I respond to that with "then why am I helping you fix this virtual environment with gigs of cruft for a 'simple task' that has suddenly and inexplicably stopped working for you?" The equivalent things in Go, Rust, etc are a breath of fresh air for sure
- pizza234 2y ago> If I share somebody a python script, they can still execute it as a program as long as a shebang is set. I'm not familiar with Python, but I presume its similar to Ruby, where besides trivial scripts, this is false - as soon as there are libraries required, you need to find a way to handle them, which in some cases may include handling multiple envs (I write and distributes such scripts). Compiling for multiple environments in a controlled environment is by far much more convenient than debugging scripts failing on end users' systems.
- pid-1 2y agoIMO it's far worse than Ruby. Since Python is meant to be a glue language, scripts can have every type of esoteric dependency, including binaries, os libs, java programs, etc...
- Levitating 2y agoRuby isn't any different
- stonemetal12 2y ago>If I share somebody a python script, they can still execute it as a program as long as a shebang is set. Since when has windows come with python installed and worked with a shebang? Mac OS doesn't come with python installed and clicking it won't run it. So anyone " confused as to why they cannot share this program with others." isn't going to be able to use your python script.
- ayhanfuat 2y agoThis would work in a language with better and more modern packaging (like Julia) but giving people Python files and expecting them to run them in correct versions might just be a bigger ask then asking them to compile C code.
- faangguyindia 2y agoUnlikely, you need to install virtualenv. As they may not have same python version, may have different python libraries (version) It's not simple to run a python script specially one which uses libraries (let's be honest how often your core is not using those popular libraries)
- anonymoushn 2y agomaybe if you don't use glibc? https://stackoverflow.com/questions/69010070/rust-linux-version-glibc-not-found-compile-for-different-glibc-libc6-version https://stackoverflow.com/questions/69010070/rust-linux-vers...
- globular-toast 2y agoThis is what pyinstaller is for. It's not quite as good as a binary executable, although are you really sending ad hoc binaries to people? Seems like a nightmare for version control etc. The pyinstaller manual is much easier than learning rust!
- judge2020 2y agoThere are a host of Python to Executable tools that either compile the code to c or include the interpreter and run the code dynamically.
- keybored 2y agoThe Rust implementation is on the heavy compiled end. The Python implementations are on the more interpreted end. Considering how widespread Python is it seems like solving the one-executable problem for Python should be easier than solving Rust’s problem (heavy compilation). Like with a wrapper or something.
- zie 2y agoYou can totally make binaries with Python, there are even many, many ways to do so. None really come out of the box, and some assembly is usually required, but if you want to do it, you can. That someone is too lazy to do so is not Python's problem, that's their problem.
- faangguyindia 2y agoThat's what I use Go for. It's much simple to write scripts in Go. Here's an example; https://github.com/zerocorebeta/bashlike https://github.com/zerocorebeta/bashlike