What language are the C and C++ standard libraries written in?

alecwhardy picture alecwhardy · Jul 8, 2011 · Viewed 9.9k times · Source

C and C++ by themselves can't actually do anything, they need the libraries to work. So how were the libraries created? Assembly language?

Answer

Jonathan Wood picture Jonathan Wood · Jul 8, 2011

C and C++ libraries are almost universally written in C and C++, as are C and C++ compilers. In fact, many compilers are even used to compile themselves!

How is this possible? Well, obviously the first C compiler couldn't have been initially developed in C. However, once a C compiler exists, then it can be used to compile another compiler. And as a compiler is being developed, so is the source code. It's possible to develop both side-by-side. Since most compilers are improvements on their predecessors, they are often used to compile better versions of themselves!

However, with respect to the library, that's easy: C can actually do something. While some lower-level routines may be written in assembler, the vast majority can be written in C or C++.