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

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
amirsaniyan
Posts: 2
Joined: Tue May 22, 2012 5:12 am

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

Post 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?
Attachments
OS.png
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

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

Post 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.
amirsaniyan
Posts: 2
Joined: Tue May 22, 2012 5:12 am

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

Post 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?
User avatar
DavidCooper
Member
Member
Posts: 1150
Joined: Wed Oct 27, 2010 4:53 pm
Location: Scotland

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

Post 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?
Help the people of Laos by liking - https://www.facebook.com/TheSBInitiative/?ref=py_c

MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming
User avatar
Griwes
Member
Member
Posts: 374
Joined: Sat Jul 30, 2011 10:07 am
Libera.chat IRC: Griwes
Location: Wrocław/Racibórz, Poland
Contact:

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

Post 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.
Reaver Project :: Repository :: Ohloh project page
<klange> This is a horror story about what happens when you need a hammer and all you have is the skulls of the damned.
<drake1> as long as the lock is read and modified by atomic operations
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

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

Post 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.
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

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

Post 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.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

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

Post 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.)
Every good solution is obvious once you've found it.
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

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

Post by iansjack »

berkus wrote:webOS?
What has yet another OS written in C got to do with this discussion?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

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

Post by Combuster »

I think the point was that the OP would be better off building on top of a browser-only system...
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

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

Post 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.
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

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

Post by iansjack »

Ah. Fair enough.
User avatar
~
Member
Member
Posts: 1228
Joined: Tue Mar 06, 2007 11:17 am
Libera.chat IRC: ArcheFire

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

Post 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).
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

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

Post 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.
User avatar
NickJohnson
Member
Member
Posts: 1249
Joined: Tue Mar 24, 2009 8:11 pm
Location: Sunnyvale, California

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

Post 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.
Post Reply