News for hackers. Stuff that matters.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by teaearlgraycold on Thursday June 02, 2022 @11:40PM (#31604003)
Step one is just clone() everywhere all the time. Then you should cut back AFTER analyzing where all of your memory is being lost to.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by chombier on Friday June 03, 2022 @04:21AM (#31605652)
Can one really escape clone hell afterwards, though?
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by wongarsu on Friday June 03, 2022 @05:22AM (#31606030)
I generally go by the principle to borrow if I can without effort, otherwise I think a second of the code is in the critical path or the object is megabytes in size. If neither is the case, I clone without shame. The remaining 0.1% gets my attention (Arc, lifetime annotations, refactoring, or whatever is appropriate).

The important part is perspective. Nobody cares if you clone your command line arguments ten times during startup. As Dijkstra said, optimize the 2% of your program that matter, keep the rest simple

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by kaba0 on Friday June 03, 2022 @06:41AM (#31606597)
Exactly. Even very experienced people will be easily misled to believe something is performance-sensitive -- computers are ridiculously fast. Like honestly, if it is not a tight loop chances are it seriously doesn't matter what you do. Remember, we write plenty of shell scripts that literally spawn a new process for almost every line, and yet they feel instantaneous.