News for hackers. Stuff that matters.
Re:What it takes to pass a file path to a Windows API in C++ by cerved on Sunday September 24, 2023 @08:47AM (#37632631)
It's not all backwards comparability. I'm willing to bet that some (a large part?) is just sloppy software development.

SQL Server (2017?) breaks if you update it on a UTF-8 Windows because it runs a TSQL that doesn't work with that code page. That script is a mess. Some of it is indented using tabs, some space. Trailing whitespace. Yuck

Re:What it takes to pass a file path to a Windows API in C++ by nikanj on Sunday September 24, 2023 @09:02AM (#37632743)
My hot take: Code quality is not measured by formatting issues, but by error resilience and number of actual bugs.

Much of modern linting and commit hooking is dedicated to checking whitespace placement, variable naming and function lengths but the well-formatted newly rewritten code is still buggy as hell - it just looks pretty

Re:What it takes to pass a file path to a Windows API in C++ by edejong on Sunday September 24, 2023 @09:36AM (#37632989)
Formatting doesn’t remove bugs, but it’ll help you detect them. Linted code helps you scan the code faster and provides valuable pattern recognition, allowing us to detect common mistakes.

There have been numerous bugs caused by incorrect code formatting, most notably an SSL security bug from 2014: https://dwheeler.com/essays/apple-goto-fail.html

Another reason for formatting is the “minimal diff” paradigm. If a formatting rule would not be followed, in the next commit hitting this code, the format would also be affected, causing a larger diff than necessary.

There are other reasons for simple format linting, but the reasons above are the most profound.

Lastly, formatting is part of a range of static code analysis tools. Generally, formatting inconsistencies are the easiest to detect and resolve, as opposed to more sophisticated tools.

Re:What it takes to pass a file path to a Windows API in C++ by lpapez on Sunday September 24, 2023 @09:49AM (#37633088)
True, but personally for me at least it is easier to find bugs in neatly formatted consistent code than something written in multitude of styles.

It is kind of like "pattern matching" on the error patterns.

Re:What it takes to pass a file path to a Windows API in C++ by cerved on Tuesday September 26, 2023 @01:44AM (#37654926)
I've often found that people that don't care about white-space also don't care that much about other aspects of code quality

The inverse may not have the same correlation, since it can be automated.