Search code examples
c#javac++cprogramming-languages

Why there is a convention of declaring default namespace/libraries in any programming language?


Why don't any programming language load the default libraries like stdio.h, iostream.h or using Systemso that there declaration is avoided?

As these namespace/libraries are required in any program, why the compilers expect it to be declared by the user.

Do any programs exist without using namespace/headers? even if yes, whats wrong in loading a harmless default libraries?

I don't mean that .. I am lazy to write a line of code but it makes less sense (as per me) for a compiler to cry for declaration of so called default thingummies ending up in a compilation error.


Solution

  • It's because there are programs which are written without the standard libraries. For example, there are plenty of C programs running on embedded systems that don't provide stdio.h, since it doesn't make any sense on those platforms (in C, such environments are referred to as "freestanding", as opposed to the more usual "hosted").