6 Comments
User's avatar
⭠ Return to thread
Peaceful Dave's avatar

C is the brown paper bag language for many, including me. With it you can do anything, but you also must do everything - garbage collection. Memory leaks can be disastrous. One of my mentors, when auditing code searched for mallocs and their associated free up of memory first - more important than algorithm elegance. Given the nature of the code I wrote for testing electronic hardware, readability and the ability to explain it to the hardware design and system engineers was more important than elegance for elegance's sake when it obfuscated the purpose.

I don't know about Microsoft, but lice comb code reviews are rare. Flight safety demanded a thorough review of my code when the hardware and system engineers were struggling for something to charge time to and had more time than normal and they all piled on. Project Management (purse string keepers) crapped in their pants when the charges rolled in. I'm thinking that might have something to do with Microsoft pushing weekly system updates on users. I was always happy to have my work reviewed.

For one project they imposed ADA, a strongly typed 1000 line "hello world" language. That never happened again.

Now that I've retired my home utility programming (quick hacks) is often in python which does cleanup for me or spreadsheets when they will serve the purpose.

Expand full comment
Chris Fox's avatar

Code reviews are like threat models or unit tests: checking a box. People come to the meeting straight from the printer and are seeing the code for the first time. They quibble

over formatting and consistency.

I usually worked on servers where memory was allocated in processing a request, so each time one came in I created a custom heap, did all my allocation for the request out of it, then freed the entire heap at the end without bothering freeing the individual allocations.

I started with servers that had to be restarted every four hours to recapture leaked memory and turned out servers that never leaked a single byte.

It takes a long time to write a big project in C but at least you can see everything but the stack operations, right in front of you. The JavaScript I am working on now bears no discernible relation to the page it implements, I can't even find where a checkbox or a button is coded. I hate browser work.

Expand full comment
Peaceful Dave's avatar

An interesting and strong solution, put the allocations in a big allocation.

When people are already working ridiculous hours to meet their schedule, expecting real code reviews is nonsense. Sadly, the best code reviews that I did was tasked with resolving problems in someone's released code where I was not punished for spending time on it. Justification for your quest to fix software development.

Expand full comment
Chris Fox's avatar

I review every commit unless the project is simply too vast. I used a tool called GitKraken that is simply superb. Sometimes I even download the branch and run the changes through a debugger but usually I can just eyeball it and catch bugs.

I bet I was the only one on the MS campus who knew about the Heap API. Everyone else just used alloc and free.

Expand full comment
Peaceful Dave's avatar

I didn't know about it either.

Expand full comment
Chris Fox's avatar

Part of the C/C++ Win32/Win64 API.

HHEAP HeapCreate,

HeapFree,

HeapAlloc,

HeapDestroy

It allocates in pages, usually 4K, and releases the entire page set with that last call, and everything allocated with it. It would take an effort to leak memory.

Expand full comment