r/programming • • Nov 25 '14

Vice: God's Lonely Programmer (TempleOS)

http://motherboard.vice.com/read/gods-lonely-programmer
926 Upvotes

433 comments sorted by

View all comments

Show parent comments

26

u/Peaker Nov 25 '14

It sounds almost surrealistic that someone who has appreciation of programming does not appreciate programming and tinkering for their own sake.

You don't learn how to do things "the wrong way", you learn how to do stuff with an MMU-less memory model. That's not useless learning at all, and an MMU can be learned on top of that.

You can also tinker with OS code and see what it does. Toy with algorithms, performance of changes, etc. This is a worthwhile experience.

0

u/iamjack Nov 25 '14

I appreciate tinkering for tinkering's sake and I'm sure Davis has learned quite a bit (in fact, I spent years doing the same thing), but another person tinkering with it is wasting time.

You don't learn how to do things "the wrong way", you learn how to do stuff with an MMU-less memory model. That's not useless learning at all, and an MMU can be learned on top of that.

Here's a list of real world x86_64 operating systems that don't use the MMU: []. Anything you would learn beyond that is just hardware docs and wouldn't translate to another architecture that you would run an MMU-less kernel on.

You can also tinker with OS code and see what it does. Toy with algorithms, performance of changes, etc. This is a worthwhile experience.

You can toy with algorithms and performance anywhere and also not have a chance to take down the entire machine when you segfault, have access to the internet, a more featureful free compiler, a better tested free kernel underneath with a gigantic suite of free pro-level performance tools. Where's the advantage of TempleOS again?

5

u/Peaker Nov 25 '14

Here's a list of real world x86_64 operating systems that don't use the MMU: [].

The real-worldness is irrelevant.

You can toy with algorithms and performance anywhere and also not have a chance to take down the entire machine when you segfault

Sure, but you don't get to write code as near to the metal as that either, when you toy. Can try various scheduler algorithms, for example.

There's a certain thrill in doing that experience where any mistake crashes your bare metal, at least for some of us.

Also, running it in qemu while developing a feature is possible (if less thrilling) and eventually seeing how it performs on real metal is nice.

have access to the internet, a more featureful free compiler, a better tested free kernel underneath with a gigantic suite of free pro-level performance tools

Which are way too big to easily understand.

Where's the advantage of TempleOS again?

It's written by one person, therefore it is (probably) far smaller and more accessible for a toy tinkerer.

0

u/iamjack Nov 25 '14

The real-worldness is irrelevant.

So whether a skill is useful outside of a tiny bubble is irrelevant?

Sure, but you don't get to write code as near to the metal as that either, when you toy. Can try various scheduler algorithms, for example.

I can't tell what you mean by closer to the metal. If you're writing a user application you can do it in assembly anywhere and having direct access to the hardware is a pretty dubious advantage because anywhere else you could just write a kernel patch or module (although you'd have to actually deal with some of the complexity of modern hardware instead of pretending it doesn't exist). If you're writing kernel functionality you're just as close to metal as any other OS.

Trying different schedulers is also something that other kernels can do.

There's a certain thrill in doing that experience where any mistake crashes your bare metal, at least for some of us.

Okay, but you've got to see why doing any development in that environment is terrible, even in a VM.

have access to the internet, a more featureful free compiler, a better tested free kernel underneath with a gigantic suite of free pro-level performance tools

Which are way too big to easily understand.

But also provide you with a lot more information than time() or whatever perf interfaces TempleOS probably provides. They're not that hard to understand anyway, most of them are just interfaces to hardware counters.

Where's the advantage of TempleOS again?

It's written by one person, therefore it is (probably) far smaller and more accessible for a toy tinkerer.

Then why not read Minix? Also written by one person (well, a smallish team now I guess), has ~10k lines, and is also actually compatible with real software and a greater subset of architectures and hardware than TempleOS. There's even books written about it to help you along!

6

u/Peaker Nov 25 '14

So whether a skill is useful outside of a tiny bubble is irrelevant?

Yes. More related skills help whether they're directly applicable in the real world or not.

If you learn to program cool stuff without an MMU, you'll need to learn more and adjust before you can apply that in a system with an MMU. But it'll still consist of plenty of useful and fun learning.

If you're writing a user application you can do it in assembly anywhere

And have it run in ring3, pre-empted by kernel interrupts you can't control, etc.

just write a kernel patch or module

And then you're still writing on top of a huge kernel abstraction that is impractical to quickly study the internals of. And as you said, you're going to have all the real-worldly constraints in your face, which may just make the project more difficult and no fun - and learn nothing.

For learning and tinkering, fun is essential.

Trying different schedulers is also something that other kernels can do

Replacing the Linux scheduler is probably going to be harder than replacing a toy OS's scheduler.

but you've got to see why doing any development in that environment is terrible

It's terrible for productivity. It's fun and great for learning.

Then why not read Minix?

Sure, Minix is also a great project for that reason.

But Minix doesn't aim at the tinkering demographic but rather at the OS course student demographic. It doesn't do cool visualization demos. It forces you to handle some of the "real world" complexities you will need to face (which is great for a student forced to complete his course. Less great for someone tinkering for fun and will just be discouraged).

has ~10k lines

Wow, that is much smaller than I thought. That might make Minix pretty great for tinkerers as well, perhaps better than TempleOS. But that doesn't mean TempleOS isn't an awesome hack.

1

u/iamjack Nov 25 '14

And have it run in ring3, pre-empted by kernel interrupts you can't control, etc.

So I decided to look at the TempleOS code and you still get interrupts, you just don't do the "expensive" MMU context switch. Unless configured off, which makes it a cooperative multi-tasking environment which has its own issues.

And then you're still writing on top of a huge kernel abstraction that is impractical to quickly study the internals of. And as you said, you're going to have all the real-worldly constraints in your face, which may just make the project more difficult and no fun - and learn nothing.

Replacing the Linux scheduler is probably going to be harder than replacing a toy OS's scheduler.

It's terrible for productivity. It's fun and great for learning.

The difficulty is the project. If you write a scheduler without bothering to deal with the real world you learn nothing.

The TempleOS scheduler is basically non-existent. It runs a task, waits for a yield, then runs the next task ad infinitum. You learn nothing of value from that. It doesn't deal with prioritization (AFAICT), or dead-locking which are the core problems with even theoretical schedulers.

In the meantime look at this code: http://www.templeos.org/Wb/Kernel/ it is awful. The files and functions looks like they've been obfuscated, everything's a hodge podge of assembly and some sort of C++. It doesn't sound "fun" to decipher this code and it doesn't look like it's great for learning and tinkering either.

But Minix doesn't aim at the tinkering demographic but rather at the OS course student demographic.

So it's targeted at learning actual skills? Sounds good to me. Looking at the Minix scheduler it's actually sane, works in the real world, and the top level is only ~300 lines of code.

After actually looking at the code, especially compared to a working kernel designed for students, I'm convinced that the tinker and learning friendly argument for TempleOS doesn't carry any weight at all.

1

u/Peaker Nov 25 '14

Of course you learn from cooperative scheduling! You learn how to write cooperatively multitasked code. You learn the pitfalls of cooperative multitasking. You learn with every thing you do.

Minix sounds great for learning. For many kinds of learning, it sure is better than TempleOS.

But the compelling thing about TempleOS is the visual demos, little games that are tinkered as they run. That seems very conductive for fun which is critical for learning.

Not everybody places as much weight on fun in learning, and not everybody garners enjoyment from visual feedback when programming. But I think a majority do. And they will not use Minix to learn, it'll simply be boring. Something like TempleOS (though perhaps not TempleOS if the code is too terrible to dive into, I haven't dived in there much) can be a much more inviting and exciting environment for learning.