Could an OS be written in the Red programming language? Would you want to?

I have been reading about Red, a programming language based on Rebol. It claims to be a “full stack” programming language that, by using specialised “dialects”, can be used for everything from basic systems programming to writing scripts.

Would this be an excellent language to write a full operating system? If everything is a dialect of the same language, would it allow for even the terminal shell to be unique and use a dialect of Red? That would be similar to how Redox operating system (written in rust) has its own shell, and Nu shell also claims to take advantage of having been written in Rust to allow things not offered in other shells.

Perhaps an operating system written in Red could incorporate new design paradigms. For example the Theseus system, written in Rust, has architecture and features inspired by its host language. As you can see, Rust has inspired a lot of re-imaginings of fundamental operating system components, and whilst this is largely due to its reputation for safe memory management, perhaps Red could also inspire new ways of doing things? Since Red is quite new as a language and at time of writing only version 0.64, could its use in a new operating system could accelerates evolution towards full release? I understand Unix and the C language were co-developed in this way.

So what do others here think about Red, operating system design generally, or even all these Rust based projects for new system components?

OSes should not be written in new, unproven languages IMO.

I’d posit that writing an OS in a language is an excellent way to “prove” it. I fundamentally disagree with considering something unfit for use because it’s unproven — how would a language only ever used for toy programs prove itself?

2 Likes

by being used for big programs that are NOT critical to the continued functioning of the system.

From what it looks like, you can cobble together a team and get some form of uLinux or Fuzix working, and then you can test it out. I’d say if it claims to be full-stack, then it should work.

If you can make a toy, functional OS (a funcitonal linux kernel), and it’s not complete garbage, then the language is proven to be useful. It already looks very promising, and you can test it on something as cheap as a raspberry pi!

1 Like

I am not sure of the reason for your view, which is not elaborated on in your subsequent post either.

Is it that you think the resultant operating system might be untrustworthy? Or that your concern is for the developer, who might find the programming language shifting under their feet?

My counter to the first is that developing an operating system is such a long term undertaking that by the time it is ready for release the programming language, which might have been immature at the start of the project, will have also been refined.

As for the second , even an operating system built on a reasonably mature language is not on immutable foundations over the time taken for it to mature. Take Haiku for instance. According to Wikipedia it started in 2002 (it is now in Beta) and stuck with the GCC compiler v2 for BeOS compatibility. The 64 bit version where this is not a concern uses GCC 8. Whilst this might be an extreme gestation period, even Google - with all its resources - had Fuchsia in development since 2016.

Whilst that would prove the concept, the last thing I had in mind was the implementation of a 30+ year old kernel. Rather I was wondering what cool things might be possible with a brand new language.

To wit, Theseus (link on OP) embodies Rust design in a cellular kernel (each “cell” corresponds with a Rust “crate”) and uses the safe language to avoid the need to compartment different things in different memory space.

Here is an article that looks at operating systems not built from C. How might an OS written in Red work?

it’s untrustworthy both from the security and the stability standpoint. being a brand new OS is bad enough in both those regards, but when its also written in a brand new language its even worse.

1 Like

Get outta here pal. We don’t need your kind here. Just joking, kind of.

Your needs and opinions are not without merit, but before it reaches the level of scrutiny you desire, somebody has to pioneer it. If there is anywhere to ask a question of this sort, the Framework forums would be the place to ask such a question in order to spark the pioneering spirit.

A more important question is why not? My answer is that I am too lazy to expend too much work on something of no benefit to me. Why Red?

Intriguing.

Rust is often touted as a safe language for developers. I’ve laughed at the notion, similar to Peter_Schofield I’m sure. Does Rust in fact create a false sense of security? How possible is it that exploits in Theseus might go undetected because of these “cells”?

Conceptually, I am more concerned about an operating system written in Rust, because of that false sense of security.

The underlying binary bits are very simple, and languages such as Rust or Red may be used to generate the same underlying bits. It may just be that security models are more work to code in C than in Rust (Red?).

Binary ← Assembly ← Low Level Languages ← High Level Languages

There are exploits that are not just poor coding standards or abilities for C programmers, but are in the underlying technologies at the binary or hardware level. I could imagine something like Spectre affecting Rust and Red as easily as any OS written in C.

Red looks like it may be a “high level language”? Rebol appears to be a high level language like Javascript, and horribly inefficient in most situations.

High level languages are more unpredictable when translating to binary (just-in-time compiling), because you are less likely to think about how the processor will execute the commands and functions. So I think Red would not be a good language, not because it is new, but rather because it is not close enough to the binary level to see what the code is actually going to do when compiled.

1 Like

Not every OS needs to have the same security and stability requirements. Someone could write an OS in this (or any) language and call it a hobby or experimental OS. Then we could play around with it (probably in a VM if you have only one computer), and anyone would know not to run their critical business apps on it.

Back to the original question: should you write an OS in Red? I don’t know of any Red-specific reason not to. Especially if the intention is to make it a toy OS, not a future Windows/Linux alternative. But there are many programming languages out there, a lot of them old enough to drink. Yet all the major OSes out there are still mostly written in C.

You could write almost any program (including OS component) in almost any language. But there’s still such a thing as using the right tool for the job.

1 Like

Don’t ever try anything new, it’s not worth it. It’s too risky and it will never be good enough. Jut sit quietly at home, accept things how they are, and give up.

As a rule of thumb he is right, generally speaking.

An Operating System is typically a significant undertaking. Apple switched to Darwin Unix for Mac OS X rather than build a new Operating System from scratch.

It is not likely economically wise to pursue an endeavor of such magnitude which by its very nature is a trend or fad.

Development of an operating system typically needs something beyond a chosen programming language to get it over the finish line.

Rust tackles memory management primarily, which is a big gotcha for up and coming programmers. Might just be me, but it seems that first you write “Hello World”, then you write a useful program, then you debug that program for using 128GB of RAM over the weekend. A pretty good problem to attempt to solve, imho.

This isn’t quite right. Darwin was an Apple release, not an existing OS they adopted. Your point still stands though, as Darwin was mostly pieced together from other (non-Apple) open-source projects. Most of the credit goes to BSD.

But still, it’s not like BSD came out of the Big Bang. It was a project that, although it had never been done before, people thought was a good idea worth pursuing and they worked hard to pull it off.

Scoffing at an ambitious project like writing an OS from scratch is fine, but anyone who does not acknowledge that big ideas occasionally turn into big innovations has not been paying attention to the last one hundred years of the history of computing.

I will start by adding that Steve Job’s Next OS and Apple derivatives incorporated Objective-C, so the language was in fact an important part of the Steve Job’s vision.

I am not a “proper” developer or anything, and am more interested in tinkering with ergonomic keyboards via QMK firmware. Even with this limited aspiration, I notice the sheer amount of stuff that comes down when I update Home-brew (a terminal based package manager for mac). I did feel that I needed There are Pythons, Ruby, a “fortran language server” and all sorts of other things I never use directly, but might have been added with the developer command line tools I thought I needed.

If Red is a “full stack” language with different dialects for system programming and the higher stuff, the appeal would lie in having Red for everything. Such an approach means rejecting most of the normal tools or re-writing them into Red, since you might want the ability to self compile them. But if such a system were a labour of passion that might be seen as an acceptable choice for purity of concept. In fact the low level Red/System dialect is said on Wikipedia to be like “C” but just written in a more straightforward way, so perhaps some tools could be (semi)-automatically converted to red/system.

Perhaps the discussed project is comparable with the Oberon operating system whose innovative features are discussed here. This was written in its eponymous programming language, although how much of its unusual look and function springs from that language I cannot speculate.

1 Like

High level languages are very appealing for everything, they are just less reliable for security and performance.

When you build a processor, you first have to create binary logic gates. Then you have to create machine code for programming for those logic gates. Then you create a low level language which turns these machine codes into functions to make it easier to write programs.

From there on you build high level languages which usually do not interact with the hardware directly, they typically call functions in an operating system, or a web browser.

Yes, that is essentially your pitch for using Red as a “full stack language”.

Note specifically in chapter 7, where it talks about a “a sufficiently dense intermediate representation” and "smaller object files”.

Essentially this “sufficiently dense intermediate representation” would become the operating system, or the kernel of the operating system. You would have to build a different “sufficiently dense intermediate representation” for each platform. It is here where the unusual look comes into play, because of the difficulty in porting an operating system to multiple different platforms with a variety of hardware that was the look which could most easily be supported.

Python and Ruby are designed to serve much the same purpose that Red is designed for, to make computers easier to develop for. FORTRAN is an ancient and very difficult language to program for. The “FORTRAN language server” is essentially a “sufficiently dense intermediate representation” for Python or Ruby to utilize when programming for a specific set of hardware.

Microsoft Windows is a very dense intermediate representation.

The Linux kernel is a somewhat dense intermediate representation.

2 Likes

Thanks for your interesting points.

Red/System is actually a low level language like “C” or “Zig”, and this is consistent with Red’s philosophy of encouraging “domain specific languages” or so-called “Dialects”, for different tasks.

If the rather sparse GUI of Oberon is a result of that portability (which can be disputed as it came after the native implementation). I think Red being based on REBOL, with its GUI dialect, would allow a fuller experience. See these REBOL examples.

If you are a linux enthusiast, this extensive chest of tools is probably a badge of honour. For the rest of us, I think less is often more, and too much choice can be a hinderance. For example, in the 1980s home computers such as the BBC Micro were strongly associated with the BASIC language, that was what you coded in, and it got a generation into computers. By contrast, my own household had an IBM and I was perhaps not exposed to coding in the same way.

As an aside, when I was training in engineering back in late 1990s, we were introduced to the FORTRAN language. Reading the introduction made us realise it was ancient even then! Thanks for explaining what it was doing on my system, as I thought FORTRAN seemed a bit obscure to be part of the Mac toolkit. We also did some Pascal which is the predecessor, so I recently learn, of the Oberon discussed in my last post.

I would modify this statement to: General Purpose OSes should not be written in new, unproven, languages.

The realm of research operating systems is a different thing. Case in point: C and Unix.

Something to have thus far escaped the notice of this thread: Rebol (the inspiration for Red) has been used to build a so-called Internet Operating System.

The applications - “Reblets” - are supposedly so small and simple to write that the authors regard them almost as disposable tools that can be easily (re)written for the job in hand.

We might imagine that our hypothetical Red based OS would present a similar userland on top of a system written in the Red “system” (low level) dialect.

It’s probably possible, if you have the spare time I’d say go for it. As long as it’s not mission-critical it’d be a really fun project and you could even try to make it work on the Framework laptop and post it on the forums.

It turns out there is no need to embark on such an endeavour from scratch as such a project already exists, in the form of SyllableOS. This somewhat moribund Amiga-inspired platform had intended to use REBOL for all its scripting, seemingly a good idea that would make coding really accessible to hobby users.

Now the project has apparently been taken over by the promoter of a new language whose concept seems almost identical to Red.

Meta is another language inspired by REBOL, in this case the more modern 3.0 version. The whole thing seems to be rather ambitious and, with an immature language and resuscitating virtually abandoned OS project, rather at risk of too many parts in motion at the same time. Still, at least they have some sort of existent OS to build from, even if the intention is to gradually rewrite the whole thing in due course.

1 Like