3 ms·
You seem to be missing the forest for the trees. > I don't think you have much experience with C++ if you're unaware how much harder debugging a segfault is th
by _gabe_ 4y ago
You seem to be missing the forest for the trees.
> I don't think you have much experience with C++ if you're unaware how much harder debugging a segfault is than an undefined.
I love how developer's go to argument is, "you must not be very experienced if you've never encountered X". It's gatekeepy and gross. I have had plenty of experience with C++, including maintaining a large corporate application in C++ professionally. I have had nasty segfaults. Remember, I was qualifying my statements with how "I program in C++ as a hobby" these days, which means I have complete control over how much unsafe C++ code I allow in my codebase. It turns out you can avoid most segfaults using a little forethought and planning, like I said.
> Have you worked on large codebases with hundreds of developers?
Yes, and it's gross. I worked on a 20 year old legacy C++ application that dealt with high frequency trading at my old job. It was nasty and there were several problems including a very large memory leak that was untraceable. You seem to have missed what I said, which was "but that doesn't mean a good developer can't avoid a lot of memory related footguns with a bit of forethought and planning". Key words, "a good _developer_". Once you throw in hundreds of developers into the mix all bets are off, and that's not the claim I was making.
If you're dealing with a system that you know inside and out, it is usually a very simple matter to trace a segfault. There are a lot of things that you can do to avoid untraceable segfaults, some of which you've alluded to. Use modern C++ safety constructs, things like `vector.at(i)` instead of `vector[i]` if you don't know if `i` is going to be in bounds. That is what I'm alluding too. If a solo developer codes with some simple forethought and planning, segfaults are not a big deal.
JavaScript undefined objects can be just as difficult to trace, under the assumption that you're a solo developer in C++ using good practices. Yes you can place breakpoints and try to figure out where the error occurs. You can do the same thing with a C++ segfault. The hard part is figuring out where the error occurs, which I believe we agree on. I know what you're saying about a segfault occuring at random times, but for the hundredth time, if you're following good practices, segfaults can be as predictable as a JavaScript undefined object. There's a qualification there, which is if you're following best practices.
Anyways, I hope you have a good day :). My intent is not to have an argument over an inconsequential problem, so I'm done replying. I hope I've made myself clear, I'm not trying to argue that C++ is better, or that segfaults are the same exact thing as JavaScript undefined objects. All I'm saying is that both are difficult things to debug, and if you're coding by yourself, you can use a few safety features (using built-in constructs, handrolled tools, or third party apps, I don't care what you use) to make a segfault no worse than a JS undefined object.
- deltaonefour 4y ago>I love how developer's go to argument is, "you must not be very experienced if you've never encountered X". It's gatekeepy and gross. Ignore it then. I'm wrong. You honestly seem like you don't have much based off of what you're telling me about segfaults. >It turns out you can avoid most segfaults using a little forethought and planning, like I said. Just "avoid them" lol is what you're saying. That's how I program. Avoid all errors and bugs with a little planning and forethought so my programs are 100% bug and error free. That's how you do it. Again I don't think you worked for a large corporate application if you think forethought and planning are all it takes to avoid a segfault or memory leak. With enough people and libraries and dependencies in the codebase statistically it inevitably gets introduced. The only time it absolutely never gets introduced is if the language doesn't even have that class of errors. >Yes, and it's gross. I worked on a 20 year old legacy C++ application that dealt with high frequency trading at my old job. It was nasty and there were several problems including a very large memory leak that was untraceable. You seem to have missed what I said, which was "but that doesn't mean a good developer can't avoid a lot of memory related footguns with a bit of forethought and planning". Key words, "a good _developer_". Once you throw in hundreds of developers into the mix all bets are off, and that's not the claim I was making. Why make this claim at all? My point is C++ is less safe then python. Your attitude made it seem like your countering my claim but really you're just going off on a tangent on how good developers make a language safer? Why? Off topic. I mean the way you put it, we're basically in agreement. C++ is less safe then python and you need "good developers" in order to make it safe. Yet despite this agreement your attitude is passively hostile especially near the end where you just say you're "done replying" lol. I think what's going on here is you're changing the goal posts. >If you're dealing with a system that you know inside and out, it is usually a very simple matter to trace a segfault. How is this even relevant? When is a code base so simple that you know it inside and out? Have you seriously been dealing with C++ outside of your hobby projects? >You can do the same thing with a C++ segfault. No you can't. There's no data to follow backwards from the segfault. The segfault can even occur in a library you don't have source code for and it's very hard to trace this without external tooling. For javascript you just trace the path of the undefined variable. That's it. You don't even technically need a debugger for this. Are you sure you worked with C++ in a large code base? Because what I stated above is somewhat definitive. >Anyways, I hope you have a good day :). My intent is not to have an argument over an inconsequential problem, so I'm done replying. No man. This is a cop out. I'm open to being convinced but you know your arguments are reaching dead ends you're going off on strange tangents just to try to stay afloat. So you act polite and pretend you're too above it all. Come on man that's weak. It is literally definitive that an undefined is easier to trace then a segfault. There's no leeway or opinion here yet you have inserted so much off topic and questionable stuff that I'm not sure if you're even being honest.