News for hackers. Stuff that matters.
Re:Why Rust is a great choice for startups by eventhorizonpl on Tuesday June 14, 2022 @06:48AM (#31737057)
Do you pine for the nice days of C/C++, when men were men and spend hours on debugging segmentation faults?
Re:Why Rust is a great choice for startups by yakubin on Tuesday June 14, 2022 @08:25AM (#31738206)
The myth of segmentation faults being hard needs to die. A fault is like an exception in Java (or a panic in Rust for that matter), only generated by hardware. It's the best case scenario for your buggy code. It's when you don't get a segfault, but your buggy code keeps chugging along, that's a problem. If after using an out-of-bounds index into an array I get a segfault instead of a memory corruption, I thank god for his mercy. The alternative of the program just continuing execution is horrible.
Re:Why Rust is a great choice for startups by klodolph on Tuesday June 14, 2022 @10:00AM (#31739621)
Segfault is only best-case scenario if it happens at the location with the bug.

It is extremely common to start diagnosing a segfault and find that the location of the segfault, in code, is unrelated to the code which caused the segfault.

Re:Why Rust is a great choice for startups by yakubin on Tuesday June 14, 2022 @10:04AM (#31739675)
Agreed.
Re:Why Rust is a great choice for startups by Kon-Peki on Tuesday June 14, 2022 @11:28AM (#31740906)
My experience (15+ years of debugging legacy C code) is that if the segfault is repeatable - as in you can make it happen in the same place over and over again - the fact that the error is somewhere else only makes things marginally more difficult. Even the old-fashioned debuggers can monitor memory locations for changes, and if that doesn't work you can set breakpoints in various locations and manually check memory for corruption - it can really narrow down the possibilities.

I always enjoyed the mystery. It's a puzzle with an as-yet unknown solution. How can you not love it?

Re:Why Rust is a great choice for startups by yakubin on Tuesday June 14, 2022 @11:38AM (#31741073)
In cases when I have a working visual debugger, I agree, it's fun. Without one, it's not fun.
Re:Why Rust is a great choice for startups by Kon-Peki on Tuesday June 14, 2022 @12:04PM (#31741411)
Oh yes, for sure. Visual debuggers make things so much easier! It might be worth pointing out that visual debuggers have been around for well over 30 years at this point.
Re:Why Rust is a great choice for startups by jcelerier on Tuesday June 14, 2022 @12:01PM (#31741359)
when do you not have one ? as soon as you have a mere hint of gdb / gdbserver possible you can debug in a GUI such as Qt Creator's
Re:Why Rust is a great choice for startups by klodolph on Tuesday June 14, 2022 @12:42PM (#31742055)
A couple situations.

Sometimes you can end up in a pickle because the embedded system you’re working with just doesn’t have a good debugger available, or it may be cumbersome to set up.

Sometimes the segfault happens in a production environment and you just can’t hook up a visual debugger to the ten different instances of the server you’re running.

I agree that a segfault is a fun error to try and diagnose because it really exercises your gray matter. But it’s not my job to diagnose segfaults, it’s my job to keep the service running up to some certain standard, and if I find myself diagnosing lots of segfaults, there is usually something else I could be doing involving instrumentation or testing to address those defects which is more boring but more productive :-)

Re:Why Rust is a great choice for startups by kaba0 on Tuesday June 14, 2022 @09:46AM (#31739439)
Depends, if it happens in prod, you are **
Re:Why Rust is a great choice for startups by yakubin on Tuesday June 14, 2022 @10:02AM (#31739644)
If it doesn't happen in prod, you are even more **. Cue password leaks, privilege escalation etc.
Re:Why Rust is a great choice for startups by kaba0 on Tuesday June 14, 2022 @10:05AM (#31739695)
Fair enough.
Re:Why Rust is a great choice for startups by farseer on Tuesday June 14, 2022 @07:22AM (#31737428)
Sticking to STL in C++ and avoiding pointers unless really necessary will significantly cut down on segmentation faults.
Re:Why Rust is a great choice for startups by ncmncm on Tuesday June 14, 2022 @07:28AM (#31737501)
It has been many years since I spent "hours debugging" a segfault. But I use C++, not C.

(That said, I coded C from 2008 to 2012, and spent no hours on segfaults then, either.)

Re:Why Rust is a great choice for startups by mbrodersen on Tuesday June 14, 2022 @09:09PM (#31747999)
I am a professional C++ programmer and I can’t even remember the last time I had a segfault. I also haven’t had a bug in production the last 5 years. But YMMV of course.
Re:Why Rust is a great choice for startups by p0nce on Tuesday June 14, 2022 @08:58AM (#31738711)
This is quite rare in C++ since C++11.
Re:Why Rust is a great choice for startups by papito on Tuesday June 14, 2022 @08:11AM (#31737987)
Well, because geniuses who were too smart for their own good turned every problem into an academic exercise, writing "elegant" code using the darkest corners of the vast language that is C++. And then we hate the language and not these characters.

Scala has the same problem. Stop writing your own DSLs!

Re:Why Rust is a great choice for startups by jcelerier on Tuesday June 14, 2022 @12:02PM (#31741367)
> Stop writing your own DSLs!

100% disagree. Writing custom DSLs is how you get the best programs.