|
Good morning CodeProject!
I’ve decided to teach myself something new - apparently it’s important for older people to do that to stop them going mental. So behind the back of my loving, dependable and reliable C# I’ve been having a risqué affair with Rust. Turns out that developing in Rust is about 30% expressing your intention in code and 70% arguing with a bad-tempered bureaucratic compiler for who simply nothing seems good enough.
I decided my first project would be a Suduko solver, which is done and it works, but there was an interesting point in the development where different runs would dish out differing results. I was using a HashSet internally, and like in .NET you shouldn’t make any assumptions about the order of the items if you iterate over it. Fair enough, but I would expect it to be consistent in that ordering between say releases of the .NET framework.
Not so in Rust. Here’s a Rust program:
use std::collections::HashSet;
fn main() {
let mut set = HashSet::new();
for n in 0..5 {
set.insert(n);
}
for n in set {
println!("{}", n);
}
}
And here’s the output from running it twice:
0
3
2
1
4
and
0
2
1
3
4
Interesting huh? Something non-deterministic is going on. I haven’t debugged the HashSet yet to find out, but I’m presuming it’s using some random number or aspect of time somehow. I spoke with 'Gemini' about it yesterday and it agreed it's interesting, so thought I'd share it.
Regards,
Rob Philpott.
|
|
|
|
|
Interesting indeed. My guess is that the Rust folks will say that that behaviour is by design, to stop you relying on assumptions about implementation details.
In other words to encourage (probably can't go as far as 'enforce') robust algorithms.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
You know, I hadn't thought of that. By design, so that weirdness comes out early rather than later. Sounds like something the Rust brigade would do - good thinking!
Regards,
Rob Philpott.
|
|
|
|
|
Rob Philpott wrote: apparently it’s important for older people to do that to stop them going mental
Using Rust to de-rust your mind.
|
|
|
|
|
Rob Philpott wrote: Something non-deterministic is going on. I haven’t debugged the HashSet yet to find out, but I’m presuming it’s using some random number or aspect of time somehow.
According to the docs[^], this is done to prevent HashDoS[^] attacks.
|
|
|
|
|
Aha! I should, perhaps, read the documentation sometimes, what with it being the first sentence and that.
The crazy lengths we are forced to go to stop mitigate people attacking our software...
Regards,
Rob Philpott.
|
|
|
|
|
He looked at my license and said "you're supposed to be wearing glasses."
I said I have contacts.
He said he didn't care who I know.
I'll get my coat.
|
|
|
|
|
I also got pulled over and he asked me if I had any ID.
I said about what?
"Ten men in the country could buy the world and ten million can’t buy enough to eat." Will Rogers
PartsBin an Electronics Part Organizer - Release Version 1.3.1 JaxCoder.com
Latest Article: EventAggregator
|
|
|
|
|
Just heard the news that some guy was stealing wheels off of police cars.
The police are working tirelessly to catch him.
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
They can't prove a thing.
"Ten men in the country could buy the world and ten million can’t buy enough to eat." Will Rogers
PartsBin an Electronics Part Organizer - Release Version 1.3.1 JaxCoder.com
Latest Article: EventAggregator
|
|
|
|
|
And someone stole all the toilets from the stalls at the police station.
They're investigating, but so far they have nothing to go on.
|
|
|
|
|
good one.
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
Did you hear about the escaped convicts hiding in a stolen cement truck?
Be on the lookout for 2 harden criminals.
"A little time, a little trouble, your better day"
Badfinger
modified 29-Feb-24 22:50pm.
|
|
|
|
|
The "new Outlook" desktop application has registered itself with Windows as a handler for opening .msg files.
If you try to use it, you get a nice big window telling you:
Quote: This action isn't supported yet
The New Outlook for Windows doesn't currently support this action. You can switch back to Classic Outlook for Windows and try again.
So why register as a handler for a file you can't display?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I hate Outlook
I have always hated Outlook
I always will hate Outlook
Ok, I have had my coffee, so you can all come out now!
|
|
|
|
|
To mis-quote Kirk:
"I've never trusted Outlook, and I never will.
I can never forgive them for the death of my productivity."
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
The new coders have yet to learn how to port the code from the classic to the new one.Maybe after 10 year of collecting paychecks they will add that hopefully.
Caveat Emptor.
"Progress doesn't come from early risers – progress is made by lazy men looking for easier ways to do things." Lazarus Long
|
|
|
|
|
Wordle 984 3/6
⬛⬛⬛🟨🟨
🟩🟩⬛⬛⬛
🟩🟩🟩🟩🟩
|
|
|
|
|
You could (should) have posted this as a reply in the thread 4 below.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
This must be Thursday. I never could get the hang of Thursdays.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Wordle 985 4/6*
🟨⬛⬛⬛🟩
⬛⬛🟩⬛🟩
🟨⬛🟩⬛🟩
🟩🟩🟩🟩🟩
|
|
|
|
|
Wordle 985 4/6
🟨⬜🟨🟨⬜
⬜🟨⬜⬜🟨
🟩⬜🟩⬜🟩
🟩🟩🟩🟩🟩
|
|
|
|
|
Wordle 985 2/6
⬜🟨🟨⬜🟩
🟩🟩🟩🟩🟩
|
|
|
|
|
Wordle 985 4/6
⬜⬜🟩⬜🟩
⬜⬜🟩⬜🟩
⬜⬜🟩⬜🟩
🟩🟩🟩🟩🟩
|
|
|
|