why do header files even exist?

why do header files even exist?

Low Level Learning

8 месяцев назад

340,272 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

bing chilling
bing chilling - 16.09.2023 18:01

idk man

Ответить
Jakob Lindskog
Jakob Lindskog - 26.10.2023 18:15

Ok, so the usp of H files is to... document close sourced binaries? It feels like documentation and housekeeping, more than something we actually need. Sqlite distributes it's clib as a big fat C file... I don't get the point

Ответить
Math Boy
Math Boy - 25.10.2023 18:16

Excellent explanation - thank you.
But (of course there's a but)...
you could improve it by avoiding something. It's something I see all the time, and it kinda drives me nuts because of how small a thing it is for how significant an impact it has on a video. Although not true here, I've seen some comp sci videos rendered basically worthless to me, not worth the bother, because of this one little thing.

When you name things using "code" and "client" and similar comp sci vocab & jargon words, it massively increases the cognitive load to follow what you're doing. I understand that when you're making the presentation, it makes perfect logical sense... here's the part that's code, here's the part that's client, and so forth. But the consequence is that the viewer has to constantly be mentally disentangling the language syntax from your naming choices... and that's a distracting burden when your identifiers are camouflaged as language syntax. If instead of "code" and "client", you'd used - I dunno, "pizza" and "lizard" - then your presentation would've been much easier to follow. (Metaphors can work nicely with this - Lasagna objects living in BakingPan allocations, or whatever. Metaphors are best, but simply not camouflaging the names is the main thing.)

Ответить
theacp127
theacp127 - 25.10.2023 10:30

One thing is that all the code in the header files does get compiled in with the rest of the code which is why really big header files, or source code files with lots of headers take a while to compile since there's a lot of hidden code being analyzed by the compiler.

Ответить
MixeuDev
MixeuDev - 24.10.2023 21:47

which linux distro u use and which ide do u use? thx! <3

Ответить
Maxamillion
Maxamillion - 18.10.2023 03:40

My god I hate stack overflow, you just summed up something I spent hours looking for in 10 minutes. Holy. Fuck.

Ответить
ex21
ex21 - 16.10.2023 04:55

Instead of "why do header files even exist" you explained how header files work, but the question from the title of the video still stands.

You may have noticed that header files are almost exclusive to C/C++ languages, other languages somehow don't need them. So why do header files even exist?

For those wondering, header files exist mostly for historical reasons. Since memory was very limited back when C was developed, compilers couldn't afford to keep track of modules themselves, so it became the job of the programmer. Modern compilers are far less hardware restricted, which allows them to favor developer experience over efficiency.

Ответить
oglop
oglop - 15.10.2023 23:04

Awesome channel, fills in a lot of my knowledge gaps efforlesly!

Ответить
Stef
Stef - 15.10.2023 20:25

Awesome explanation! Thanks!

Ответить
Maiuna
Maiuna - 13.10.2023 12:10

Now I'm, curious, since other languages don't have header files (like Java), how can they expose shared library (if that even exist for a language) APIs without also exposing the implementation details?

Ответить
Lonko
Lonko - 12.10.2023 23:22

love your shirt

Ответить
MTadder
MTadder - 09.10.2023 03:29

What is `catg l`?

Ответить
TRIO
TRIO - 08.10.2023 02:38

Header files smth like a interface, where you declare the function and parameter

Ответить
Berkay Kürkcü
Berkay Kürkcü - 07.10.2023 23:18

Will you consider doing a video about dll files? Back in the days, when I was a little pirate, i used to see them a lot. Still have no complete understanding of them.

Ответить
Colin Maharaj
Colin Maharaj - 07.10.2023 21:43

Header fights create a prototype declaration of the interface to a full actual function.
Only at link time you'd need the code for the function. Ultimately the whole compilation process will be faster, and gives you a full correctness check before linking.

Ответить
Guliver Jham
Guliver Jham - 06.10.2023 23:00

C should generate those on command.

Ответить
kirinsst
kirinsst - 06.10.2023 22:47

Btw, for linker paths in e.g. proprietary programs, patchelf from the NixOS project exists. It lets you change paths to libraries in standard Linux ELF files, which they have to use as that distro doesn't use /usr/lib.

Ответить
AFTERSCHOOL
AFTERSCHOOL - 06.10.2023 18:19

I think header file is also the way to make function implementation private/hidden from the end user

Ответить
Fruits Punch Samurai
Fruits Punch Samurai - 05.10.2023 20:58

Explain about import vs include

Ответить