Windows、Mac OS X 和 Linux 是用什么语言编写的?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/580292/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-03 17:01:52  来源:igfitidea点击:

What languages are Windows, Mac OS X and Linux written in?

windowslinuxmacosprogramming-languagesoperating-system

提问by Brock Woolf

I was just wondering who knows what programming languages Windows, Mac OS X and Linux are made up from and what languages are used for each part of the OS (ie: Kernel, plug-in architecture, GUI components, etc).

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

I assume that there are multiple languages for each and obviously I know the Linux kernel is written in C.

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

I'm totally guessing here that Mac OS X contains a lot of Objective-C code as it is Apple's language derived from NeXT.

我在这里完全猜测 Mac OS X 包含很多 Objective-C 代码,因为它是 Apple 的源自 NeXT 的语言。

Windows, I have heard contains C, C++ and Intel Assembly. Do Linux or Mac OS contain any Assembly code?

Windows,我听说包含 C、C++ 和 Intel 程序集。Linux 或 Mac OS 是否包含任何汇编代码?

Also, are there scripting languages like Ruby, Python, etc used by the OS developers for scripting parts of the OS? What parts of the OS would be written in each language?

此外,操作系统开发人员是否使用 Ruby、Python 等脚本语言来编写操作系统的脚本部分?操作系统的哪些部分将用每种语言编写?

采纳答案by Ana Betts

  • Windows: C++, kernel is in C
  • Mac: Objective C, kernel is in C (IO PnP subsystem is Embedded C++)
  • Linux: Most things are in C, many userland apps are in Python, KDE is all C++
  • Windows:C++,内核在 C 中
  • Mac:Objective C,内核是C(IO PnP子系统是嵌入式C++)
  • Linux:大多数东西都是用 C 语言编写的,许多用户应用程序是用 Python 编写的,KDE 都是 C++

All kernels will use some assembly code as well.

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

回答by ReinstateMonica Larry Osterman

Windows: Mostly C and C++, some C#

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

回答by OscarRyz

You're right MacOSX has Objective-C in the core.

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

Windows C++

视窗 C++

Linux C

Linux C

About the scripting languages, no, they pretty much high level.

关于脚本语言,不,它们非常高级。

回答by David Z

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)

Linux 内核主要是用 C 编写的(我想还有一点汇编语言),但一些重要的用户空间实用程序(程序)是用 Bash 脚本语言编写的 shell 脚本。除此之外,定义“Linux”有点困难,因为您基本上是通过挑选您想要的零碎部分并将​​它们组合在一起来构建 Linux 系统,并且根据单个 Linux 用户的需求,您几乎可以使用任何语言。(正如 Paul 所说,Python 和 C++ 扮演着重要的角色)

回答by Patrick Cassell

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 主要是用 Objective-C 编写的,其中一些较低级别的部分,例如内核和用 C 编写的硬件设备驱动程序。我相信苹果“吃自己的狗粮” ”,也就是说,他们使用自己编写的Mac OS X的Xcode开发工具。的(GNU编译器集合)GCC编译器-连接基是unix命令行工具xcode的用于大多数其编译和/或可执行程序的链接。在其他可能的语言中,我知道 GCC 从 C、Objective-C、C++ 和 Objective-C++ 语言编译源代码。

回答by Patrick Cassell

Windows is obviously not written in C# (!)

Windows 显然不是用 C# 编写的(!)

Simply see the source code of Windows and you'll see...

只需查看 Windows 的源代码,您就会看到...

回答by alex strange

Mac OS X uses large amounts of C++ inside some libraries, but it isn't exposed as they're afraid of the ABI breaking.

Mac OS X 在某些库中使用了大量 C++,但由于担心 ABI 破坏,因此并未公开。

回答by Pacerier

Linux: C. Some parts in assembly.

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)

[...] 它主要是用 C 语言编写的,但大多数人不会称我写的是 C。它使用了我能找到的 386 的所有可以想象的功能,因为它也是一个教我了解 386 的项目。如前所述。 ,它使用 MMU,用于分页(尚未到磁盘)和分段。正是分段使其真正依赖于 386(每个任务都有一个 64Mb 的代码和数据段 - 4Gb 中最多 64 个任务。任何需要超过 64Mb/任务的人 - 硬饼干)。[...] 我的一些“C”文件(特别是 mm.c)几乎和 C 一样多的汇编程序。 [...] 与 minix 不同,我也碰巧喜欢中断,所以处理中断时不会试图隐藏他们背后的原因。(来源)

Mac OS X: Cocoa mostly in Objective-C. Kernel written in C, some parts in assembly.

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)

Mac OS X,在内核层,主要是一个旧的、免费的操作系统,称为 BSD(具体来说,它是 Darwin,一种 BSD、Mach 和其他一些东西的混合体)......几乎完全是 C,有一点汇编程序投入。(来源)

Cocoa 的大部分内容是用 Objective-C 实现的,Objective-C 是一种面向对象的语言,编译后以惊人的速度运行,但采用真正动态的运行时,使其具有独特的灵活性。因为 Objective-C 是 C 的超集,所以很容易将 C 甚至 C++ 混合到您的 Cocoa 应用程序中。 (来源)

Windows: C, C++, C#. Some parts in assembler.

视窗:C、C++、C#。汇编程序中的某些部分。

We use almost entirely C, C++, and C# for Windows. Some areas of code are hand tuned/hand written assembly. (Source)

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

Unix: C. Some parts in assembly. (Source)

Unix: C. 组装中的一些部件。(来源)

回答by ?a?atay Gürtürk

As an addition about the core of Mac OS X, Finder had not been written in Objective-C prior to Snow Leopard. In Snow Leopard it was written in Cocoa, Objective-C

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

回答by Duke Bishop

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.

我知道这是一篇旧帖子,但 Windows 绝对不是用 C++ 编写的。里面有很多 C++,但我们技术上定义的操作系统不是 C++。Windows API、Windows 内核(这两者本质上都是操作系统)是用 C 编写的。几年前,我收到了一些 Windows 2000 和 Windows XP 的泄露代码。代码还不够完整,无法编译内核或 API,但我们能够编译单个程序和服务。例如,我们能够成功编译 Notepad.exe、mspaint.exe 和 spoolsv.exe 服务(print spooler)。全部用 C 编写。我没有再看,但我确信泄漏的代码仍然存在,因为那里可能仍然可用的 Torrent 文件。