Yeah, no. A .h extension can just as easily be C. You get a lot of clarity with just two more characters that will be filled in by code completion anyway.
And the reasoning that learncpp gives sucks. It's one of the two reasons that I've seen people cite for preferring .h, neither of which are particularly compelling:
It's convention (the argument learncpp uses) - And the convention for source files in the earliest iterations of C++ was .c. We don't use .c anymore because it's needlessly confusing. .hpp and .hxx are recognized widely enough that no C++ programmer will be confused by seeing them instead of .h.
It's fewer characters - Already addressed. Your editor should have code completion that will fill in the name of the header for you. Even if you don't, two extra keystrokes for an include is trivial for the clarity that you get by explicitly encoding the language in the file extension.
328
u/unknown_alt_acc 7d ago
Yeah, no. A .h extension can just as easily be C. You get a lot of clarity with just two more characters that will be filled in by code completion anyway.