I have moved my blog to Wordpress at theunixgeek.wordpress.com. I will still be checking back periodically on this one as well, though. 19 April 2009

featured

Merging Mkdir and Cd | 280 Slides Interview | I Switched to KDE 4

clickable portals

Wednesday, May 23, 2007

A Simple Lecture on Operating Systems

****I'm a beginner to this depth of computer science - please leave any comments with corrections if any errors are spotted. Thank you!****

I'm forgetting about Python and learning C. I'll need it to write the OS I'm working on. Well, I'm not forgetting about Python entirely, but I'm abandoning it for good reasons.

First, every time the user you run a Python program, it needs to be interpreted. This may cause pain for the user, having to use chmod +x over and over again. What is the difference between interpreting and compiling? Compiling is when you have the pure source code and you save it in runnable machine-language form. In C, it's only done once, which means the developer can compile it once and the user doesn't have to go through the pain of compiling for every time they download the file. They just click, and off they go! In Python,  an interpreted language, the code is sort of like a one-time use camera: you type in python foo.py and foo.py is run, but isn't saved as an executable. Also, C is more widely used in Windows PC's, the most widely used platform in the world (Python only comes pre-installed on most modern UN*X systems).

Secondly, it's harder to write an OS in Python because it's so distant to Assembly, the main OS language. It's easier to write an OS in an assembly-C(++) combo.

In an OS, the main boot file (the file that boots the computer) is written in assembly, while the actual OS program is written in C. The makefile basically describes how the system is built, and all that to run a simpler C program.

Now, why is it easier to write an OS in C than in Python? Let's see the family tree (these are metaphors)!

"And Fortran created the Programming Language World, and upon it placed Assembler. Assembler begat C and C++, fraternal twins, and BASIC. Now, the twins moved to a far away land. And the twins begat Perl, who in turn begat Python. Perl was very different from his father due to the fact that he was born so far away from his father's homeland. Now, Perl was dumbed down compared to his father, and Python was not the brightest around."

Python is really far from Assembler, like BASIC. None of BASIC's "descendants" can be used to program an OS.

What about some semi-modern OS's? UN*X and DOS, for example. UN*X is written in an Assembler-C combo. DOS is written in an Assembler-Batch combo. Batch is a language the developers made to ease their writing of the OS. Batch is a really quick and easy language, somewhat like BASIC.

That's just a basic lesson on operating systems, a fundamental step to studying computers. But this is just a scratch on the surface of a wonderful science.

digg it

2 comments:

underdog5004 said...

The only big thing I would point out is this: Why use "Un*x" to describe unix-type OS's? I've seen this done over and over again, with various permutations, eg. *nix, *nux, etc. The most accurate way to describe an OS would be unix-type, or Windows.

Tom said...

"First, every time the user you run a Python program, it needs to be compiled."

You must have gotten a little confused there. Python is interpreted, therefore programs written with it don't need to be compiled.