News for hackers. Stuff that matters.
Re:Never trust a programmer who says they know C++ by cm277 on Monday June 05, 2023 @05:34AM (#36194182)
I once worked with a true 10x programmer. The guy used C++ metaprogramming to avoid boiler-plate code. Any by "used" I mean he needed the best preprocessors and compilers at the time to just write his code. He once single-handedly porting our >1m LOC codebase to Java over a weekend (admittedly, a 3-day weekend, but still).

When new people asked him if he knew C++ his standard answer was "I know enough to know I don't know C++".

Re:Never trust a programmer who says they know C++ by ZephyrBlu on Monday June 05, 2023 @05:46AM (#36194236)
> He once single-handedly porting our >1m LOC codebase to Java over a weekend

How do you even physically do that?

Generous estimate:

    1M LOC
    18hr days * 3 = 54hrs
    1,000,000 / 54 ~ 18,500 LOC/hr
There must have been a lot of help from automation here or you had an enormous amount of boilerplate code, because otherwise I don't understand how this is even possible.
Re:Never trust a programmer who says they know C++ by flohofwoe on Monday June 05, 2023 @05:48AM (#36194248)
IME a lot of real-world 'enterprise quality' million-line code bases only have a few thousand lines of actual functionality in them - if at all (take a typical Java or Java-style C++ class which is mostly constructors, setters and getters, and maybe a single method that actually does something).

Then replace some large modules with existing 3rd party libraries, and the whole feat sounds a lot more believable.

Re:Never trust a programmer who says they know C++ by cocochanel on Monday June 05, 2023 @05:54AM (#36194295)
Funny that a language sounds like a big company where only a small percentage of people do most of the work.
Re:Never trust a programmer who says they know C++ by yvdriess on Monday June 05, 2023 @06:20AM (#36194471)
That's why it's an Enterprise programming language.
Re:Never trust a programmer who says they know C++ by aeternum on Monday June 05, 2023 @11:33AM (#36197759)
Back in the day that those codebases were written, the 3rd party libraries did not exist or they were GPL. Everyone actually had to reimplement a linked-list library or macros in C. Nowadays you should probably fire anyone attempting to do that inhouse.
Re:Never trust a programmer who says they know C++ by ricardobeat on Monday June 05, 2023 @05:52AM (#36194285)
When doing a major rewrite like that, you’ll often end up with significantly less lines of code, maybe 1/4 of the original. Even if rewriting in the same language.

This is the result of both being able to cleanup & simplify, as well as completely ignoring edge cases and regressions :)

Re:Never trust a programmer who says they know C++ by rgbgraph on Monday June 05, 2023 @05:58AM (#36194323)
- Java is majorly boilerplate.

- If you map out the entire system, and understand how all the pieces fit together, you can: make something simpler that fulfills reqs/does the same exact thing; use template metaprogramming to generate the source code for you, instead of writing it by hand

The only issue is very few people will have the skills or the patience to sit down and try to understand metaprogramming. So you won't be able to take advantage of it in most business use-cases (i.e. won't easily be able to find another cog to work on it), despite how powerful it is.

It's like why more people don't work with K (or functional langs, etc.): it's not a simple procedural or OO language, so it's harder to learn -- and harder to get started with.

Re:Never trust a programmer who says they know C++ by rtheunissen on Monday June 05, 2023 @05:51AM (#36194275)
A very consistent codebase makes it possible to do things like this, using automatic refactoring and very smart find/replace, but such codebases are few and far between.
Re:Never trust a programmer who says they know C++ by cm277 on Monday June 05, 2023 @07:46AM (#36194990)
Yeah, I asked him; the answer was emacs (and a lot of macros). He automated the translation (from pre-processed code) and then hand-crafted the rest.
Re:Never trust a programmer who says they know C++ by hedora on Monday June 05, 2023 @12:34PM (#36198851)
I've reduced codebases by more than 100x, and simultaneously closed out 90+% of bugs, and added many orders of magnitude in performance.

It is far less impressive than it sounds, because it relies on having an unimaginably bad starting point.

I guarantee you that the starting point for this story was a pile of copy-pasted classes, each of which had some minor tweak, and that the program exposed some combinatorially large number of similar flows. When a bug was fixed, it would need to be manually applied to dozens of classes, and this did not happen, so each of the copy-pasted classes diverged and replicated functionality.

The output of the weekend was almost certainly a simple set of software layers, each with a clean mathematical abstraction, and the composition of the layers expressed all possible flows from the legacy system.

The best example of this I've heard of was with inkjet printer drivers from HP. They used to fork their entire driver stack, including font rendering and dithering, for each printer they released. They produced dozens of models per year. Then they assigned 5-10 full time engineers to maintain each fork of the driver.

After the open source people had already done it with reverse engineered stacks, someone at HP wrote a unified driver framework where the only model-specific stuff was parameterized inputs to the ditherer (DPI, etc) or the actual wire protocol over USB to send the list of dots to put on the paper.

They ended up replacing something like 10,000 engineers with a dozen people or so, and printout quality increased dramatically (though I doubt it was as good as the open source stacks).

Re:Never trust a programmer who says they know C++ by hliyan on Monday June 05, 2023 @10:43AM (#36196846)
I once wrote a Perl translator to translate a codebase from a custom business rule language into C++. Not my proudest moment: rather than using a parser, I just tokenised and processed the code line-by-line. It worked.