Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> some old dude who's been doing this for 30 years will still sit in a meeting and tell me that he's been writing pointer arithmetic in deep nested loops for 20 years and it should work fine

Pointer arithmetics in nested loops is just regular C code though, that is perfectly fine. The problem comes when you start to mix C++ datatypes and templates with pointer arithmetics, that is when the footguns becomes completely unmanageable.

However if your team doesn't have other people with experience writing such code then it is best to avoid it anyway, if you decided to not write C style code in C++ then he should respect that. But he is right that it is perfectly fine thing to do, writing C in C++ is basically just C with namespaces and scoping.



Sure, it's doable, but it was in this case the source of the issue, along with some obfuscation of where and when those particular sections of code were being executed through shenanigans with encapsulation and inheritance (I respect people who can manage their pointers well, but I genuinely dislike a lot of OO practices even aside from if they're done "well"). People write exceptional code in C despite and sometimes because of it not protecting you from writing it wrong. I respect the view that some people don't need their programming languages to protect them from these problems. In this case, it helped quite a lot, especially since the application was essentially reimplementing vector processing, getting the memory management wrong, and not doing anything to justify not taking advantage of the insane degree of optimization that's gone into std::vector




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: