332

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).

I assume that there are multiple languages for each and obviously I know the Linux kernel is written in 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.

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

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?

peterh
  • 11,875
  • 18
  • 85
  • 108
Brock Woolf
  • 46,656
  • 50
  • 121
  • 144
  • [One Dev Question with Raymond Chen - What Programming Language is Windows Written In?](https://channel9.msdn.com/Blogs/One-Dev-Minute/One-Dev-Question-with-Raymond-Chen-What-Programming-Language-is-Windows-Written-In) – phuclv Apr 29 '18 at 15:07
  • This [SO exchange](https://stackoverflow.com/questions/10904721/is-it-possible-to-create-an-operating-system-using-python) may help answer the very last part of your question. – Bikramjeet Singh Apr 21 '19 at 13:07
  • 2
    Windows is written in JS according to google :) look it up – samarmohan Jan 27 '21 at 00:49
  • @samarmohan how is Windows written in JavaScript? I mean, can you make a damn OS in JS? You can’t (as far as I know). It’s C++. – Daniyal Warraich Apr 12 '21 at 17:59
  • 3
    It was a joke, just look it up. – samarmohan Apr 12 '21 at 20:18

12 Answers12

336
  • 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++

All kernels will use some assembly code as well.

Sean
  • 60,939
  • 11
  • 97
  • 136
Ana Betts
  • 73,868
  • 16
  • 141
  • 209
  • 18
    I should add that Gnome is pretty much C as well. – Nathan Osman Jul 23 '11 at 18:16
  • 19
    Gnome also flirted with C# (Mono). – Hristo Iliev May 08 '12 at 08:30
  • 6
    The linux kernel has assembler as well I believe. – GL2014 Aug 06 '13 at 15:12
  • 13
    True, every kernel will have at least some assembler – Ana Betts Aug 07 '13 at 09:07
  • 4
    To make things crystal clear - the Apple kernel's IOKit subsystem (for drivers) uses (a restricted subset of) C++. And on all 3, i.e Windows, Mac and Linux, many of the most important userland applications are written in either C or C++. Allegedly, for example, MS tried to redo Office in .NET but went back to C++. And the linux kernel uses many C++-like idioms but hand-cooked together in C, e.g. inheritance in driver code. – Erik Alapää Feb 23 '15 at 13:14
  • @ErikAlapää do you have a source for this comment? "Allegedly, for example, MS tried to redo Office in .NET but went back to C++" I'm intrigued to read about it. – rollsch Feb 07 '17 at 01:28
  • @rolls I read it a long time ago, but maybe this interview has some info: https://channel9.msdn.com/Shows/Going+Deep/Craig-Symonds-and-Mohsen-Agsen-C-Renaissance – Erik Alapää Feb 07 '17 at 10:32
  • can you tell me which lang. is used to Build UI in windows ? – jasinth premkumar Mar 15 '18 at 14:45
  • C++ and XAML in Windows 10 – Ana Betts Mar 18 '18 at 20:51
  • 2
    All thanks to the founder of C language -> **Dennis Ritchie**. He is the main reason for today's growing IT industry. – G_real Mar 08 '19 at 22:17
104

Linux: C. Some parts in assembly.

[...] 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 mostly in Objective-C. Kernel written in C, some parts in assembly.

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#. Some parts in assembler.

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

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

Community
  • 1
  • 1
Pacerier
  • 86,231
  • 106
  • 366
  • 634
  • 4
    The driver subsystem in Darwin (IOKit) relies heavily on a COM-like object model that is written in a subset of C++. – Hristo Iliev May 08 '12 at 08:33
  • @Tahlor yes. How can you write a low-level thing like a kernel in VB when it doesn't have even an operator for bit shifting? [This is what Raymond Chen said](https://channel9.msdn.com/Blogs/One-Dev-Minute/One-Dev-Question-with-Raymond-Chen-What-Programming-Language-is-Windows-Written-In). Windows apps are different – phuclv Apr 29 '18 at 15:05
21

Wow!!! 9 years of question but I've just come across a series of internal article on Windows Command Line history and I think some part of it might be relevant Windows side of the question:

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++.

16

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

alex strange
  • 1,249
  • 9
  • 9
  • 15
    What? Half of the programs stop working on every new release anyway. – kinokijuf Jan 06 '13 at 16:31
  • 8
    Could you please provide some sort of a citation for the _"Mac OS X uses large amounts of C++ inside some libraries"_ statement? I just find it hard to just take your word for it! I'm sorry for being skeptical. – Anish Ramaswamy Jan 30 '14 at 05:46
  • 5
    @AnishRamaswamy Look into `IOKit`, `WebKit` and `GLKit`. Also have a glimpse at `dyld`. Those are very C++ heavy. – Maxthon Chan Nov 24 '14 at 08:48
  • 2
    I'm sure the OSX Kernal is C and not C++, in fact all operating systems I have come across have a C kernal – twigg Jun 30 '15 at 10:07
14

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.

Duke Bishop
  • 171
  • 1
  • 5
10

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

Larry Osterman
  • 16,086
  • 32
  • 60
  • 1
    .NET is shipped with Windows. A lot of .NET is in C#. – Jonathan Parker Feb 24 '09 at 03:11
  • There's rumors that future versions (Windows 8 maybe) of windows will have some C++ code replaced with C#/.NET. – Jonathan Parker Feb 24 '09 at 03:12
  • They've already managed a working OS (almost) completely in C#. It's called Singularity. http://research.microsoft.com/en-us/projects/singularity/ – Randolpho Feb 24 '09 at 03:32
  • 1
    Luc M: Yes, there's C# code in Windows. Poke around and you'll find it. .Net is shipped with the OS but it doesn't mean the OS is written using .Net. And Windows isn't Singularity. There's a huge difference between a research prototype and a real operating system. – Larry Osterman Feb 25 '09 at 06:17
  • I'm pretty sure at least Windows XP can work entirely without any .NET runtime installed (I'm not sure about Vista), so there can't be any C# in there. – Joachim Sauer Feb 25 '09 at 15:23
  • C# consists of bytecode and a virtual machine....if they used that in Windows it would make it rather slow... Oh... now i see. – Brock Woolf Feb 26 '09 at 05:47
  • Obviously XP was released a long time before .Net so it would have no dependancy on .Net – 1800 INFORMATION Mar 18 '09 at 07:35
  • 2
    @1800Information - C# compiles to machine code from there JIT compiles to machine code when run? I think you are the confused one. There IS bytecode and there IS a virtual machine: http://en.wikipedia.org/wiki/Common_Intermediate_Language – Brock Woolf Apr 07 '09 at 21:53
  • C# is the future for microsoft. It is a higher language for making it easier for learning and producing better apps quicker. languages will higher and higher. soon a 10 year old will be able to program. – numerical25 May 25 '13 at 15:19
  • @BrockWoolf: That Wikipedia article is pretty misleading, if not wrong. CIL (in the .NET implementation shipped by Microsoft) is never executed by a virtual machine. It is always compiled to machine code, prior to execution, either by a JIT compiler, or offline as in [.NET Native](https://docs.microsoft.com/en-us/dotnet/framework/net-native/). Besides, there are areas, where .NET flat out beats native code in terms of performance. The heap implementation, for example, allows for blazingly fast allocations. Creating lots of short-lived objects is usually a lot faster in .NET than in C or C++. – IInspectable Mar 14 '18 at 20:33
4
  • windows: C++
  • linux: C
  • mac: Objective C
  • android: JAVA, C, C++
  • Solaris: C, C++
  • iOS 7: Objective-C,Swift,C, C++
SimonT
  • 2,219
  • 1
  • 18
  • 32
sonsha
  • 165
  • 2
  • 9
  • 1
    Android's written in Java? Really? – nirvanaswap Apr 15 '16 at 00:32
  • 4
    Android: Java (UI). Source: https://en.wikipedia.org/wiki/Android_(operating_system) – Nitesh Borad Jun 23 '16 at 12:47
  • 6
    The discussion is about the operating system. An operating system cannot be built without a system programming language. It's not possible to do system programming with Java. – Clay Risser Feb 05 '17 at 07:16
  • Yah. Some parts of a system can be built in Java and some examples are already present like JavaOS, although it wasn't sucessful. I am not saying you can build OS with 100% java. – Shukant Pal Nov 18 '17 at 12:35
  • 6
    @JamRisser Android uses the Linux kernel, which is in C. The system, nearly until the deepest layers, is written in Java. The Dalvik VM, which is a java virtual machine written by the Google, is in C or C++. – peterh Apr 04 '19 at 11:20
4

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

Windows C++

Linux C

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

OscarRyz
  • 196,001
  • 113
  • 385
  • 569
  • 11
    Windows in C: kernel, drivers, API. Only system applications and tools in C++, I guess. So it's more clear to say just C – abatishchev Feb 25 '09 at 15:27
4

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)

David Z
  • 128,184
  • 27
  • 255
  • 279
4

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.

Patrick Cassell
  • 469
  • 2
  • 6
  • 10
4

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

Cagatay Gurturk
  • 7,186
  • 3
  • 34
  • 44
3

See under the heading One Operating System Running On Multiple Platforms where it states:

Most of the source code for Windows NT is written in C or C++.
pcunite
  • 1,197
  • 15
  • 23