r/C_Programming • • Oct 16 '26

Question Why not specifying what to include ?

Hi, sorry if there is English mistake, it's not my first language.

I found online that the #include is replaced by preprocessor by the whole file being included, and I wondered why C isn't made so we can specify only parts of the files to include (like `import { x, y, z } from "file"` in typescript) so the compiled file is lighter ?

20 Upvotes

28 comments sorted by

View all comments

-13

u/kinchkun Oct 16 '26

Because c is a boomer language and doesn't have a module system

7

u/vertigosol Oct 16 '26

Only runs on like 90% of embedded devices worldwide 

0

u/Devatator_ Oct 16 '26

Uh isn't that C++? My Arduino Uno and ESP32 both use C++ and looking around a bit ago it seemed like C++ was far more common for anything embedded

-8

u/kinchkun Oct 16 '26

and?

3

u/vertigosol Oct 16 '26

Shitty resource heavy languages are terrible for real programming on real devices. There is a reason c is still used 

-1

u/kinchkun Oct 16 '26

A module system doesn't make language resource heavy. But compiling the same headers over and over again does make the compilation slower

4

u/Maqi-X Oct 16 '26

No, it isn't. C complication model allows more parallel compilation than many languages with module systems do (for example, rust). In rust you need to split your project into separate crates because modules cannot be compilated simultaneously for whatever reason. Unlike C++, C headers are lightweight and they don't slow down compilation, and if they do you're using them wrong. C has one of the fastest compile times anyway because of how simple language it is.

2

u/tobdomo Oct 16 '26

You can't wait the extra 3 ms it takes to scan and parse a header as opposed to waiting 23 ms it takes to scan the module you want to pull a function from?

8

u/ReallyEvilRob Oct 16 '26

It never needed one.