11 ms·
Why is everything written in rust nowadays? Apart from the safety it provides.
by firefly284 5y ago
Why is everything written in rust nowadays? Apart from the safety it provides.
- skocznymroczny 5y agoGood package manager, broad ecosystem of packages, no header files, helpful compiler messages. It offers a good alternative to C++ for native applications.
- chalst 5y agoNot to mention excellent support for algebraic datatypes and pattern matching.
- kamray23 5y agoADT and pattern matching really does it. Older languages certainly have their pull and can do a lot but with many modern coders having an interest or even education in higher level mathematics, easily being able to do that will put you way ahead of the competition. Even the hyper-pure Haskell now runs its own ecosystem and has actual systems written in it.
- dthul 5y agoSo much this. After having encountered ADTs for the first time in Haskell and later on in Rust and other languages, any language without sum types (like Rust's enums) feels wholly incomplete. And the destructuring pattern matching is the cherry on top.
- hosteur 5y agoThat is like a big deal. Also speed.
- lovelyviking 5y ago>That is like a big deal Why you think it is "a big deal"?
- kamray23 5y agoWhy do you not? No memory leaks, no security issues stemming from such. No random crashes from memory misuse, no issues debugging the issues that exist. It's like a higher level language but lower. You get to do things your way, except when your way is fundamentally unsafe. The code is then easier to debug as it actually describes what's happening and issues are mostly algorithmic, while the application gets a massive boost in reliability and security. Security is like the issue now, along with reliability. That's what people need and want. Rust offers that.
- hnlmorg 5y agoRust isn't the only language that offers that. In fact most languages offer that. Even Pascal is safer than C. Or if we're really concerned about security then we should be advocating that out shells are written in Ada. But clearly there's more to it than that.... It's also worth remembering that the biggest causes of RCE in shells haven't been buffer overflows. It's been fundamental design problems from the outset (eg Bash executing functions in environmental variables (Shellshock) and CI/CD pipelines or other programs forking out to the shell without sanitising user input nor having sufficient RBAC in place). Don't get me wrong, I have nothing against Rust. I think its fantastic that we're seeing diversity in the ecosystem. But we need to be careful not to judge a project simply because of its use of Rust (or choice of other language). The reality is soooo much more complicated and nuanced than is often made out in HN.
- pdpi 5y agoMaybe we could be writing things in ADA. I don’t know, it’s a language that’s been on my radar for several years but I haven’t actually dug into it yet. That said, we need something to replace C — and Rust seems to be picking up momentum. Rust seems good enough a replacement to me, and that’s enough for me to cheer it on. I do agree that “written in rust” isn’t as big a guarantee of quality as people here assume though.
- hnlmorg 5y ago
- vbsteven 5y agoI think Cargo doubling as both build tool and package manager is a big factor here. The combination of Cargo + crates.io makes it very easy to write some Rust code and make it available to anyone with Cargo on their system. Either by `cargo install nu` to build it from sources on crates.io or `cargo install` inside the git repo to build my own customized version. No more waiting for distro packagers to keep up. Putting this together makes for a nice environment to distribute native system tools. And in the last few years we've seen a wave of these tools becoming popular (ripgrep, bat, fzf, broot, exa and some others).
- spullara 5y agoHow are you measuring popularity?
- vbsteven 5y agoPopularity in this context is my personal experience seeing these tools pop up over and over again in the media that I consume.
- chx 5y agoThis is insanity and hubris. "It's so easy!" yes if you have the language and tools de jour installed and up to date. I want none of that. It was node and npm. Then go. Now Rust and cargo. Oh, I forgot ruby. And all this needs to be up to date or things break. (And if you do update them then things you are actively using will break.) I don't need more tamagochis, in fact the less I have, the better. What happened to .deb and .rpm files? Especially since these days you can have github actions or a gitlab pipeline packaging for you. I can't care less what language you are using, don't try to force it down my throat.
- stevenhuang 5y agoWhy don't you download the native binaries then? Rust isn't an interpreted language, you only need the rust toolchain if you want to build from source.
- wraptile 5y agoSeems like low level programmers finally getting an enjoyable, modern, free language and are getting a bit loose with it!
- Macha 5y agoAlso high level programmers getting something more performant and that doesn't require a runtime but still has a lot of ergonomics they're used to.
- 29athrowaway 5y agoBackwards compatibility can be a heavy burden for a programming language. C++ could be a much simpler, ergonomic language by eliminating features and idioms that are no longer convenient to use. Achieving mastery in C++ requires a lot of work. C++ projects require a coding standard. The decision space you have when working in C++ is much larger than when working with Rust due to the proliferation of language idioms. Rust in the other hand, as a newer language, can benefit from the experiences working with languages such as C++, and provide a better experience right from the beginning. In fact, Rust was created by Mozilla as a response to the shortcomings they perceived in C++.
- pjmlp 5y agoI just hope that Rust with 40 years of backwards compatibility feels better than C++ today.
- pdpi 5y ago40 years is a long time, so the experience will almost certainly degrade a fair bit. The notion of editions in rust makes allowances for breaking changes while still keeping backwards compatibility, I'm very curious to see whether the problems that solves outweigh the complexity in the compiler.
- pjmlp 5y agoI am not convinced that editions are much better than language version switches. They only work in the ideal case that whole dependencies are available as source code, the same compiler is used for the whole compilation process and for light syntactic changes. In fact for IntoIterator, a small fix to the editions was made, https://blog.rust-lang.org/2021/05/11/edition-2021.html https://blog.rust-lang.org/2021/05/11/edition-2021.html With 40 years of history, several Rust compilers in production, corporations shipping binary crates, expect the editions to be as effective as ISO/ECMA language editions.
- steveklabnik 5y ago
- baby 5y agoIt’s the new C/C++ but also you can write Rust like you’re writing Golang.
- junon 5y agoNone of that sounds appealing on its own. Ready for the downvote wave. :D
- pdpi 5y agoThis is a thread about a shell. That’s very much the sort of project that is typically written in C, and also the sort of project that really benefits from being written in something safer. It’s fine if writing systems languages doesn’t appeal to you, but they fulfil an important niche in. V8, Hotspot, Cpython all have to be written in something.
- junon 5y agoYou assumed a lot about me from one sentence. This is why people dislike the rust evangelism.
- kstenerud 5y ago"What have the Romans ever done for us?" https://youtu.be/djZkTnJnLR0?t=56 https://youtu.be/djZkTnJnLR0?t=56
- IshKebab 5y agoIt's a fast compiled language with a great type system and a sane build system. There aren't a lot of alternatives with those properties. I'd say the closest are Go, which doesn't have remotely as good a type system, Typescript which isn't compiled and isn't quite as fast or nice.
- cube2222 5y agoMost of the answers here omit this, and it's a very important point for hobby open source projects - Rust is just very fun to write.
- masklinn 5y ago> Apart from the safety it provides. Sum types (and pattern matching), first-class results, ownership, good performances and a rich ecosystem turn out to be quite nice for a general purpose langage once you’ve passed the hurdle of the borrow checker, even ignoring all the zero-cost abstraction stuff. Also the really solid and safe multithreading. You might struggle a bit getting all your ducks in a row, but past that you’re reasonably safe from all sorts of annoying race conditions. And rayon is… good. Not sufficient for GUI applications where the rust experience remains not great, but for CLI or even TUI? I’ll misquote something i recently saw on Twitter because it’s very much my experience: “and once again I end up riir-ing a one-off tool I wrote in python and wonder why I didn’t just do that from the start”.
- daptaq 5y agoThere must be something else, because most of what Rust brings to the table is what functional languages have been providing for ages, just with rebranded names.
- aethertap 5y agoIn my case, I use it because it is dead simple to get a standalone, lean, fast, native executable (on top of the other functional programming features). Cargo is a huge part of what I love about rust.
- indemnity 5y agoI have a great example. We have 100s of Markdown files. I needed a link checker with some additional validations. Existing tools took 10-20 minutes to run. I cooked up a Rust validator that uses the awesome pulldown-cmark, reqwest and rayon crates. Rayon let me do the CPU bits concurrently, and reqwest with streams made it dead simple to do the 1000s of HTTP requests with a decent level of concurrency. Indicatif gave me awesome console progress bars. And the best part, the CPU bound part runs in 90ms instead of minutes, and the HTTP requests finish in around 40 seconds, primarily limited by how fast the remote servers are over a VPN halfway around the world. No attempt made to optimise, .clone() and .to_owned() all over the place. Not a single crash or threading bug. And it will likely work one year from now too.
- flohofwoe 5y agoMight just be the Baader-Meinhof effect: https://en.wikipedia.org/wiki/Frequency_illusion https://en.wikipedia.org/wiki/Frequency_illusion
- aerique 5y agohype language du jour In the past it has been Lisp, Python, Haskell, Go, etc.
- aerique 5y agoDownvoting me doesn't make it less true.
- Macha 5y agoI write a lot of personal small utilities in Rust these days: The tooling is more modern than C++, it's more consistent cross platform, and it doesn't suffer the VM startup time of Python, which I would have used previously.