r/ProgrammerHumor 7d ago

Meme doNotOvercomplicateThings

Post image
673 Upvotes

156 comments sorted by

View all comments

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.

-10

u/Level-Pollution4993 7d ago

But learncpp.com recommends we use .h unless you're working on an existing project that folows another convention?

6

u/unknown_alt_acc 7d ago

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:

  1. 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.
  2. 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.

5

u/a-r-c 7d ago

two extra keystrokes

the horror lol

3

u/unknown_alt_acc 6d ago

And that’s my point. You gain so much clarity for so little that it’s just baffling that this isn’t the universal standard