This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Lupus590's profile picture

Got any tips for making an OS? Well actually a shell.

Started by Lupus590, 10 March 2015 - 11:39 AM
Lupus590 #1
Posted 10 March 2015 - 12:39 PM
I have a project that I'm working on which looks like it may end up having it's own coroutine manager.

Also, recently I've been looking at other peoples OSs, and how CC multishell and window APIs work (heard some complaints about different things).

Any way, I want to know what I should and should not do in writing an OS/shell. If you have made an OS/shell before, please share you what you've learned. Any essential/popular features?

P.S. I don't plan to add Pre-1.73 support
P.P.S. I'm aware that you can't make a proper OS in CC but that's what every one calls their shell so… yeah.

I've started work on the non-OS parts: http://www.computercraft.info/forums2/index.php?/topic/22421-wip-mit-hive-automating-the-things-that-automates-all-the-other-things/

My basic design idea is an improved shell with multi-tasking and non-colour.

My Notes
[namedSpoiler=Don'ts][list]
[*]Fake loading screen
[*]File spamming(why have 8 APIs just to get 1 API to function?)
[*]Sequels e.g. MyOS 2(unless the OS is revamped in GUI/Functionality)
[*]use default multi-shell nor window API
[/list]
[/namedSpoiler]

[namedSpoiler= Ideas]
[b]Key:[/b]
[s]Not possible[/s]
[i]When I develop, these features will be prioritised[/i]

[b]General[/b][list]
[*][i]multi-shell like interface with options to switch tabs (ctrl-tab? [url="http://en.wikipedia.org/wiki/Fn_key"]fn keys[/url]?) must be non colour compatible[/i]
[*][i]static program IDs[/i]
[*][i]inter program communication (via events, one program does a special queue action, perhaps os.message(programID,message), which sends an event to another program, the 2nd program collects the event the normal way)[/i]
[*][i]speed - default ui as comand line with optional gui[/i]
[*]colours must be "clean and matching"
[*]everything must be spaced out well - not [url="http://www.ssw.com.au/ssw/Standards/Rules/Images/badui2.jpg"]this[/url]
[*]optional gui
[*]customisation - UI Colours, language - store config in lua table
[*]Multilingual - lang files (I will need translators, google is only so good) also due to lua, this will be limited to characters in the ASCII range (use nearest equivalent, é will become e, best of luck with non-latin text)
[*][i]found a cool API loader which is compatible with file extensions [/i][i][url="http://pastebin.com/P5PCiPyg"]http://pastebin.com/P5PCiPyg[/url] - thanks ElvishJerricco for letting me use this[/i]
[*]remote startup files (take a startup file from another computer via rednet) - I have no idea what this would be useful for
[*][i]apiUnloader which allows api's to do stuff 'before they leave' http://www.computerc...__fromsearch__1

Shell
  • tab auto-complete
  • bash like?
  • powershell like 'what if' - this may use alot of sandboxing
  • super user mode - the OS tries to protect it's own files but will allow full access if the user types in a password
  • hidden file - anything with a file name that starts with a . will be hidden (E.G. .git .meta .*), an argument to the ls command with show these (super user show too?)


Learning from others (This is not a name and shame)Examples Of What To DoExamples Of What Not To Do
Edited on 18 March 2015 - 02:45 PM
cdel #2
Posted 10 March 2015 - 12:54 PM
Speed, raw speed. In my opinion, the colour scheme has to be clean and matching, and everything must be spaced out well.
Lupus590 #3
Posted 10 March 2015 - 05:15 PM
had some more ideas:

shell
  • bash like?
  • powershell like 'what if'
Edited on 10 March 2015 - 04:15 PM
TheOddByte #4
Posted 10 March 2015 - 07:14 PM
Well it kinda depends, do you want to create an easy-to-use OS like OneOS? Or do you want to create an OS that has a lot of features and is more advanced to use? Are you leaning into the direction of creating a graphical OS or more of a command-based OS? My personal preference is command-based, and I like to stick with CraftOS, but most new users tend to go for the easy-to-use ones, so it kinda depends on what kind of audience you want

If you're going to create a graphical OS then it's pretty important to have in-built programs that you would find on a standard computer, programs like calculator etc.
Anyway, it's important that the OS runs smooth and has a clean look. Here's some OSes that handled multi-tasking very well IMO, they ran smoothly and had a pretty clean look. I'd suggest you try them out and see what people found appealing about them.Another thing I find pretty important is customization, people love to be able to mess around with color schemes and stuff.
And if you decide to create an OS you shouldn't abandon it and create a new one, as some others have done.

One last thingDon't make a NDF-OS clone! If you've been on the forums long enough you should know what I'm talking about :P/>
SquidDev #5
Posted 10 March 2015 - 08:56 PM
I agree with TheOddByte's suggestions, but I'll add some other things:

What don't you like about CraftOS? I say this because you have to know what you really want to improve, don't make another …-clone, make something that is worth the time it takes to download.

I'd lean towards a command based OS because I have yet to find an all-singing, all-dancing shell. ClamShell is wonderful but it has no multitasking or completion, the shells that have completion don't have scrollback or redirects, there isn't one 'end-all' product.

The key thing though is something different, I'd look through the Operating system threads with more than 5 pages and those with less than 10 posts. What did they do right or wrong?
Edited on 10 March 2015 - 07:56 PM
Agent Silence #6
Posted 10 March 2015 - 08:58 PM
Lets lay down a list of don'ts :
Spoiler
  • Fake loading screen
  • File spamming(why have 8 APIs just to get 1 API to function?)
  • Sequels e.g. MyOS 2(unless the OS is revamped in GUI/Functionality)

And I agree with Byte's suggestion.
Lupus590 #7
Posted 10 March 2015 - 09:20 PM
-snip-
What don't you like about CraftOS?
-snip-
need auto complete; I like MS powershell 'what if' command; I need multi tasking in a program I'm making which needs to run on several hundreds of turtles, since I will be using other peoples programs (with permission) it makes more sense for the OS to manage the coroutines, also I don't want nsh to be held up because my program crashed (lets hope my OS won't have this problem)

also, updated OP

Don't make a NDF-OS clone!

google hasn't helped me with this, can someone explain?
Edited on 10 March 2015 - 08:25 PM
KingofGamesYami #8
Posted 10 March 2015 - 11:13 PM
NDFJay created a series of youtube tutorials on how to make an "OS". This resulted in many new players with no experience creating copies of his program and posting them on the forums ("Look! I made an OS!")
Lupus590 #9
Posted 10 March 2015 - 11:31 PM
Thanks for explaining
Edited on 10 March 2015 - 10:31 PM
Lupus590 #10
Posted 12 March 2015 - 09:39 PM
added more to OP
  • customisation - UI Colours
  • Multilingual - lang files (I will need translators, google is only so good)
MKlegoman357 #11
Posted 12 March 2015 - 09:43 PM
Problem with languages is that many use characters that are not in ASCII, such as Crylic (did I spelled it right?) Cyrillic. CC doesn't support those.
Edited on 12 March 2015 - 08:45 PM
Geforce Fan #12
Posted 12 March 2015 - 09:51 PM
I would highly dis-recommend the use of the Window API. It is slow, and many programs nowadays are circumventing it.
Try this

Problem with languages is that many use characters that are not in ASCII, such as Crylic (did I spelled it right?) Cyrillic. CC doesn't support those.
This is entirely incorrect. ComputerCraft supports ASCII entirely, until you try to print them to the screen. So basically, you would have to edit the OS in a third party editor.
Lupus590 #13
Posted 12 March 2015 - 10:16 PM
if the character is not supported then it will have to use the nearest ascii equivalent so é will become e etc.

I've already heard the window API 'discussion' and will be using/making an alternative.

also, updated OP and added a priority system

had more ideas too:
  • super user mode - the OS tries to protect it's own files but will allow full access if the user types in a password
  • hidden file - anything with a file name that starts with a . will be hidden (E.G. .git .meta .*)
I'm lightly worried that the OS file protection will cause slowdown due to an overhead
Edited on 12 March 2015 - 09:44 PM
Geforce Fan #14
Posted 12 March 2015 - 10:22 PM
That's a lot of requirements.
[os] meets a lot of them. I have it on github, but it's really out of date. And it's in a sort-of public alpha. It's on github, but there's no post
Lupus590 #15
Posted 12 March 2015 - 10:55 PM
That's a lot of requirements.
[os] meets a lot of them. I have it on github, but it's really out of date. And it's in a sort-of public alpha. It's on github, but there's no post
Got a link to that github repo? The search turn up nil and I think your [os] may be a good "giant to stand on the shoulder of"
Edited on 13 March 2015 - 11:20 AM
Lignum #16
Posted 13 March 2015 - 04:35 PM
This is entirely incorrect. ComputerCraft supports ASCII entirely, until you try to print them to the screen. So basically, you would have to edit the OS in a third party editor.

No, he's correct. Lua doesn't support these characters. And even if it did, if CC can't display them then what's the use of using a third party editor to add them to your code?

Anyway, back on topic.
The most important thing to remember is that an OS is not a fancy interface for your computer. An OS is intended for the programmer. If Windows didn't have its API, we would still be addressing the hardware manually in our programs. In ComputerCraft, there's already an API for dealing with these low-level components, however there are also other essential features, like multitasking, which you need to worry about. Basically, create the best environment you can for programs to run in. Then, you build your OS's user interface with the features that your core provides (desktop is a task, etc.).
Lyqyd #17
Posted 13 March 2015 - 04:53 PM
For clarity, Lua doesn't care what you put in your strings. Lua doesn't reserve any values, including NUL, so you can put whatever binary data in a string that you so desire to. However, the built-in string manipulation functionality all assumes that one byte is one character, so using Unicode that require multiple bytes in UTF-8 or using multibyte fixed-width encodings is going to present a few difficulties. In addition, ComputerCraft is unable to display characters outside of a certain set (everything with byte values > 127, among others), and any characters in the set that can't be displayed are also mangled when sent through rednet, or saved to a file, and possibly other operations. In plain Lua (and in ComputerCraft, if you're careful), it is possible to work around the limitations and correctly manipulate strings containing non-ASCII characters. Non-ASCII characters in strings is neither entirely supported nor entirely unsupported.
Lupus590 #18
Posted 13 March 2015 - 05:21 PM
If you check my idea list you will see a prioritised list (italics is prioritised) also making a GUI will be one of the last things I do (and it will be the non-default mod of the OS)

As for features for programs, a non-colour PC compatible multi-shell (hopefully faster than the vanilla one), and the ability for programs to exchange data via events. To facilitate the latter, static program IDs.

Including the above, additional prioritised features are for the shell: auto-complete, and protected/hidden files with a super user mode.

Also, I've noted the somewhat limited support for the multilingual feature in the OP.

added this to the OP http://pastebin.com/P5PCiPyg
Edited on 13 March 2015 - 07:38 PM
Lupus590 #19
Posted 14 March 2015 - 11:59 PM
updated OP

new ideas:
  • remote startup files (take a startup file from another computer via rednet) - I have no idea what this would be useful for
  • apiUnloader which allows api's to do stuff 'before they leave' http://www.computerc...__fromsearch__1
Lupus590 #20
Posted 18 March 2015 - 03:46 PM
Updated OP

also, I've started work on the non-OS parts: http://www.computerc...e-other-things/
Geforce Fan #21
Posted 20 March 2015 - 02:17 AM
This is entirely incorrect. ComputerCraft supports ASCII entirely, until you try to print them to the screen. So basically, you would have to edit the OS in a third party editor.

No, he's correct. Lua doesn't support these characters. And even if it did, if CC can't display them then what's the use of using a third party editor to add them to your code?

Anyway, back on topic.
The most important thing to remember is that an OS is not a fancy interface for your computer. An OS is intended for the programmer. If Windows didn't have its API, we would still be addressing the hardware manually in our programs. In ComputerCraft, there's already an API for dealing with these low-level components, however there are also other essential features, like multitasking, which you need to worry about. Basically, create the best environment you can for programs to run in. Then, you build your OS's user interface with the features that your core provides (desktop is a task, etc.).
I've put symbols on comment lines with no problem.
Lupus590 #22
Posted 20 March 2015 - 07:42 AM
I believe this is because any character that CC doesn't recognise is replaced with '?'
Lignum #23
Posted 21 March 2015 - 01:54 PM
I've put symbols on comment lines with no problem.

Yes, that's probably possible. However, what I meant is that Lua can't deal with non-ASCII characters in strings. You can use them in strings, but none of Lua's in-built string manipulation functions can handle them properly. Lyqyd's post explains this very well.
Bomb Bloke #24
Posted 21 March 2015 - 11:52 PM
To be clear, Lyqyd is saying that Lua works just fine with many non-ASCII characters, but doesn't handle Unicode (bearing in mind that "non-ASCII" doesn't automatically mean "Unicode").

The main issue is that the particular implementation of Lua that ComputerCraft uses, an old build of LuaJ, is bugged. LuaJ's problems aren't representative of Lua itself.
Geforce Fan #25
Posted 22 March 2015 - 06:59 PM
Also to be noted is that "»" seems to work if you format your program in something other than unicode.
» is <127. How come I can print it to the screen?
Lignum #26
Posted 22 March 2015 - 08:25 PM
Also to be noted is that "»" seems to work if you format your program in something other than unicode.
» is <127. How come I can print it to the screen?

ASCII is 8-bits. That means you can have 256 characters.
Edited on 22 March 2015 - 07:26 PM
Lyqyd #27
Posted 22 March 2015 - 08:45 PM
ASCII is actually seven-bit, but is usually stored in one character per byte.
Bomb Bloke #28
Posted 22 March 2015 - 10:51 PM
… and it's often confused with the likes of code page 437, which is 8bit and is what I wish we had.
Geforce Fan #29
Posted 22 March 2015 - 10:57 PM
ASCII is actually seven-bit, but is usually stored in one character per byte.
The wasted space! Why?!!??!?
Bomb Bloke #30
Posted 22 March 2015 - 11:21 PM
Psst - read the article, it explains why. ;)/>