-1

Which is the relationship between the standard libraries of C language and the standard libraries of other software platforms, e.g. Java, .NET, Python? Do the Java (.NET and Python) standard libraries use the C standard libraries for making system calls, or in other words, is the C standard library the only place in a Windows/Linux system that actually makes the system calls?

  • 1
    While the answers correctly point out that you should separate the standard library from its implementations, it is the case that most implementations are built on top of the C standard library or operating-system specific interfaces (like POSIX or Win32). The most notable exception is the Golang reference implementation which uses its own syscall interface. – amon Feb 24 at 12:21
9

Which is the relationship between the standard libraries of C language and the standard libraries of other software platforms, e.g. Java, .NET, Python?

There is no relationship.

Some library designers may or may not decide to take inspiration from the design of the C library when designing their own libraries, but this is a conscious decision by the library designer and not some general, automatic relationship. For example, Ruby was designed (among other things) as a scripting language for Unix systems, and thus large parts of the IO, File, and Process libraries are deliberately designed to be close to the C and POSIX standard libraries, even down to the names.

Also, in some cases, it just happens that two library designers trying to solve the same problem end up with similar designs.

Do the Java (.NET and Python) standard libraries use the C standard libraries for making system calls,

No. The standard library of a language or platform is a specification. It is a piece of paper. It is not a piece of software. It doesn't "use the C standard libraries for making system calls", it doesn't make any calls at all, since it is not software.

or in other words, is the C standard library the only place in a Windows/Linux system that actually makes the system calls?

It might be, it might be not. It certainly doesn't have to be.

There are plenty of tools written in assembly language, for example, that perform system calls directly. (This might have been more popular in the past, but it is certainly still done.)

I believe you are confusing the standard library of a language or platform, which is a set of specifications, with a specific implementation of a language or platform, which is a piece of software. However, even if we focus just on the latter part, your assumption is still not true.

There are implementations of Java on Operating Systems where C is not the native systems programming language. So, even assuming that these implementations of Java's standard libraries do use system libraries and do use system calls, those system libraries wouldn't be the C standard libraries.

Also, there are implementations of Java that don't run on an OS at all, so the concept of a "system call" doesn't even make sense.

And, there are Java implementations which are their own OS, so the Java standard libraries are the system libraries and Java method calls are system calls.

Additionally, consider an implementation like IKVM.NET, which runs on the .NET platform. Certainly, it doesn't use the C standard libraries, it uses the .NET standard libraries.

GNU Classpath was a (now abandoned) open source implementation of the Java standard libraries. GNU Classpath did not use calls to the C standard libraries. Instead, it defined a certain minimal set of intrinsic methods that had to be provided by the host platform, and everything else was implemented in terms of those well-defined intrinsics. How the host platform provides those intrinsics, GNU Classpath did not care about. The host platform might have used calls to C standard libraries to provide them, but then again, it might not.

  • +1 Excellent breakdown and great examples. – valiano Feb 23 at 19:35
  • 2
    I see your point, but I think your might be overstating your case a bit. The implementation of the standard library "specification" on a given platform for, say, C++ is called the "standard library" all the time; even the C++ language lawyers don't split hairs like this. – Robert Harvey Feb 24 at 0:49
5

The C standard library is a set of functions, macros, etc.. defined in header files that are required to be provided by a C Language implementation.  The kinds of functions found there do IO, math, string handling, memory allocation, etc..  However, this standard library does necessarily not include/expose/offer what we think of as operating system calls (the library is, of course, implemented in terms of system calls).  Examples of these library functions include fread, malloc, which can be thought of as using system calls in their implementation (e.g. read and sbrk), though are doing buffering and are implementing what is required by the C language, rather than providing direct or 1:1 access to the respective system calls.

Most languages have some way of accessing the system calls more-or-less directly, depending on the system call mechanism, possibly via a operating system provided library.  Such an operating system provided library will usually be accessible via C calling conventions, so that any language that can call C can call these system calls.

A Java implementation is free to use C standard library calls or make operating system calls directly, or both as it sees fit.

  • 1
    There are also Java implementations that run on Operating Systems that aren't really conducive to C (e.g. i/OS (aka OS/400), z/OS (aka OS/390)), don't run on an Operating System at all (e.g. Smartcards, microcontrollers), or are an OS (e.g. JNode). – Jörg W Mittag Feb 23 at 18:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.