0

I've been coding in C++ professionally for six odd years, and it's my go-to language for performance-critical projects. When working to a deadline, the scope expands to fill the time available. Without that deadline, such as in personal learning projects, the scope exponentially grows until I'm exhausted. I start wanting to program a quick and dirty visualised physics simulation using CUDA and OpenGL, and then find myself writing an allocator to get the memory management just right. I know I've gone too far when I find myself needing a virtual template.

I know there are a couple of personal biases exacerbating the problem; such as an unwillingness to adopt an entire library for a couple of useful functions, and an unreasonable aversion to boilerplate code. But I'm also wondering if C++ is part of the problem. There's the ever-growing feature set, the complicated way those features need to interact to implement particular patterns, the error messages, and even organisation of the source files.

Does anyone with experience of C++ and other performance-focused/compiled languages agree C++ makes things complicated and maybe recommend alternatives? I'm hoping there's something out there that shares Python's "There should be one, and preferably only one, obvious way to do things." Or does working with C++ necessitate some degree of project management.

1
  • As this is currently phrased, I'm not sure this is a project management question. To make it a project management, please revise the question to scope management and away from the tool (C++). Commented Jun 14, 2018 at 14:03

2 Answers 2

5

Does anyone with experience of C++ and other performance-focused/compiled languages agree C++ makes things complicated and maybe recommend alternatives?

I've been programming in C++ professionally for 25 years and don't see this problem at all. I can write a small, self-contained application quickly without it growing to ridiculous sizes or expanding in scope at all. But in order to do that, I have to exercise some discipline. While I might get ideas for a million possible features, I usually write them down for later. I don't usually dive into them until I've got the base functionality fully working and mostly debugged. When I do dive in, I pick one thing and add it. I also look at the group of features and think about what sort of architecture might be needed to support all that. I try to avoid just pumping out code to get a feature working because that usually leaves me with an unmaintainable mess.

I start wanting to program a quick and dirty visualised physics simulation using CUDA and OpenGL

OpenGL is certainly dirty, but it's almost never quick due to the amount of boilerplate code it takes just to put a single poly on the screen.

...there are ... biases exacerbating the problem; such as...an unreasonable aversion to boilerplate code.

One solution is to use a library that hides most of the boilerplate for you, like Unity or Unreal Engine, or even something simpler like SDL. Another solution is to scale back. Why use CUDA? Does the first version need to use it, or could you do a CPU version to get it up and running, and later replace it with something using CUDA, OpenCL, or some other technology? If you're careful about how you separate out the various tasks your application needs, it's easier to replace a single piece later without touching anything else.

One thing that has helped me get better at keeping projects in check is refactoring existing code I have, and doing code reviews on Code Review Stack Exchange. The more code I refactor and review, the better my first passes at writing code get, and the fewer problems my code has down the line.

3

C++ provides you with more freedom as Java for sure -- you can work with memory directly and all that stuff :)

But problem of overengineering doesn't depend on the language you use very much. You should just find a way not to do that. Try this article: "Ways to prevent over-engineering?"

Also, I propose you to look at Pomodoro techniques -- maybe more disciplined approach to your time management and chance to step back every 25 minutes can help :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.