What language is used to program windows

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

Want to improve this question? Update the question so it’s on-topic for Stack Overflow.

Closed 10 years ago .

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

5 Answers 5

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

Maybe you want to look into the Singularity Project.

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

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

Operating Systems can be written in pretty much any language, 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

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.

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

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.

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

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.

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.

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.

Find Programming Language Used

Whats the easiest way to find out what programming language an application was written in? I would like to know if its vb or c++ or delphi or .net etc from the program exe file.

13 Answers 13

of course if they used a packer, some unpacking will need to be done first 🙂

Start it up and check what run-time DLLs it uses with Process Explorer.

If that doesn’t make it immediately obvious, search the web for references to those DLLs.

Most disassemblers (including Olly I think) can easily show you the text contained in an EXE or DLL, and that can also sometimes give a clue. Delphi types are often prefixed with T as in TMyClass.

If it’s a small executable with no DLL references and no text you might be SOL. At that point you’d need to look for idioms of particular compilers, and it would be mostly guesswork.

There is an art to detecting what language a program was written in. It is possible but there are no hard and fast rules. It takes a lot of experience (and it also leads to the question «Why would you want to. » but here are a few ideas on how to go about it.

What you’re looking for is a «signature». The signature could be a certain string that is included by the compiler, a reference to an API that is quite common in the programming tool being used, or even a style of programing that is common to the tools being used, visible in the strings contained in the application.

In addition, there are styles to how an application is deployed: various configuration files found in the deployment directory, dlls and assemblies and even images, directories or icons.

Java applications wrapped in a self-launching executable will contain references to java libs, and will likely have certain libraries or files included in the same directory that indicate that it’s java.

As indicated in other answers a managed assembly will show certain signs as well: you can open it in Reflector etc. While it is correct that c# and VB are «interchangable» once compiled, it is not true that they are identical. If you use Reflector to disassemble VB code you will quite often see that the assembly references the Microsoft.VisualBasic.dll assembly. You’ll be able to tell the difference between Mono applications because they will most likely contain references to the mono assemblies.

Many compilers assemble and link code in certain ways, and leave footprints behind. For example, examining a window executable using «strings: tab in Process Explorer, you’ll see a lot of strings. Using these you may be able to determine programming styles, methods called, error or trace methods withint the exe.

An example is that compilers use different mechanisms for localization: Microsoft stores localized strings in XML files or resource files. Other compilers will use a different tactic.

Another example is c++ name mangling. The CodeWarrior compiler uses a different algorithm to mangle the names of the member variables and functions of a call than Visual Studio.

Читайте также:  Установка windows 10 с облака

I suppose you could write a book on the subject of accurately determining the lineage of any executable. This subject would probably be called «programming archeology».

Programming language

A programming language is a computer language programmers use to develop software programs, scripts, or other sets of instructions for computers to execute.

Although many languages share similarities, each has its own syntax. Once a programmer learns the languages rules, syntax, and structure, they write the source code in a text editor or IDE. Then, the programmer often compiles the code into machine language that can be understood by the computer. Scripting languages, which do not require a compiler, use an interpreter to execute the script.

Types of programming languages

Each of the different programming languages mentioned in the next section can be broken into one or more of the following types (paradigms) of languages.

There are other paradigms that can classify a programming language. We’ve tried to list only the most common as a starting point.

A language can also be broken into one of five generation languages.

List of computer programming languages

Today, there are hundreds of different programming languages. The following section contains an index of the different programming and scripting languages currently listed on our site. Clicking any of the following languages displays an explanation and examples of that language.

A-C D-K L-Q R-Z
ActionScript
ALGOL
Ada
AIML *
Altair BASIC
Assembly
AutoHotkey
Babel
BASIC
Batch file
BCPL
BeanShell
Brooks
C
C#
C++
CL
Clojure
COBOL
CoffeeScript
Common Lisp
CPL
CSS *
Curl
Curry
D
DarkBASIC
Dart
Datalog
dBASE
Dylan
EuLisp
Elixir
F
F#
FORTRAN
FoxPro
Franz Lisp
GameMaker
Go
GW Basic
Haskell
HDML *
HTML *
InterLisp
ksh
Java
JavaScript
JCL
Julia
Kotlin
LeLisp
Lisp
LiveScript
LOGO
Lua
MACLISP
Matlab
Metro
MUMPS
Nim
Objective-C
OCaml
Pascal
Perl
PHP
Pick
PureBasic
Python
Prolog
QBasic
R
Racket
Reia
RPG
Ruby
Rust
Scala
Scheme
Scratch
SGML *
Simula
Smalltalk
SPL
SQL *
Stanford LISP
Swift
Tcl
Turbo Pascal
True BASIC
VHDL
Visual Basic
Visual FoxPro
WML *
WHTML *
XLISP
XML *
YAML *
ZetaLisp

Languages marked with an asterisk (*) in the list above are not technically a programming language. They are markup, style sheet, and database management languages that are included in the list for those who may consider them as a programming language.

Those new to computer programming may find the list above overwhelming. Figuring out where to start depends on the type of computer programming you want to do. The next section lists different fields of programming, and the languages to consider for each.

There are several programming languages listed above that may not be in the following categories. The reason for this is that we have elected to list only the most popular choices to avoid confusion.

Application and program development

Application and program development involves programs you work with on a daily basis. For example, the Internet browser you are using to view this web page is considered a program. If you are interested in developing a program, consider the following languages:

Artificial intelligence development

Artificial intelligence or related fields involve creating the character interactions in computer games, portions of programs that make decisions, chatbots, and more. If you’re interested in developing an AI, consider the following languages:

Database development

Database developers create and maintain databases. If you’re interested in creating or maintaining a database, consider any of the following languages:

Game development

Game development involves creating computer games or other entertainment software. If you’re interested in developing a game, consider the following languages:

Computer drivers or other hardware development

Computer drivers and programming hardware interface support are a necessity for hardware functionality. If you’re interested in developing drivers or software interfaces for hardware devices, consider the following languages:

Internet and web page development

Internet and web page development are the essence of the Internet. Without developers, the Internet would not exist. If you’re interested in creating web pages, Internet applications, or other Internet-related tasks, consider the following languages:

Script development

Although it is not likely to become a career, knowing how to create and develop scripts can increase productivity for you or your company, saving you countless hours. If you’re interested in developing scripts, consider the following languages:

How many programming languages are there?

As computers have evolved, many different computer programming languages created for various types of development. Although we do have several dozen languages listed on our site, there are hundreds that we don’t have listed. To get an idea of the different programming languages, you can visit The Hello World Collection, which gives a demo of how to write «Hello World» in over 591 different programming languages.

What are the top programming languages?

There are many different ways this question could be answered. However, we feel that the best method is to rely on the data from GitHub, a service that hosts over 96 million different software projects. In the below chart, GitHub shows the top 10 programming languages from 2014 to 2018.

In the chart above, you can see the top 10 languages are: JavaScript, Java, Python, PHP, C++, C#, TypeScript, Shell, C, and Ruby. The complete overview of growing languages list is on the GitHub Octoverse page.

If you’re learning to program, we recommend learning the language that will suit your needs or that others in your industry rather than the most popular language.

After All These Years, the World is Still Powered by C Programming

Many of the C projects that exist today were started decades ago.

The UNIX operating system’s development started in 1969, and its code was rewritten in C in 1972. The C language was actually created to move the UNIX kernel code from assembly to a higher level language, which would do the same tasks with fewer lines of code.

Oracle database development started in 1977, and its code was rewritten from assembly to C in 1983. It became one of the most popular databases in the world.

In 1985 Windows 1.0 was released. Although Windows source code is not publicly available, it’s been stated that its kernel is mostly written in C, with some parts in assembly. Linux kernel development started in 1991, and it is also written in C. The next year, it was released under the GNU license and was used as part of the GNU Operating System. The GNU operating system itself was started using C and Lisp programming languages, so many of its components are written in C.

But C programming isn’t limited to projects that started decades ago, when there weren’t as many programming languages as today. Many C projects are still started today; there are some good reasons for that.

How is the World Powered by C?

Despite the prevalence of higher-level languages, C continues to empower the world. The following are some of the systems that are used by millions and are programmed in the C language.

Microsoft Windows

Microsoft’s Windows kernel is developed mostly in C, with some parts in assembly language. For decades, the world’s most used operating system, with about 90 percent of the market share, has been powered by a kernel written in C.

Читайте также:  Как настроить launchpad mac os под себя

Linux

Linux is also written mostly in C, with some parts in assembly. About 97 percent of the world’s 500 most powerful supercomputers run the Linux kernel. It is also used in many personal computers.

Mac computers are also powered by C, since the OS X kernel is written mostly in C. Every program and driver in a Mac, as in Windows and Linux computers, is running on a C-powered kernel.

Mobile

iOS, Android and Windows Phone kernels are also written in C. They are just mobile adaptations of existing Mac OS, Linux and Windows kernels. So smartphones you use every day are running on a C kernel.

Databases

The world’s most popular databases, including Oracle Database, MySQL, MS SQL Server, and PostgreSQL, are coded in C (the first three of them actually both in C and C++).

Databases are used in all kind of systems: financial, government, media, entertainment, telecommunications, health, education, retail, social networks, web, and the like.

3D Movies

3D movies are created with applications that are generally written in C and C++. Those applications need to be very efficient and fast, since they handle a huge amount of data and do many calculations per second. The more efficient they are, the less time it takes for the artists and animators to generate the movie shots, and the more money the company saves.

Embedded Systems

Imagine that you wake up one day and go shopping. The alarm clock that wakes you up is likely programmed in C. Then you use your microwave or coffee maker to make your breakfast. They are also embedded systems and therefore are probably programmed in C. You turn on your TV or radio while you eat your breakfast. Those are also embedded systems, powered by C. When you open your garage door with the remote control you are also using an embedded system that is most likely programmed in C.

Then you get into your car. If it has the following features, also programmed in C:

  • automatic transmission
  • tire pressure detection systems
  • sensors (oxygen, temperature, oil level, etc.)
  • memory for seats and mirror settings.
  • dashboard display
  • anti-lock brakes
  • automatic stability control
  • cruise control
  • climate control
  • child-proof locks
  • keyless entry
  • heated seats
  • airbag control

You get to the store, park your car and go to a vending machine to get a soda. What language did they use to program this vending machine? Probably C. Then you buy something at the store. The cash register is also programmed in C. And when you pay with your credit card? You guessed it: the credit card reader is, again, likely programmed in C.

All those devices are embedded systems. They are like small computers that have a microcontroller/microprocessor inside that is running a program, also called firmware, on embedded devices. That program must detect key presses and act accordingly, and also display information to the user. For example, the alarm clock must interact with the user, detecting what button the user is pressing and, sometimes, how long it is being pressed, and program the device accordingly, all while displaying to the user the relevant information. The anti-lock brake system of the car, for example, must be able to detect sudden locking of the tires and act to release the pressure on the brakes for a small period of time, unlocking them, and thereby preventing uncontrolled skidding. All those calculations are done by a programmed embedded system.

Although the programming language used on embedded systems can vary from brand to brand, they are most commonly programmed in the C language, due to the language’s features of flexibility, efficiency, performance, and closeness to the hardware.

Why is the C Programming Language Still Used?

There are many programming languages, today, that allow developers to be more productive than with C for different kinds of projects. There are higher level languages that provide much larger built-in libraries that simplify working with JSON, XML, UI, web pages, client requests, database connections, media manipulation, and so on.

But despite that, there are plenty of reasons to believe that C programming will remain active for a long time.

In programming languages one size does not fit all. Here are some reasons that C is unbeatable, and almost mandatory, for certain applications.

Portability and Efficiency

C is almost a portable assembly language. It is as close to the machine as possible while it is almost universally available for existing processor architectures. There is at least one C compiler for almost every existent architecture. And nowadays, because of highly optimized binaries generated by modern compilers, it’s not an easy task to improve on their output with hand written assembly.

Such is its portability and efficiency that “compilers, libraries, and interpreters of other programming languages are often implemented in C”. Interpreted languages like Python, Ruby, and PHP have their primary implementations written in C. It is even used by compilers for other languages to communicate with the machine. For example, C is the intermediate language underlying Eiffel and Forth. This means that, instead of generating machine code for every architecture to be supported, compilers for those languages just generate intermediate C code, and the C compiler handles the machine code generation.

C has also become a lingua franca for communicating between developers. As Alex Allain, Dropbox Engineering Manager and creator of Cprogramming.com, puts it:

C is a great language for expressing common ideas in programming in a way that most people are comfortable with. Moreover, a lot of the principles used in C – for instance, argc and argv for command line parameters, as well as loop constructs and variable types – will show up in a lot of other languages you learn so you’ll be able to talk to people even if they don’t know C in a way that’s common to both of you.

Memory Manipulation

Arbitrary memory address access and pointer arithmetic is an important feature that makes C a perfect fit for system programming (operating systems and embedded systems).

At the hardware/software boundary, computer systems and microcontrollers map their peripherals and I/O pins into memory addresses. System applications must read and write to those custom memory locations to communicate with the world. So C’s ability to manipulate arbitrary memory addresses is imperative for system programming.

A microcontroller could be architected, for example, such that the byte in memory address 0x40008000 will be sent by the universal asynchronous receiver/transmitter (or UART, a common hardware component for communicating with peripherals) every time bit number 4 of address 0x40008001 is set to 1, and that after you set that bit, it will be automatically unset by the peripheral.

This would be the code for a C function that sends a byte through that UART:

The first line of the function will be expanded to:

This line tells the compiler to interpret the value 0x40008000 as a pointer to a char , then to dereference (give the value pointed to by) that pointer (with the leftmost * operator) and finally to assign byte value to that dereferenced pointer. In other words: write the value of variable byte to memory address 0x40008000 .

The next line will be expanded to:

In this line, we perform a bitwise OR operation on the value at address 0x40008001 and the value 0x08 ( 00001000 in binary, i.e., a 1 in bit number 4), and save the result back to address 0x40008001 . In other words: we set bit 4 of the byte that is at address 0x40008001. We also declare that the value at address 0x40008001 is volatile. This tells the compiler that this value may be modified by processes external to our code, so the compiler won’t make any assumptions about the value in that address after writing to it. (In this case, this bit is unset by the UART hardware just after we set it by software.) This information is important for the compiler’s optimizer. If we did this inside a for loop, for example, without specifying that the value is volatile, the compiler might assume this value never changes after being set, and skip executing the command after the first loop.

Читайте также:  Отключение sip mac os big sur

Deterministic Usage of Resources

A common language feature that system programming cannot rely on is garbage collection, or even just dynamic allocation for some embedded systems. Embedded applications are very limited in time and memory resources. They are often used for real-time systems, where a non-deterministic call to the garbage collector cannot be afforded. And if dynamic allocation cannot be used because of the lack of memory, it is very important to have other mechanisms of memory management, like placing data in custom addresses, as C pointers allow. Languages that depend heavily on dynamic allocation and garbage collection wouldn’t be a fit for resource-limited systems.

Code Size

C has a very small runtime. And the memory footprint for its code is smaller than for most other languages.

When compared to C++, for example, a C-generated binary that goes to an embedded device is about half the size of a binary generated by similar C++ code. One of the main causes for that is exceptions support.

Exceptions are a great tool added by C++ over C, and, if not triggered and smartly implemented, they have practically no execution time overhead (but at the cost of increasing the code size).

Let’s see an example in C++:

Methods of A , B and C classes are defined somewhere else (for example in other files). Therefore the compiler cannot analyze them and cannot know if they will throw exceptions. So it must prepare to handle exceptions thrown from any of their constructors, destructors, or other method calls. Destructors should not throw (very bad practice), but the user could throw anyway, or they could throw indirectly by calling some function or method (explicitly or implicitly) that throws an exception.

If any of the calls in myFunction throw an exception, the stack unwinding mechanism must be able to call all the destructors for the objects that were already constructed. One implementation for the stack unwinding mechanism will use the return address of the last call from this function to verify the “checkpoint number” of the call that triggered the exception (this is the simple explanation). It does this by making use of an auxiliary autogenerated function (a kind of look-up table) that will be used for stack unwinding in case an exception is thrown from the body of that function, which will be similar to this:

If the exception is thrown from checkpoints 1 and 9, no object needs destruction. For checkpoint 3, b and a must be destructed. For checkpoint 6, c and a must be destructed. In all cases the destruction order must be respected. For checkpoints 2, 4, 5, 7, and 8, only object a needs to be destructed.

This auxiliary function adds size to the code. This is part of the space overhead that C++ adds to C. Many embedded applications cannot afford this extra space. Therefore, C++ compilers for embedded systems often have a flag to disable exceptions. Disabling exceptions in C++ is not free, because the Standard Template Library heavily relies on exceptions to inform errors. Using this modified scheme, without exceptions, requires more training for C++ developers to detect possible issues or find bugs.

And, we are talking about C++, a language whose principle is: “You don’t pay for what you don’t use.” This increase on binary size gets worse for other languages that add additional overhead with other features that are very useful but cannot be afforded by embedded systems. While C does not give you the use of these extra features, it allows a much more compact code footprint than the other languages.

Reasons to Learn C

C is not a hard language to learn, so all the benefits from learning it will come quite cheap. Let’s see some of those benefits.

Lingua Franca

As already mentioned, C is a lingua franca for developers. Many implementations of new algorithms in books or on the internet are first (or only) made available in C by their authors. This gives the maximum possible portability for the implementation. I’ve seen programmers struggling on the internet to rewrite a C algorithm to other programming languages because he or she didn’t know very basic concepts of C.

Be aware that C is an old and widespread language, so you can find all kind of algorithms written in C around the web. Therefore you’ll very likely benefit from knowing this language.

Understand the Machine (Think in C)

When we discuss the behavior of certain portions of code, or certain features of other languages, with colleagues, we end up “talking in C:” Is this portion passing a “pointer” to the object or copying the entire object? Could any “cast” be happening here? And so on.

We would rarely discuss (or think) about the assembly instructions that a portion of code is executing when analyzing the behavior of a portion of code of a high level language. Instead, when discussing what the machine is doing, we speak (or think) pretty clearly in C.

Moreover, if you can’t stop and think that way about what you are doing, you may end up programming with some sort of superstition about how (magically) things are done.

Work on Many Interesting C Projects

Many interesting projects, from big database servers or operating system kernels, to small embedded applications you can even do at home for your personal satisfaction and fun, are done in C. There is no reason to stop doing things you may love for the single reason that you don’t know an old and small, but strong and time-proven programming language like C.

Conclusion

The C programming language doesn’t seem to have an expiration date. It’s closeness to the hardware, great portability and deterministic usage of resources makes it ideal for low level development for such things as operating system kernels and embedded software. Its versatility, efficiency and good performance makes it an excellent choice for high complexity data manipulation software, like databases or 3D animation. The fact that many programming languages today are better than C for their intended use doesn’t mean that they beat C in all areas. C is still unsurpassed when performance is the priority.

The world is running on C-powered devices. We use these devices every day whether we realize it or not. C is the past, the present, and, as far as we can see, still the future for many areas of software.

Оцените статью