Hacker News new | ask | show | jobs
by jbandela1 689 days ago
The code presented has problems, but they are not the problems the author thinks it is.

The code is listed as c++. However, it is using a style that will result in problems.

First thing that jumped out at me is using const char* for strings. Using this muddies ownership and doesn’t store the length of the buffer which can result in all sorts of fun. Add to that that many times paths are formed by string concatenation, and it is looking like a code smell.

Second, there is no RAII and just manual management of resources.

These problems are far more likely to cause issues that the use of type deduction which by now has pretty good tooling support and is used successfully in many languages. Of course, not using RAII, using raw pointers make it tricky, but you shouldn’t be using those like that anyway.