我只是想知道谁知道Windows、Mac OS X和Linux是由哪些编程语言组成的,以及操作系统的每个部分都使用了哪些语言(例如:内核、插件架构、GUI组件等)。

我假设每种都有多种语言,显然我知道Linux内核是用C编写的。

我完全猜测Mac OS X包含大量Objective-C代码,因为它是苹果从NeXT派生的语言。

Windows,我听说包含C, c++和英特尔汇编。Linux或Mac OS是否包含任何汇编代码?

还有,是否有像Ruby, Python之类的脚本语言被操作系统开发者用来编写部分操作系统的脚本?操作系统的哪些部分是用每种语言编写的?


Windows:主要是C和c++,还有一些c#


你说得对,MacOSX的核心是Objective-C。

Windows C + +

Linux C

关于脚本语言,不,它们相当高级。


Windows: c++,内核是C语言 Mac: Objective C,内核是C (IO PnP子系统是嵌入式c++) Linux:大多数东西都是C语言,许多用户应用程序是Python语言,KDE都是c++语言

所有内核都将使用一些汇编代码。


The Linux kernel is mostly written in C (and a bit of assembly language, I'd imagine), but some of the important userspace utilities (programs) are shell scripts written in the Bash scripting language. Beyond that, it's sort of hard to define "Linux" since you basically build a Linux system by picking bits and pieces you want and putting them together, and depending on what an individual Linux user wants, you can get pretty much any language involved. (As Paul said, Python and C++ play important roles)


I have read or heard that Mac OS X is written mostly in Objective-C with some of the lower level parts, such as the kernel, and hardware device drivers written in C. I believe that Apple "eat(s) its own dog food", meaning that they write Mac OS X using their own Xcode Developer Tools. The GCC(GNU Compiler Collection) compiler-linker is the unix command line tool that xCode used for most of its compiling and/or linking of executables. Among other possible languages, I know GCC compiles source code from the C, Objective-C, C++ and Objective-C++ languages.


Mac OS X在一些库中使用了大量的c++,但由于担心ABI被破坏,所以没有公开。


Linux: C.组装中的部分部件。

[...] It's mostly in C, but most people wouldn't call what I write C. It uses every conceivable feature of the 386 I could find, as it was also a project to teach me about the 386. As already mentioned, it uses a MMU, for both paging (not to disk yet) and segmentation. It's the segmentation that makes it REALLY 386 dependent (every task has a 64Mb segment for code & data - max 64 tasks in 4Gb. Anybody who needs more than 64Mb/task - tough cookies). [...] Some of my "C"-files (specifically mm.c) are almost as much assembler as C. [...] Unlike minix, I also happen to LIKE interrupts, so interrupts are handled without trying to hide the reason behind them. (Source)

Mac OS X: Cocoa主要在Objective-C中。内核用C语言编写,部分部件用汇编。

Mac OS X, at the kernel layer, is mostly an older, free operating system called BSD (specifically, it’s Darwin, a sort of hybrid of BSD, Mach, and a few other things)... almost entirely C, with a bit of assembler thrown in. (Source) Much of Cocoa is implemented in Objective-C, an object-oriented language that is compiled to run at incredible speed, yet employes a truly dynamic runtime making it uniquely flexible. Because Objective-C is a superset of C, it is easy to mix C and even C++ into your Cocoa applications. (Source)

Windows: C, c++, c#。汇编程序中的部分部件。

对于Windows,我们几乎全部使用C、c++和c#。一些代码区域是手工调优/手工编写的汇编。(源)

Unix: C.汇编中的部分部件。(源)


作为Mac OS X核心的一个补充,Finder在Snow Leopard之前还没有用Objective-C编写。在Snow Leopard中,它是用Cocoa Objective-C编写的


I understand that this is an old post but Windows is definitely not written in C++. There is lots of C++ in it but what we technical define as an operating system is not in C++. The Windows API, the Windows kernel (both of these are in essence what an operating system is) are written in C. Years ago I was given some leaked code for both Windows 2000 and Windows XP. The code was not nearly complete enough to compile the kernel or API but we were able to compile individual programs and services. For example, we were able to successfully compile Notepad.exe, mspaint.exe, and the spoolsv.exe service (print spooler). All written in C. I have not looked again but I am sure that leaked code still survives as torrent files out there that may still be available.


请参阅标题下的一个操作系统在多个平台上运行,其中说明:

Most of the source code for Windows NT is written in C or C++.

windows: c++ linux: C mac: Objective C android: JAVA, C, c++ Solaris: C, c++ iOS 7: Objective-C,Swift,C, c++


哇! !9年的问题,但我刚刚看到了一系列关于Windows命令行历史的内部文章,我认为其中一些可能与问题的Windows方面有关:

For those who care about such things: Many have asked whether Windows is written in C or C++. The answer is that - despite NT's Object-Based design - like most OS', Windows is almost entirely written in 'C'. Why? C++ introduces a cost in terms of memory footprint, and code execution overhead. Even today, the hidden costs of code written in C++ can be surprising, but back in the late 1990's, when memory cost ~$60/MB (yes … $60 per MEGABYTE!), the hidden memory cost of vtables etc. was significant. In addition, the cost of virtual-method call indirection and object-dereferencing could result in very significant performance & scale penalties for C++ code at that time. While one still needs to be careful, the performance overhead of modern C++ on modern computers is much less of a concern, and is often an acceptable trade-off considering its security, readability, and maintainability benefits ... which is why we're steadily upgrading the Console’s code to modern C++.