使用什么语言编写操作系统(Windows)?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3317329/
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-09-09 07:29:21  来源:igfitidea点击:

What language is used to write operating systems (Windows)?

windowsoperating-systembootosdev

提问by cdxf

What is the language used to write operating systems (Windows) or a boot CD?

用于编写操作系统 (Windows) 或引导 CD 的语言是什么?

回答by Macmade

Boot loaders are usually written in Assembly, as well as low-level kernel parts, like hardware drivers.
The kernel itself can be written in different languages, like Assembly, C or C++.

引导加载程序通常是用汇编编写的,还有低级内核部分,如硬件驱动程序。
内核本身可以用不同的语言编写,如汇编、C 或 C++。

回答by cRichter

Maybe you want to look into the Singularity Project.

也许你想研究奇点项目。

Its from Microsoft Reseach, on how today a OS could be built.

它来自 Microsoft Reseach,关于当今如何构建操作系统。

there you find a lot of papers, on the concepts of building an OS.

那里有很多关于构建操作系统概念的论文。

Singularity

奇点

回答by J?rg W Mittag

Operating Systems can be written in pretty much anylanguage, and there are plenty of Operating Systems written in an whole bunch of languages. Just a couple of examples:

操作系统几乎可以用任何语言编写,并且有很多操作系统是用各种语言编写的。举几个例子:

  • Singularity is written in Sing# which is a superset of Spec#, which in turn is a superset of C#
  • House is written in Haskell
  • all of the Lisp OS's are written in Lisp
  • there are several Smalltalk OSs written in Smalltalk
  • many embeddded OSs are written in Forth
  • SharpOS and Cosmos are written in C#
  • NewOS and JNode are written in Java
  • Ununumium used to be written largely in Python, but now they have shifted their focus, it is written largely in assembly
  • You can argue whether JS/UX is an OS or not, but it is written in JavaScript
  • Modula-2 was explicitly invented for the purpose of writing an OS
  • Oberon also was explicitly invented for OS development
  • the original MacOS was written in Pascal
  • the original OS/400 was written in Modula-2 and PL/MI
  • Eleanor McHugh has some preliminary ideas for writing an OS in Ruby
  • the Windows NT kernel is written largely in C, however the farther away you get from the kernel, there might be some C++ or even C# in there
  • Singularity 是用 Sing# 编写的,它是 Spec# 的超集,而后者又是 C# 的超集
  • 房子是用 Haskell 写的
  • 所有 Lisp 操作系统都是用 Lisp 编写的
  • 有几个用 Smalltalk 编写的 Smalltalk 操作系统
  • 许多嵌入式操作系统是用 Forth 编写的
  • SharpOS 和 Cosmos 是用 C# 编写的
  • NewOS 和 JNode 是用 Java 编写的
  • Ununumium 过去主要用 Python 编写,但现在他们转移了重点,主要用汇编编写
  • 你可以争论 JS/UX 是否是一个操作系统,但它是用 JavaScript 编写的
  • Modula-2 是为了编写操作系统而明确发明的
  • Oberon 也是为操作系统开发而明确发明的
  • 最初的 MacOS 是用 Pascal 编写的
  • 最初的 OS/400 是用 Modula-2 和 PL/MI 编写的
  • Eleanor McHugh 有一些用 Ruby 编写操作系统的初步想法
  • Windows NT 内核主要是用 C 编写的,但是离内核越远,里面可能有一些 C++ 甚至 C#

回答by Steve314

I'm pretty sure the earliest versions of Windows were written primarily in Pascal. That's why you can still find references to pascal calling conventions in old documents and header files, though AFAIK those conventions only ever applied to 16 bit Windows.

我很确定最早版本的 Windows 主要是用 Pascal 编写的。这就是为什么您仍然可以在旧文档和头文件中找到对 pascal 调用约定的引用,尽管 AFAIK 这些约定仅适用于 16 位 Windows。

[EDIT- I'm now pretty sure I was told a while ago that this is wrong. Microsoft had reasons for using Pascal call conventions that I don't remember, but didn't use Pascal for coding Windows (or the majority of it or whatever)].

[编辑- 我现在很确定我不久前被告知这是错误的。微软有使用 Pascal 调用约定的原因,我不记得了,但没有使用 Pascal 来编码 Windows(或大部分或其他)]。

These days, Windows is probably written in a mixture of languages, though with the emphasis strongly on C and C++. For example, some parts of .NET are probably written in C#, and these days that easily counts as an O/S component.

现在,Windows 可能是用多种语言编写的,但重点是 C 和 C++。例如,.NET 的某些部分可能是用 C# 编写的,现在很容易算作 O/S 组件。

Similarly, I'll bet there are at least a few Objective C components in modern versions of the Mac O/S.

同样,我敢打赌,现代版本的 Mac O/S 中至少有一些 Objective C 组件。

There are a lot of languages that are somewhat suited to writing operating systems. In niche areas, I'm certain you'll find Ada, Modula 2 and more.

有很多语言在某种程度上适合编写操作系统。在利基领域,我敢肯定您会找到 Ada、Modula 2 等。

Imperative languages without garbage collection are probably most common because of the relative ease of interfacing to hardware and assembler code. However, most functional languages are impure. There are low-level versions of Lisp around, if you look hard enough. And ML-family languages and Haskell have probably been used in operating systems, at least for research/academic purposes.

没有垃圾收集的命令式语言可能是最常见的,因为与硬件和汇编代码的接口相对容易。然而,大多数函数式语言是不纯的。如果你仔细看的话,周围有 Lisp 的低级版本。ML 系列语言和 Haskell 可能已用于操作系统,至少用于研究/学术目的。

In fact, I wouldn't be surprised to find even a bit of Prolog in some operating systems components - and certainly some code written using custom-made domain specific languages.

事实上,即使在某些操作系统组件中发现一点 Prolog,我也不会感到惊讶——当然还有一些使用定制的领域特定语言编写的代码。

A real-world operating system is usually a very large software system. Even embedded operating systems have a fair bit of complexity, e.g. for options you don't need for your hardware but someone else does. I've never worked on one, but I'll bet that to get that working, the developers are primarily pragmatists - using whatever they have that works to get the job done.

现实世界的操作系统通常是一个非常大的软件系统。即使是嵌入式操作系统也有相当多的复杂性,例如对于您的硬件不需要但其他人需要的选项。我从来没有做过,但我敢打赌,为了让它发挥作用,开发人员主要是实用主义者 - 使用他们所拥有的任何东西来完成工作。

回答by mcepl

Well, the question is also "What is the operating system?" (does bundled Internet Explorer count in?), but otherwise I believe Windows is mostly C and C++.

那么,问题也是“什么是操作系统?” (捆绑的 Internet Explorer 算不算?),但除此之外,我相信 Windows 主要是 C 和 C++。