3 ms·
What would be accidentally complex about Rust? Sure, if you don't provide the static guarantees that Rust does (and only Rust provides AFAIK), you can be a lot
by eklavya 6y ago
What would be accidentally complex about Rust? Sure, if you don't provide the static guarantees that Rust does (and only Rust provides AFAIK), you can be a lot simpler :)
The more I use Rust the more I am convinced I can write high level performant code. I mean it's ridiculous that sometimes I forget I am writing Rust and not Scala!!
- friend-monoid 6y agoTry compiling a program with nostd and nocore - try targeting a weird platform, like a small embedded device. You immediately find out how many hidden layers there are to Rust, it’s borderline annoying. Rust is an amazing language, but stuff like mem transmute and I don’t know - it’s been a while now - just trips you up. It’s possible that I just don’t “get” rust, but maybe that’s also the problem. Zig is so easy it’s hard to get wrong. Zig favours readability and understandability over everything else. I can easily grasp complex questions like “will this overflow my very limited call stack” in Zig - it’s harder in Rust (for me anyway).
- deleted 6y ago[deleted]
- pron 6y agoRust, like C++ if not more, elevates certain technical details like lifetime, static vs. dynamic dispatch, partial evaluation, and sequential composition ("default" vs. async) to multiple layers of syntactic constructs (types, generics, macros). That focuses the language on accidental complexity, although some people do find that C++ design philosophy appealing (I would expect some high correlation between people who like Scala and people who like Rust as I would between those who don't like either). Of course, it's a matter of personal aesthetics, but I think that style is misapplied for low-level domains, putting a lot of effort into a veneer of high abstraction without actually providing it (you still have to think about these aspects, as you do in all low-level languages, and, much more importantly, it still requires changing client code when details change, as in all low-level languages -- i.e. changing a Rust program is not like changing a Scala program), doing, IMO, more harm than good. As someone who does a lot of low-level development, before Zig I didn't think any approach other than that of C or that of C++ was even possible. I don't know if Zig will fulfil its promise, but its radical design, that's unlike anything we've ever seen, sure offers a fresh perspective on things. As to static guarantees -- they are never the point; they are a means to an end: writing more correct programs. That goal is just as valued by Zig as it is by Rust, Zig just tries to achieve it differently. Which achieves it better? It's hard to know right now. I have little doubt that Rust could make things that are today written in C++ safer, but I have serious doubts whether it would be adopted in truly safety-critical domains, where C is king. I think Zig could be.
- eklavya 6y agoThanks for your insights in the matter. I have tried writing a VM with Rust (crafting interpreters) but outside of that I don't have a lot of low level experience with it. I am also in the minority that believes Scala codebases are simpler than all the Java codebases I have come across. Maybe it's just me :D I didn't know Zig can provide memory safety using it's features. If that's the case it's great, I need to try it out! Although I am sceptical about the claim that in truly safety-critical domains Rust would not be adopted where Zig would, but I am again out of my depth here, so :)
- pron 6y ago> I didn't know Zig can provide memory safety using it's features. Yes, although this is done through runtime checks (that can be optionally disabled) rather than through static sound guarantees (Rust uses runtime checks in some cases, too). The language's simplicity and fast compilation helps with other types of correctness, too (i.e. beyond memory safety). > Although I am sceptical about the claim that in truly safety-critical domains Rust would not be adopted where Zig would I don't know if Zig would, but Rust has several problems for such domains that C and Zig don't: porting it is a challenge (both Rust itself and LLVM are very complex), understanding what a program does is a challenge (a lot of implicit behaviour), and handling allocation failures is a challenge.
- pjmlp 6y agoHopefully during 2021, LLVM won't be any longer the only option to compile Rust, as the work for integrating cranelift backend into stable keeps going on. Zig also has the same issue with LLVM until the language is fully bootstraped and the original LLVM based compiler no longer part of the build process. However, packaging a C and C++ compiler alongside for the ride doesn't make it that much simpler.
- pron 6y ago> LLVM won't be any longer the only option to compile Rust, as the work for integrating cranelift backend into stable keeps going on. That might not matter. Porting Rust might not be a simple undertaking, either. > Zig also has the same issue with LLVM until the language is fully bootstraped and the original LLVM based compiler no longer part of the build process. Yes, but that's expected to happen before 1.0. > However, packaging a C and C++ compiler alongside for the ride doesn't make it that much simpler. C isn't an issue at all; C++ is. I'm pretty sure it could be made optional.
- DixieDev 6y agoI like Rust for the reason you've stated, but it is absolutely both complex and full of potential for implicit behaviour. `Copy`, `Deref`, and `Drop` traits immediately spring to mind, but there are also weirdly specific things like having `no_mangle` and `static` on a global variable when targeting WASM implicitly exports (the address/offset of) the variable for use on the JS side. Procedural macros are also somewhat insane in many ways.