Standard library

from Wikipedia, the free encyclopedia

A standard library is a program library that is supplied with the compiler or with the development environment of a programming language .


Almost all common programming languages ​​such as C , C ++ , C # , Java , Object Pascal and Python offer a comprehensive standard library. So if a compiler is to conform to the standards of a programming language, it must also supply the standard libraries.

The background for the concept of the standard library is the abstraction of platform details (e.g. input / output), i.e. increased portability, and the standardized provision of frequently used data structures , algorithms and functionality (e.g. sorting ).

The use of a standard library can also simplify the actual language definition. For example, screen output functions do not need to be defined as new keywords . The orthogonality of the language can also be increased because, for example, functions from the standard library are normal functions, i.e. they can be used in all places where normal functions are permitted (e.g. with function pointers ).

In some programming languages, the use of a standard library enables it to be easily exchanged; for example, either a version optimized for good performance or a version optimized for easier debugging can be used.

For use in embedded systems, for example, large parts of the standard library can often be left out entirely, that is, they are then not integrated into the executable programs generated, which means that the programs generated become smaller and place less demands on their runtime environment . For example, on screenless systems, all screen output functions can usually be omitted without replacement. Programs that run on systems without an operating system (such as simple controls or simple pocket calculators) or those that represent an operating system themselves can also do without the standard library completely. Under these conditions, a high-level language can then also serve as a more convenient replacement for an assembly language . The first operating system written almost entirely in a high-level language, Unix , was e.g. B. only possible through the clear separation of the language core and standard library in the then new programming language C.


A simple console output in C can be implemented on all C-compliant platforms as follows:

#include <stdio.h>
int main (void) {
   printf("Hallo Welt!\n");
   return 0;

The command printf () is part of the C standard library with the header file stdio.h . If you integrate this into your program, you can write your program portable without considering the platform at hand .

In contrast to this, the functions for screen output writeln()in Pascal or printin Python 2 are not part of a standard library, but part of the language definition.