Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it a good idea to create an OS that's written in a scripting language?

For example, how about creating an OS using Python?

share|improve this question

closed as not a real question by gnat, ChrisF Jun 29 '12 at 7:47

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

There are virtual machines written in Javascript... – user16764 Jun 29 '12 at 2:12
As good an idea as making a car out of all plastic and no metal. – Job Jun 29 '12 at 3:33
Emacs is a nice OS, and elisp is a scripting language indeed, both by its use and its dynamic scoping. – SK-logic Jun 29 '12 at 7:50

It's not just a bad idea. It's pretty much impossible.

How do you implement IO with a language whose IO facilities depend entirely on the host operating system?

How could you implement primitive scheduling without any useful interrupt primitives?

How could you write a device driver in a language which cannot address a particular byte?

Edit:-- Just to clarify a bit. You cannot write a "real" OS which interacts directly with the machine in a "scripting" language. You can however write a usable "virtual machine" if the scritping language is flexible enough. For instance implementations of Donald Knuths theoretical MIX (s) machine and a ZX80 emulator good enough to run pacman have been written in JavaScript.

share|improve this answer
@ClintNash really? JavaScript by Definition lives within a runtime environment that must run on top of an OS. Sure, it's theoretically possible to precompile it to binary, but this is virtually unheard of. Node.js must run on a host os. JavaScript has no native access to the constructs required to write a real os. Sure, once you are at a high enough level of abstraction you can start using scripts, but something below it needs real, bare to the metal ability to interact with the hardware. – bunglestink Jun 29 '12 at 3:44
I believe you are correct @bunglestink. I was referencing usages of JS/OS at a higher abstraction layer. I am uncertain at what level Windows 8 integrates JS. – ClintNash Jun 29 '12 at 4:13
Lisp has no interrupt or IO primitives and can't access raw memory. It's dynamically typed. And yet, Lisp machines' OS was written in Lisp. – nikie Jun 29 '12 at 7:43
@nikie -- yes but it is not a real OS is still relies on the underlying OS for all the basic services. – James Anderson Jun 29 '12 at 8:43
@nikie Lisp machines were built upon specialized hardware that basically implemented the Lisp virtual machine at the hardware level. So yes, in some since it is possible, but really at this point you are actually implementing your OS in the most primitive form possible - at the microcode level. – bunglestink Jun 29 '12 at 11:15

Before you decide on the how, you need to specify the what. What will this new OS do? Where will it run? Why would any one bother to use it? etc. The next thing is to determine the qualities of the OS. Speed, Security, Threading, Memory Management, Multi-Tasking, File Formats, Language support, supported processors, etc.

From answering the above questions and considering the many qualities of your OS you can determine what tool to use to achieve your goals.

Now, do you really want to do all that?

I assume that Python was used in part in writing parts of Linux - See: What Languages are Windows, Mac OS X and Linux written in?

share|improve this answer

I know this is not a proper answer, but this project demonstrates a working operating system with a kernel written in JavaScript:

The drivers for VGA and the keyboard were also written in JavaScript using interrupts. I developed an implementation of OpenGL 1.1 for it myself a while ago and it works pretty nicely.

share|improve this answer
Actually that looks live the boot loader and low level features are written in c and assembly... Also, the entire js virtual machine is implemented in c... – bunglestink Jun 29 '12 at 3:54
At that point you could also argue that operating systems can't be written in C, because parts need to be written in x86. – Overv Jun 29 '12 at 13:45
good point, can't argue with that. Asm will always be required at some level; although, I believe that the only piece that absolutely must be written in asm on x86 is the bootloader. After that, most C implementations have inline assembly features that could allow you to construct anything above that. This is in contrast to a scripting language that always must have some lower abstraction of a runtime environment present, as it never touches the hardware without going through the runtime abstraction. – bunglestink Jun 29 '12 at 15:22

No, it is not even possible (exclusively)

Why? Consider the following:

What is a scripting language?

Lets make the following two assumptions about the definition of a "scripting language":

  1. The language lives within a runtime environment.
  2. The language does not have access to raw memory pointers.

What is an operating system?

Lets assume that an Operating System's primary goal can be simplified to the following:

  • to provide an abstraction between user programs and the hardware they run upon

By these very definitions, it is logically impossible for a scripting language to be an operating system. Why?

  1. An OS must have raw, untethered access to a computer's memory for communicating with hardware. Since scripting languages do not have access to raw memory pointers, they cannot do this.
  2. Since a scripting language requires a runtime environment, but they can't talk to directly to the hardware, the environment must be coded in another language that has this ability. In this instance (as is with JSOS that was brought up in other posts), a lower level language must be used to interface with the machine.

It is possible to write a minimum amount of code in a "raw" language such as C, but a raw compiled language is always going to be needed by definition. Once this is in place, other pieces of the OS can be implemented in a scripting language, but a scripting language could never be used alone.

share|improve this answer

I must maintain that it is, in principle, possible to write an operating system in python. You would have to produce a Python-to-low level language compiler, as well as add modules to the standard library that provide access to the low level pieces of your computer. But if those two pieces were in place it would be possible.


  1. Its going to be really hard to write a compiler that produces efficient code
  2. Python is going to be awkward for accessing low level details
share|improve this answer
Also, Python in this scenario would no longer qualify as a 'scripting language' by any sensible definition. – tdammers Jun 29 '12 at 7:49
@tdammers, I consider scripting language to be an ill-defined concept anyways. – Winston Ewert Jun 29 '12 at 15:22

Not the answer you're looking for? Browse other questions tagged or ask your own question.