Page 1 of 2

An idea: Create an OS that's written in a scripting language

Posted: Mon Jul 02, 2012 2:57 pm
by amirsaniyan
I have an idea about creating an OS.
My idea is: Create an OS that's written in a scripting language (eg. JavaScript or Python).

This image shows the architecture:

Image

Note:
HAL written in ASM/C/C++ and should be minimal. Some classes like CPU provides Interrupts/Privileges (Even CPU like Z80 not supported that feature).
OS (Kernel, Drivers and ...) written in a scripting language (eg. JavaScript or ECMA Script).
Applications written in a scripting language too (eg. XHTML + CSS + JavaScript).

Benefits:
* Open Source (Because OS written in a scripting language)
* Easy to port to other Hardwares.
* Easy to port to Mobile devices.
* Easy to debug.
* Easy to update.
* XHTML, CSS, JavaScript are popular.
....

Is it a good idea to create an OS that's written in a scripting language?
For example, how about creating an OS using JavaScript?

Re: An idea: Create an OS that's written in a scripting lang

Posted: Mon Jul 02, 2012 3:02 pm
by iansjack
Is it a good idea to create an OS that's written in a scripting language?
No.
For example, how about creating an OS using JavaScript?
No.

Re: An idea: Create an OS that's written in a scripting lang

Posted: Mon Jul 02, 2012 3:08 pm
by amirsaniyan
iansjack wrote:
Is it a good idea to create an OS that's written in a scripting language?
No.
For example, how about creating an OS using JavaScript?
No.
Why?

Re: An idea: Create an OS that's written in a scripting lang

Posted: Mon Jul 02, 2012 3:16 pm
by DavidCooper
What sort of performance do you expect to get out of it? Would it not be like designing a new kind of high-speed train to be pulled along by oxen?

Re: An idea: Create an OS that's written in a scripting lang

Posted: Mon Jul 02, 2012 3:22 pm
by Griwes
* Open Source (Because OS written in a scripting language)
Written in a scripting language, so what? Do you think they are not compilable?
* Easy to port to other Hardwares.
The same is true for every OS written with porting in mind.
* Easy to debug.
How so?
* XHTML, CSS, JavaScript are popular.
True, but two of them are *really* broken. And it's by design.
My idea is: Create an OS that's written in a scripting language (eg. JavaScript or Python).
It's not really your idea, don't you know? Why, do you think, there is no JS or Python OS you've heard of? I assume you: not because no-one ever said "I have an idea to create OS in JS...", because you're definitely not the first one to say so.
(Even CPU like Z80 not supported that feature)
That's an argument for keeping C++ level minimal?
Is it a good idea to create an OS that's written in a scripting language?
No, because it's broken by design (by design, because they are called *scripting languages*, not *system programming languages*, think about it for a second).
For example, how about creating an OS using JavaScript?
http://roflcopter.pl/5682 wrote:<omarqureshi> some fuckmuppet wrote a javascript interpreter in javascript
<omarqureshi> https://github.com/jterrace/js.js
<omarqureshi> "It currently takes about 40 seconds to run print(1+1)"

Edit: ah, forgot about something. "Class" isn't some magical creature, y'know.

Re: An idea: Create an OS that's written in a scripting lang

Posted: Tue Jul 03, 2012 12:48 am
by iansjack
amirsaniyan wrote:
iansjack wrote:
Is it a good idea to create an OS that's written in a scripting language?
No.
For example, how about creating an OS using JavaScript?
No.
Why?
I'll tell you what. Write an ext2fs driver in javascript and post it somewhere where I can review it; then I'll answer your question.

Re: An idea: Create an OS that's written in a scripting lang

Posted: Tue Jul 03, 2012 12:52 am
by bluemoon
amirsaniyan wrote:This image shows the architecture:
You have omitted a thousand layer in between the block in the architectural diagram, before we go into implementation detail like the choice of script language.

Re: An idea: Create an OS that's written in a scripting lang

Posted: Tue Jul 03, 2012 1:21 am
by Solar
Basically:
  • The desire to use scripting language is usually felt by people who consider compiled languages "difficult". That is about the same group of people that will find OS development "insanely difficult".
  • Most people from above group fail to realize that much of the "comfort" they feel when using their scripting language of choice is due to its runtime environment and standard library. Neither is available in kernel space. Porting runtime and standard library is about 95% of the work inherent in "writing an OS", or "porting to other hardware". (I.e., the "HAL" box in your schematics is the OS.)
  • There are many tools available for debugging ASM or C code, even in kernel space. They are easy enough to use for anyone who knows those languages. There is no advantage to be had in the debugging department by chosing a scripting language; to the contrary actually.
  • Whether or not something is OpenSource is not a factor of the language, but a factor of the license. If I post a piece of JavaScript and write "all rights reserved", that prohibits you from using it legally just as much as if I'd posted a binary without source. If I post C source and write "CC0", that's as open as it gets. Again, the advantage of scripting languages might be felt, but it's not real.
  • XHTML and CSS are not programming languages at all, and utterly insufficient to build anything worth the name "application".
Basically, your request shows that you haven't read the Wiki (Beginner Mistakes, section "Programming Languages"), and it's a safe bet that you have not much of a mental picture of what OS development is actually about. Actually, I'd be willing to bet money that you don't even have a mental picture what application development, let alone system development is about.

Sorry, but your suggestion cannot be taken seriously. (And hasn't, not in the >10 years that I dabble in this subject, not in the many dozen occurrences of some web designer popping up with that same idea.)

Re: An idea: Create an OS that's written in a scripting lang

Posted: Tue Jul 03, 2012 2:13 am
by iansjack
berkus wrote:webOS?
What has yet another OS written in C got to do with this discussion?

Re: An idea: Create an OS that's written in a scripting lang

Posted: Tue Jul 03, 2012 4:15 am
by Combuster
I think the point was that the OP would be better off building on top of a browser-only system...

Re: An idea: Create an OS that's written in a scripting lang

Posted: Tue Jul 03, 2012 4:55 am
by iansjack
I'm still not sure that I understand. The OP wants to write an OS, and this is a site dedicated to OS development. I'm not sure that writing user applications in javascript is of much interest in this context.

Re: An idea: Create an OS that's written in a scripting lang

Posted: Tue Jul 03, 2012 6:11 am
by iansjack
Ah. Fair enough.

Re: An idea: Create an OS that's written in a scripting lang

Posted: Tue Jul 03, 2012 6:48 am
by ~
amirsaniyan wrote:I have an idea about creating an OS.
My idea is: Create an OS that's written in a scripting language (eg. JavaScript or Python).

This image shows the architecture:

Image

Note:
HAL written in ASM/C/C++ and should be minimal. Some classes like CPU provides Interrupts/Privileges (Even CPU like Z80 not supported that feature).
OS (Kernel, Drivers and ...) written in a scripting language (eg. JavaScript or ECMA Script).
Applications written in a scripting language too (eg. XHTML + CSS + JavaScript).

Benefits:
* Open Source (Because OS written in a scripting language)
* Easy to port to other Hardwares.
* Easy to port to Mobile devices.
* Easy to debug.
* Easy to update.
* XHTML, CSS, JavaScript are popular.
....

Is it a good idea to create an OS that's written in a scripting language?
For example, how about creating an OS using JavaScript?
I have a similar idea for my projects: Create a proper kernel in C/Assembly and the like, build a compiler that can combine different languages and compiles them, including a language like JavaScript for some aspects that aren't the core of a component but that can make such component more maintainable and readable, and use as many standards as possible to make it worthy. Some of those standards would be HTML/XHTML/JavaScript/CSS to build a GUI that obeys standard practices and in which we can use HTML to create an application's GUI, probably compiling it partially or totally to native code or some bytecode. However, there should always be the option of using any other languages.

I would say it is a good idea only if you are capable of writing all of the above for yourself, use scripting languages as compiled code ultimately if you use them for parts of the system/kernel itself, and let the programmer choose the use of regular APIs, or fancy and easy interfaces that, like JavaScript, require no configuration from the end user/end developer. Otherwise it would be so pointless that you simply won't be able to implement that OS to begin with.

You still have a lot of work ahead, and will need to start with very low level stuff anyway, which won't be so fancy from that point of view, while you get the huge experience required to be capable of creating such a complex environment properly.

After all, if it wasn't a good idea to have such languages in an OS, they wouldn't be in the OS'es everyone use normally; but they must be used correctly, not necessarily in the same old way in which they have been used so far, but efficiently, and just compile them if it is beneficial to do so. And don't leave out the possibility of the rest of languages like C and Assembly, since they are still the primary ones in OS development, and in applications to.
iansjack wrote:I'll tell you what. Write an ext2fs driver in javascript and post it somewhere where I can review it; then I'll answer your question.
I would be one to do so if I had enough information and expertise on ext2. However I have implemented tiny parts of FAT12 in JavaScript, and could finish a driver that can at least read the root directory, but since I already have a working implementation in assembly, I see no practical use for a FAT12 JavaScript driver in the short term, or maybe only to create an interactive tutorial about it with a driver in the web browser.

It is common knowledge that JavaScript can handle binary data easily in modern browsers since FireFox 3 (use Base64 functions btoa to load the binary data as plain text, and decode it back to its binary form using atob; in this way you could, for instance, request or embed part or all of a floppy image and parse it with pure JavaScript). Working with raw binary data in JavaScript is no longer something to be afraid of (at least not in moderate quantity, and in the default environment of a web browser, mainly to read it, unless you build an extension or use a web server to have it make writes to a file to save what you did at the JavaScript side).

Re: An idea: Create an OS that's written in a scripting lang

Posted: Tue Jul 03, 2012 8:39 am
by iansjack
Writing OS drivers is not a question of handling raw byte data. If anything it is the opposite - you need the ability to treat data as complicated structures. I don't believe that javascript was designed with this in mind.

I'm sure that you are very expert in javascript, yet you have only been able to implement "a tiny bit" of a FAT driver, which is a relatively simple task. As for ext2fs, if you are interested copious documentation is available on the web.

If you just want to run javascript programs on top of a C/asm kernel, that's hardly revolutionary.

Re: An idea: Create an OS that's written in a scripting lang

Posted: Tue Jul 03, 2012 8:53 am
by NickJohnson
The only scripting language I would ever attempt to write system components in is Lua. Even then, there would be a lot of work to be done writing extensions to it in C to make it suitable for driver writing. In general, I'd say it's more work than it's worth.