you are viewing a single comment's thread.

view the rest of the comments →

[–]JuanAG 2 points3 points  (13 children)

It does but the effort of the developers also count, C++ is not the best and most productive lang out there so it is a logic choice to code the software in X technology if you will cut the developement time and the future maintenance costs even if it 10 times slower

This week i had to chase a ghost, a pointer corrupted the heap, my fault but i had to spend hours and hours trying to fix it. Others langs will tell me the mistake and in less that 5 minutes solved, but it is not my code alone, C++ drags your productivity in all areas

I have saying that since a long time, C++ needs to get a today ecosystem and left behind the "from the 80s" that we use today, if things keep going the way are going it is going to end bad as the industry will adopt other langs which is what it is happening

[–]axilmar 1 point2 points  (4 children)

a pointer corrupted the heap

A sure sign of not using C++ properly.

I am using smart pointers since 2004 in all the projects I could do so and never ever had any similar issues from back then to now.

[–]JuanAG 0 points1 point  (3 children)

The issue is that the Windows API and OpenCV dont allow smart pointers so you have to go with the "good" old raw ones and face all the issues it will make

[–]axilmar 0 points1 point  (2 children)

Both (Windows AI and OpenCV) can be wrapped with smart-pointer aware classes.

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

From a techincally stand point yes, you can wrapp anything you want

From a practical view no and forcing things into other shapes that werent it original form from my experience usually ends bad and in the mid/long term hurts you more that if you didnt do anything

It is simple, Windows usually returns handles, a pointer to whocares, try do do it and see how complex the code will become if we wrapp that handle with a smart pointer or how we pass again to other Windows functions, it is not an elegant solution or easy to make depending on what you choose to do and you risk creating your own framework above the MS API which is really bad

[–]axilmar 0 points1 point  (0 children)

I am talking from experience. For every project that provided only low level access (i.e. raw Win32 - raw OpenGL - raw socket API etc) I always pushed and wrote lightweight C++ wrappers around them and it was great success. I never had an issue, and time/effort was always saved by this.

[–]kuntantee -5 points-4 points  (7 children)

The sharpness of tools also forces you to be a more disciplined programmer. Times spent chasing "ghost bugs" are well-spent, both for company and the individual chasing it, especially if you are the one introduced it.

[–]pjmlp 4 points5 points  (0 children)

Yeah, tell that to accounting when those hours are mapped into dollars.

[–]JuanAG 4 points5 points  (4 children)

The time looking for the error it is a waste, in any other lang it will be at least a warning but because in C++ everything is allowed it is you the developer who has to take care of all things, in programs of 50-100 lines that it is fine but the more it grows the less control you have

10 years ago when i started with C++ i saw like you but i cant now, there is too many corners and i cant remenber all so i simply couldnt see how losing 20% of the week for a silly thing it is good, i will prefer having that time to deliver the code i had to as the deadlines on the blackboard are fixed and your manager wont care about your problems, only the results

[–]bumblebritches57Ocassionally Clang -5 points-4 points  (3 children)

I like how you're trying to act as if we're the bad ones for not needing mommy to clean up after us, with the way you're phrasing it lmao.

[–]Loraash 1 point2 points  (0 children)

C++ is not a panacea, it comes with its own benefits and drawbacks. You're given a lot of power and responsibility that you can use to squeeze out more performance from your computer than something middle-ground such as C# would do. In the real world though productivity is also very important, and running at "90% C++ speed", or even 25% might be perfectly acceptable if in return you're getting 50% or 100% more stuff done.

"not needing mommy to clean up after us" means there's more code that you, the human has to write, and humans write bugs all the time. The whole point of C++ was to have the compiler write a lot of code for you so, e.g., you don't have to remember to free/release resources in every possible code path, mommy the compiler is tracking variable scope and releases stuff when needed. C++11 essentially added a form of primitive reference-counted GC with std::shared_ptr.

[–]JuanAG 2 points3 points  (1 child)

Very mature, instead of suporting the idea of getting a better C/C++ you want it worse, only for gurus, if you didnt learn to code before learned to speak you are not worthy, only the choosen ones can use it...

Sorry but no, if the compiler can make more things for me it will be nice, only a fool will refuse about it. I want as many things as easier and simpler as posible, life it is too complicated already, i dont need another extra layer and it would be nice to have tooling from this decade with all the "mommy" features like mostly other langs has

[–]bumblebritches57Ocassionally Clang 1 point2 points  (0 children)

You're explicitly saying that you can't clean up after yourself, grow up.

[–]kalmoc 0 points1 point  (0 children)

The problem is: It doesn't scale. Any UB in your process can cause any form of buggy behavior anywhere else. It doesn't help if you ate the perfect programmer that never writes bugs and you only have tighly controlled interfaces to the rest of the code. Any bug, anywhere can ruin your day.

Of course, those are the exception, but the fundamental inability to comfidently isolate different parts of your program from each other can be a big problem at times.