Skip to content

Instantly share code, notes, and snippets.

@SquidDev
Last active June 26, 2021 10:20
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SquidDev/6fa444798bbe01f4068bf82a76ac273f to your computer and use it in GitHub Desktop.
Save SquidDev/6fa444798bbe01f4068bf82a76ac273f to your computer and use it in GitHub Desktop.

If you've been sent a link to this by someone on Discord/IRC/the forums in response to "how do I make an OS?", please don't feel discouraged by this document! It's a bit grumpy at times (like me), and won't provide any technical insight, but hopefully should get you thinking a bit more about the design process.

I do think the whole thing is worth reading, but as a TLDR:

  • CC OSes are generally a little boring - there's far more interesting projects you can work on!
  • If you want to write an OS (or any project), think a little bit about what it's going to do (and what problems it solves) first.
  • Have fun! Don't let this document (or other people) discourage you from making what you want!

I want to write an OS

Read the TLDR above before digging into this!

Don't. Find something else interesting to write. Most operating systems end up being glorified startup screens. The ones which don't generally opt for features which are "cool" or exist in real life operating systems rather than those which make life easier for the user.

Instead write an actual program. Something fun, something useful, something completely useless and over-complicated. Whatever. As long as you learn a ton and have fun I don't care - that is what ComputerCraft is about :). But please don't just make an operating system.

If you're struggling for ideas have a look through Idea Exchange, Or find a useful file format or algorithm which hasn't been implemented in CC yet (DEFLATE compression, PNG and JPEG spring to mind). Do some reading and write a type checker for Lua. Or something which will insert runtime type checks if that is simpler. Maybe write a tic-tac-toe game with an AI (look at algorithms like Min-max). But please don't just make an operating system.

I really want to write an OS

If you insist on making one, make a significantly better shell - see this and this thread. Take some inspiration from ClamShell and MBS

But I want to write a Linux clone!

We've had so many Linux knockoffs I've lost count. Think about the things the Linux kernel does: daemons, process scheduling, drivers, memory managements. All of these are either implemented already in bios.lua or, if they are not, mean people have to write code which depends on your OS' APIs: something which is rarely happens.

My question is why do you want to write an "OS"? There is a whole range of far more exciting and interesting programming challenges out there. Do something which will make me go "wow" rather than "Mark this forum as read".


Originally from this forum thread

Planning an Operating System

So there's several things I think when I see someone start a new OS (or any project) and, whilst you've clearly put some planning into this, none of them are answered here or on the repo. They all boil down into one big question:

What problem does this operating system solve?

The reality is that there are 350 odd CC OSes on this forum already and, whilst they vary from glorified startup screens to 600kb behemoths, few of them answer this question. People have gone "I want a GUI" or "I want a linux clone" without sitting down and thinking really hard about what that actually means. I love Linux as much as the next developer, but you've got to think about what's worth taking from there (i.e. shell syntax (technically separate program but w/e)) and what's not (drivers).

My advice is twofold: First read the grumpy rant above, as it covers some of these thoughts in a little more details. Then, if you're still up to it, sit down with a piece of paper (and I do mean paper) and have a long hard think about the following questions:

  • What about CraftOS is bad, and who does that impact? As a developer, I dislike how painful working in the shell and Lua REPL can be (hence MBS). Maybe you think it's not accessible to new users of the mod. Or maybe there's some tooling (such as a package manager) you're missing.
  • Now you've established a target and problem, how are you going to solve it? Maybe this doesn't involve writing an OS, but a standalone utility (such as MBS or the various package managers).
  • If it still involves writing an OS, what features are relevant to that problem, and how to they help solve it?

Because apparently I have too much time (why am I not in bed right now), I'm going to have a look at two CC OSes. Note it's been a while since I looked at either, so take my comments with a pinch of salt.

Firstly, PearOS: this was the precursor to OneOS, and I think the same points apply to that too. As the OP states, PearOS was designed for people who have no clue what they're doing with CC. It's not going to help someone who's a master of the mod, but acts as a useful introduction beyond just running adventure. There's a reason it's one of the most popular topics on the OS forum (OK, that reason might be because oeed is a literal and figurative wizard when it comes to GUIs).

Secondly, VorbaniOS: This aims to provide a more *nixy approach over ComputerCraft. Whilst the code is clean, and an architectural masterpiece, I'm really not sure what the point is. I've never really sat down and gone "hrmrm, I do wish I could index peripherals as devices". Maybe someone has found a use for that though - I'll happily retract my criticism if wrong.

My point isn't that one type of OS is better than another, it's that you've got to have a clear problem you're trying to solve, and a goal in mind before setting out. Otherwise you're almost doomed to failure. That being said, there's no harm in experimenting in these sorts of projects as anything outside one's comfort zone is going to make you a better developer. I know I've re-invented the wheel enough times myself, it's just when there's 350 other near-identical wheels out there already, one does have to raise eyebrows.


Originally from this forum thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment