3 ms·
Rust has an explicit goal of zero-cost abstractions, while Go will allow more expensive abstractions in the service of simplicity.
by random023987 9y ago
Rust has an explicit goal of zero-cost abstractions, while Go will allow more expensive abstractions in the service of simplicity.
- ori_b 9y agoFor the kind of numerical code here, it's not going to be significantly faster.
- bascule 9y agocurve25519-dalek is 3X faster than the equivalent Go code (i.e. in the stdlib, authored by agl). This is for a few reasons: Rust has support for 128-bit integers (i.e. u128) which allows for faster arithmetic when operating on what are effectively multi-u128 bignums in an elliptic curve library. LLVM is generally more sophisticated about optimizations. It wasn't until recently that go had an SSA-based compiler, so its optimizer isn't nearly as sophisticated as LLVM's, which has been developed for many years now.
- pjmlp 9y agoThere is also gccgo, taking advantage of GCC's backend. There is some ongoing work into an LLVM based compiler for Go, and LLVM now has Go as official supported bindings.
- tptacek 9y agoGo can and should fix the integer problem here. George Tankersley had a whole talk at Crypto Village this year about what a nightmare it is to write competitively fast curve code in Go.
- fnord123 9y agoMy information may be out of date, but last time I poked through the Go compiler, it did no vectorization or anything equivalent to march=native. So there's plenty of opportunity for Rust to be faster.
- kmicklas 9y agoGo makes you write complex code so that they can be lazy and have a simple compiler.
- chc 9y agoWhereas Rust makes you write complex code because they put a lot of work into making a sophisticated compiler. It's a strange case of convergent evolution.
- kmicklas 9y agoMore complex code that then actually does the thing you intend it to do rather than having subtle concurrency bugs (among other sorts).
- Ar-Curunir 9y agoRust code I've written has been fairly straightforward, so not sure why you think Rust is complex.