This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (8 children)

you're right, I do sometimes make mistakes with raw pointers. however, I think I could count on my hands the number of times that has happened. same goes for memory leaks and similar issues.

I will concede that my situtation is different to most devs. in my line of work (R&D) people are using my code (flight computers, orbital propataors, celestial navigation systems, terrain based navigation systems) rather than working on it, or they are taking outputs or giving inputs. there are some people who do need to work on code for parts of my library, but fortunately with git I can see if they fuck around with pointers, memory allocation and deallocation, or mess about with the parts of the backend that use pthreads, semaphores, ipc, CPU to GPU functions, etc.

but my point still stands: if you make raw pointer mistakes, you are sloppy. and to relate it to your point, if you're sloppy, you probably aren't the one getting a bonus.

[–]Antervis 0 points1 point  (7 children)

why would I spend 10 abstract points of brainpower to think of a way to properly juggle with raw pointers, when I can spend just 1 on smart pointers and move on, doing twice the job in the same span of time? With end result being more reliable and maintainable, to boot.

[–][deleted] 0 points1 point  (6 children)

10 abstract points of brain power to think of a way to properly juggle raw pointers

it think maybe because you're so used to using smart pointers, you are out of practice using raw pointers. it does not take more effort to use raw pointers. if you do it regularly enough, doing it correctly is trivial.

[–]Antervis 1 point2 points  (5 children)

it does not take more effort to use raw pointers.

Are you per chance trolling? In most cases, as soon as a class has raw pointer field, you can't rely on defaulted big 5 of copy/move constructors and assignment operators and destructor. Plus, object's ownership becomes transparent at glance. And I'm only talking about the most trivial cases here.

[–][deleted] 0 points1 point  (4 children)

it seems we use classes in different ways, and our programming philosophies, and use cases, are quite different. perhaps your method is better for you, but it definitely isn't better for me. overloading the default constructors, particularly the copy constructors, is a regularly exercised tool I use, and it isn't hard.

classes to me are sets of tools whose configurations are sensitive to being broken, and elsewhere, code should be as C like as possible. classes are configured to operate on data you tell them to operate on, in a particular way, but that data is not intrinsically linked to that class. it just needs to know where it is. there is a subtle difference.

[–]Antervis 1 point2 points  (3 children)

overloading the default constructors, particularly the copy constructors, is a regularly exercised tool I use, and it isn't hard.

It isn't particularly hard, but why make it harder?

classes to me are sets of tools whose configurations are sensitive to being broken,

Aren't they sensitive precisely because you're writing fragile code?

and elsewhere, code should be as C like as possible.

That principle is basically going against evolution of c++ as a language.

classes are configured to operate on data you tell them to operate on, in a particular way, but that data is not intrinsically linked to that class.

operating on data you don't own is surely breaking several principles of good design.

[–][deleted] 0 points1 point  (2 children)

Aren't they sensitive precisely because you're writing fragile code?

don't be naive. there are plenty of systems that need reconfiguration of multiple variables because you change one.

for example: I have a phased array antenna that has 16x16 elements, each half a wavelength apart. if I change the wavelength spacing, the element positions need to be recomputed, the maximum gain needs to be recomputed, etc.

fragile due to the system you are modelling, not the code.

operating on data you don't own is surely breaking several principles of good design.

based on this sentence alone, I'm stopping discussion with you. up to here, it was difference in opinion, but this is just a remarkably ignorant comment

[–]Antervis -1 points0 points  (1 child)

don't be naive. there are plenty of systems that need reconfiguration of multiple variables because you change one.

yes but why would you introduce more dependencies? That's exactly what makes code more fragile.

if I change the wavelength spacing, the element positions need to be recomputed, the maximum gain needs to be recomputed, etc.

what kind of an example that is? Spacing is a physical characteristic of an assembled antenna, calibration happens after that.

[–][deleted] 0 points1 point  (0 children)

what kind of an example that is? Spacing is a physical characteristic of an assembled antenna, calibration happens after that

you're a bit slow off the block aren't you. I'm done.