Is Unix encoded in C or C ++, or both?

Many Unix system calls use overload and default variables. This concept is missing in C, so is Unix also encoded in C ++?

+4
source share
7 answers

Unix was first created at Bell Labs in 1969, long before C ++ was conceived. (Src: Unix ), you can confirm this by reading Lions' Comment on Unix or BSD 4.4-Lite (which is similar to BSD Net / 2 ), which is available in tarball or via cvs (from FreeBSD). Or archives from the Unix Heritage Society , which is one of the oldest versions of Bell Labs / AT & T.

Bjarne Stroustrup created C ++ around 1983, before that he worked on “C with classes” according to the History of C ++ . Confirmed from the Bjarne Stroustrup FAQ , and the earliest date for C with classes is 1979.

Hope this clarifies the impossibility of the idea that Unix was based on C ++. Note that object-oriented languages ​​have existed since the 1960s in Simula 67 , so do not confuse objects and classes with C ++.

+16
source

Pretty strong C all the way down ...

All major versions of Unix use fully direct C for the kernel. (Well, Mac OS X has a bit of C ++ in one interface.)

If you do not consider the desktop layer, then, without any exceptions, the main libraries and utilities are also in C. The only main utility that I can think of is written in C ++: groff .

Now, with packages, this is a different story ...

+12
source

When you talk about kernels for Unix-y like Linux, Solaris, Mac OS X, NetBSD, FreeBSD, etc. - they are usually all C. And I'm also not sure what you mean by default or overloading variables - of course, not in kernel calls.

I was surprised when DigitalRoss stated that Mac OS X has Objective-C in the kernel source files, so I downloaded the xvu kernel version for MacOS X 10.6.2, and there really wasn’t target C. I was, however, slightly shocked to discover a bit of C ++.

In any case, many things on which "user" (non-kernel) programs are based, such as virtual memory, exception handling, device I / O, etc., are performed by the kernel. But the core cannot use itself for these things, just as you cannot raise yourself in the air by lifting your shoes with your hands.

Object-oriented languages ​​such as C ++ and Objective-C make extensive use of what kernels cannot do for themselves. This is why the kernels are mostly written in C. In the case of C ++, which I saw in xnu sources, I am sure that it is very, very carefully written to avoid actions that are unsafe in the kernel.

As for user-space programs written in C or C ++, I think that this is mainly a tradition, personal preferences and what people are used to. As a person who speaks both languages, I think this is pretty stupid.

+5
source

I don’t know what kind of system calls you have in mind, but I’m sure that most UNIX-ee operating systems are encoded in direct C. There are probably only C ++ shells for system calls.

+3
source

Definitely C - try man syscall or man -s2 read - this gives you the C library interface, there is no C ++ in sight.

+1
source

Several OS cores are written in C ++. I believe that the Chorus kernel (in one example) is written (almost?) Exclusively in C ++ (this is somewhat similar to Mach: a microkernel that is used almost exclusively with a UNIX emulator acting as a user-mode server).

C ++ also had several other semi-experimental systems. One fairly recent is called Hybrid. A much older one was published on comp.sources.misc ( in four consecutive messages ) years ago - I'm pretty sure it will take a lot of work to get it to compile the current C ++ compiler. This runs in a virtual machine and includes a source for emulating equipment.

+1
source

UNIX systems are usually encoded in direct C, and for some reason, most UNIX developers also seem to dislike C ++.

0
source

Source: https://habr.com/ru/post/1303366/


All Articles