I like that I have to think in Rust before compiling, not after.
A nice patena on aged metal !
It kinda feels like cheating for rust to publish a list of reasons why rust people like rust...
I like rust too, but this feels more like advertising than useful commentary on the language and its tools.
Why not? Of course people who make something (in this case, a programming language) are going to promote what they make and share praise they've received. It's a pretty normal thing to do. They're not trying to obscure the fact that they're the Rust Foundation—it's on the Rust blog.
Did you read the post? It ends with several critiques of Rust.
"I think proc macros are a really big superpower for Rust."
Yeah, been working on a framework and proc-macros are really useful to simplify the API.
For example, previously I needed users to define a struct and then an impl block with a function inside. Well, and they need to do that a lot, so it was genuinely a bit of a pain to write out, but it also made the code feel more complex than it really was.
Now I've got an annotation, which you can slap onto a function and then it generates the struct from the function parameters and puts the function into the impl block.
And while you do need to be aware that the function parameters will be put into a struct and therefore you want owned parameters, all-in-all it still feels really nice to just delete dozens of boilerplate lines and an indentation level in the codebases where I've introduced it.
...and not just for performance-heavy stuff or embedded development, but for shell scripts...
WHAT
Yeah it's great for little scripts. There's even a cargo script feature that's being worked on so you can compile & run them using a shebang.
I'd use a shell script if it is literally just a list of commands with no control logic or piping. Anything more than that and you're pointing a loaded gun at your face, and should switch to a proper language, of which Rust is a great choice.
Honestly yes. If I need to manipulate the filesystem or manage processes with any amount of conditional logic or looping, I'd much rather do it with Rust than shell scripts.
The only thing I use shell scripts for anymore is completely trivial sequences of commands.
As someone who uses a lot of shell scripts and learning Rust, do tell more.
One of the simplest tricks is that you can throw down a function, which you can call with a command like e.g. this: run("cat /etc/os-release | grep NAME")
by constructing a Command like so:
Command::new("sh")
.arg("-c")
.arg(command) //the string passed as parameter
There's proper libraries to make running commands even easier and more robust, but if you don't want to pull in a library, that's really easy to write out ad-hoc and gets you 95% of the way there, with shell piping and everything.
You can do this in all programming languages that exist...
That's kind of the point. You can do it in most languages, so why use a shitty one like Bash? Use a good language like Rust!
Also there are aspects of languages that make many languages less suitable for this application though. For example Python, because you can't use third party dependencies (or at least you couldn't; I think uv has an equivalent of cargo script now). Java would be a pretty awful choice for example.
Python is actually super known for its batteries included approach, it has modules for everything. Simply do pip install anything. But best practice is to use a python virtual environment and install packages into that one. Cargo does this by itself in each project and doesnt install modules globally.
But python code is so much easier to write. Its basically almost English and the syntax is easy. Rust... Not so much. Its quite ugly.
Its a systems programming language. Designed to be fast to execute. Its one of the slowest to write code in. But sure, with Ai, you can just ask for a rust script and it will run.
Oh yeah, I'm not saying this is what makes Rust special. Rust's strength in comparison to Bash is that it's a lot more competent at control flow and structuring programs. But yeah, virtually any programming language is at least better at that than Bash, so whichever one you're most comfortable with, is probably the best choice. This trick just allows you to make use of Bash's biggest strengths, which is easily running commands and piping between commands, while also having the competent control flow and structuring of your programming language of choice.
Kind of agree with you here.. I wouldnt reach for rust. Python gives much faster results than rust.
/me putting my Rust (post-v1.0 era) historian hat on.
The list of (language-level) reasons why people liked Rust was already largely covered by the bullet points in the real original Rust website homepage, before some "community" people decided to nuke that website because they didn't like the person who wrote these points (or rather, what that person was "becoming"). They tasked some faultless volunteers who didn't even know much Rust to develop a new website, and then rushed it out. It was ugly. It lacked supposedly important components like internationalization, which the original site did. But what was important to those "community people" (not to be confused with the larger body of people who develop Rust and/or with Rust) is that the very much technically relevant bullet points were gone. And it was then, and only then, that useless meaningless "empowerment" speak came into the picture.
Rust
Welcome to the Rust community! This is a place to discuss about the Rust programming language.
Wormhole
Credits
- The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)