Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
scroll top