Re:DigitalMars C/C++ Compiler
by petre on Wednesday May 23, 2018 @07:58AM
(#17133357)
I did run my own prime number crunching benchmark for fun and D blew Rust away but lagged behind Go. I used mutable Vec and HashSet in Rust, associative arrays and arrays in D, maps and arrays in Go to store the sieves.
[ Parent
| on HN ]
Re:DigitalMars C/C++ Compiler
by dvfjsdhgfv on Wednesday May 23, 2018 @08:52AM
(#17133697)
You see, that's the point - even if you do something as simple, there are many ways to do it (and different compiler versions, especially in the case of D), different optimizations at the code and compiler level and all that - it's practically impossible to have a reliable, comprehensive benchmark.
(That said, D is lightning fast for me!)
Re:DigitalMars C/C++ Compiler
by steveklabnik on Wednesday May 23, 2018 @09:55AM
(#17134183)
HashSet uses a cryptographically secure hashing algorithm by default, itβs gonna be slow.
What's the Rust equivalent of Go maps or D associative arrays then?
Re:DigitalMars C/C++ Compiler
by palmtree3000 on Wednesday May 23, 2018 @12:30PM
(#17135464)
The Rust HashMap and HashSet implementations are generic over hasher: you can pick a faster one if you don't have to worry about getting ddos'd. Last I checked, the go-to fast hasher was fnv: https://doc.servo.org/fnv/
How often do I need to explain that this siphash claim of DDOS protection is utter nonsense. siphash can easily be brute forced like every insecure hash function (<256 bits), and proper DDOS protection can only be provided by a proper collision strategy. Even DJB himself does so.
Well, it's not in the standard lib and I couldn't get my program to compile. Compare that to D or Go, where you don't have to fight the copiler.
Re:DigitalMars C/C++ Compiler
by steveklabnik on Thursday May 24, 2018 @10:40AM
(#17144390)
Rust has a different take on the standard library than many other languages. It's kept quite minimal, because it's trivial to use a package.
Is there any way to use it directly in the source w/o having to create a Crate.toml and src dirs? Is there a getting started document? Dub recently included such a feature.
Re:DigitalMars C/C++ Compiler
by steveklabnik on Thursday May 24, 2018 @11:50AM
(#17145173)
That's the hard way. `cargo new` generates both for you, so you don't need to do any of that stuff manually.
If you really, really want to, you could use https://crates.io/crates/cargo-script to do the way you're talking about.
https://doc.rust-lang.org/cargo/ has installation, getting started, a reference, all of that. It needs some work, but for the basics of doing this, it's got it all.
Re:DigitalMars C/C++ Compiler
by steveklabnik on Wednesday May 23, 2018 @12:56PM
(#17135710)
Yup, this is 100% correct.