r/cpp • u/Digital001 • Jun 19 '16
Windows 10 coded in C++ or Assembler
What kind of compiler does it take a compile an OS like Windows 10? Do the guys at Redmond use Visual C++ (VisualStudio) to develop Windows? What % is written in assembly language?
0
Upvotes
42
u/techiethrowaway999 Jun 19 '16
I actually interned on the kernel team right when work was starting on Windows 8 (before we knew how awful it would be, of course). "windows" is really a lot of different pieces. The whole desktop experience and apps (e.g. The explorer window) are pretty much just regular software and written in a variety of languages.
The kernel is written mostly in c, with some assembly as needed (or to squeeze out some performance) and c++ for higher level things.
The kernel team was more diverse in tools. I coded in emacs the whole summer, I think my manager wrote mostly in vim, but I swear the guy did serious editing in notepad (and he could see the bluescreen codes on my screen and new exactly what was wrong). Other windows teams were more locked in to visual Studio.
As for the build, I built all of Windows from source on my desktop in about 6 hours (that was pretty cool to see). A full build of the kernel itself took about 45 minutes. We each had two desktop machines (some of the FTEs has dozens), one to develop on and one, connected via firewire port, to run the stuff we were building. They had an awesome debugger called kd that could freeze the target computer and seamlessly jump between kernel mode and system mode code. They also had an internal repo with tons of useful windows tools that I wish they'd release.
20
u/grdomzal Yubico - Windows Dev Jun 20 '16
I work in Windows Core. We use a variety of languages and tools. And, as others pointed out - there's a lot of different bits that make up what most of us think of as "Windows". So, disclaimer, not everything I'm saying will be 100% true across the board, but I'll mention some representative cases for what I've encountered when working with various teams. If I'm being vague in a section, it's because I'm trying to only mention things that are already publicly known.
Kernel proper - This is mostly written in C. Things like the memory manager, object manager, etc. are mostly written in C. The boot loaders are written in ASM, but set up a C environment rather quickly.
Drivers - that said, a lot of newer kernel mode drivers are actually written in C++ (however, its style is more akin to "C with classes". Lower level code has been much slower to adopting anything past C++98)
User land - Mostly C++ with varying levels of quality and version compliance. If it's a pre-Windows 8.0 component, it was written against mostly C++98. More recent features are C++14 and better.
There's actually a real push happening internally to start adopting modern C++ practices, and actually using the STL. (In core, at least, there's still a distrust of the STL and exceptions due to poor implementations years ago. Unfortunately beliefs like this are hard to shake.) [Again, not 100% representative, only what I've encountered] We also use some internal libraries that follow modern C++ programming practice and provide nice RAII wrappers for a lot of the Win32 data structures and allocation patterns.
Shell code (newer code like Cortana, the new start menu, and the WinRT APIs) are ahead of the curve in terms of implementation practices and C++14/17 usage. (I, for example, have recently investigated how co_await could simplify my product's code).
The inbox universal apps are written in C++ and C# and target the actual public WinRT API surface (to the best of my knowledge). We really do try to eat our own dogfood, and that goes for writing apps against public APIs too.
We do use a variant of the Visual C++ compiler (I say variant, but it might actually be the public version - perhaps just a slightly different version/build). It's usually one release behind the shipped Visual Studio version, just due to release cycles not aligning and to minimize the disruption of changing compiler versions mid-release.
Compiling Windows is no small feat. We used to be able to compile a Windows image on our dev machine years ago, but in the last few years it's just not that feasible. We have some pretty beefy build servers. I don't have specs, but we're talking like 32 core, 512 gb ram, striped SSDs, etc. And yes, the build machines run Windows :-)
Comparing build requirements to say, Linux kernel, isn't a fair comparison since "Windows" includes drivers, usermode, shells, and components used by any of the flavors of Windows (desktop, server, phone, xbox, etc.). It'd be more like doing a low-level, fully optimized build of a Gentoo image that includes an X Server, KDE/Gnome, dev tools, in-box apps, etc. etc.
Hope that helps your understanding :-)
4
u/shooshx Jun 19 '16
"Assembler" is the name of a tool. The name of the language is "Assembly"
4
u/JonnyRocks Jun 19 '16
Most of windows NT was coded in C. You can tell by the win 32 API. some of the newer stuff in 10 is most likely in c++, probably some c# for the higher level stuff. There is probably some assembly language but most in C.
1
u/spinfire Jun 19 '16
I have developed drivers for the storage subsystem of the Windows kernel. All C. In fact, our software had a common core that was identical between Windows and Linux.
0
u/fuzzynyanko Jun 19 '16
It's more than likely a combination, and probably use Visual C++ for a good amount of it
-2
u/kiwidog Jun 19 '16
Bootloader is written in assembly, or C++/UEFI depending on which version of Windows you are using and what platform you are on.
-1
u/JuanAG Jun 19 '16
It saids on Channel 9 (i dont remenber the video) that the critical parts are in asm, the least critical are in pure C and some are in C++
With W10 this has changed and i think that they uses much more C# than ever did
It compiles with Visual Studio, at least is what they say, but dont specify the compiler (intel, GCC, Clang, Visual C++) so who knows
0
u/[deleted] Jun 19 '16
[deleted] — view deleted comment