Author Topic: any examples of OS not written in C/C++?  (Read 25419 times)

0 Members and 1 Guest are viewing this topic.

Offline PlainName

  • Super Contributor
  • ***
  • Posts: 6796
  • Country: va
Re: any examples of OS not written in C/C++?
« Reply #100 on: April 17, 2021, 08:36:58 am »
Quote
The standard library is linked statically by default, though your binary is still an order of magnitude larger than mine for some reason. If you do dynamic linking, comparable to the default with C

Just to be clear, by 'static' linking you mean shoving library code in the executable, and by 'dynamic' you mean having the library code loaded at run-time? If so, that's a bit disingenuous since the executing application still needs the same linked-in code, just that with dynamic linking you don't count it. Put all the necessary stuff in one place and see what the size is - that's what it takes to run it.

And, in fact, all other things being equal, running a single executable with dynamic linking leads to more bloat since every library function will be required regardless as to whether it's used or not. With static linking only the bits actually used get linked in (or should be).

 
 

Offline DC1MC

  • Super Contributor
  • ***
  • Posts: 1882
  • Country: de
Re: any examples of OS not written in C/C++?
« Reply #101 on: April 17, 2021, 08:48:40 am »
Why is everybody ignoring and not mentioning ADA, the best way that is not C/C++ to write an operating system ?

"The Army Secure Operating System (ASOS) was written almost entirely in Ada. It was designed to meet Orange Book A1 protection requirements, support Ada applications more directly, and run on a commodity Sun3. The total software was 55,000 lines of code. It even had checkpointing/restore and later a secure RDBMS."

Here, freshly declassified:
https://apps.dtic.mil/dtic/tr/fulltext/u2/a340370.pdf
https://moscow.sci-hub.se/1864/6e4bd79db1e4753ea76c251441a45133/waldhart1990.pdf

This was what real programmers were doing before CoC and other hipster shite.
« Last Edit: April 17, 2021, 08:50:51 am by DC1MC »
 

Online brucehoult

  • Super Contributor
  • ***
  • Posts: 4000
  • Country: nz
Re: any examples of OS not written in C/C++?
« Reply #102 on: April 17, 2021, 08:57:01 am »
Quote
The standard library is linked statically by default, though your binary is still an order of magnitude larger than mine for some reason. If you do dynamic linking, comparable to the default with C

Just to be clear, by 'static' linking you mean shoving library code in the executable, and by 'dynamic' you mean having the library code loaded at run-time? If so, that's a bit disingenuous since the executing application still needs the same linked-in code, just that with dynamic linking you don't count it. Put all the necessary stuff in one place and see what the size is - that's what it takes to run it.

Fair enough. If you want to do that then you need to compile the C code with -static as well.

On my x86_64 Linux compiling helloWorld I get:

dynamic: 1508 bytes program code, 600 bytes data, 8 bytes bss
static: 743321 bytes program code, 20876 bytes data, 5984 bytes bss


Quote
And, in fact, all other things being equal, running a single executable with dynamic linking leads to more bloat since every library function will be required regardless as to whether it's used or not. With static linking only the bits actually used get linked in (or should be).

With dynamic linking, every program running on the system at the same time can use the same physical RAM copy of the dynamic libraries.
 

Offline RoV

  • Regular Contributor
  • *
  • Posts: 175
  • Country: it
Re: any examples of OS not written in C/C++?
« Reply #103 on: April 17, 2021, 10:32:20 am »
If I remember well, Motorola VersaDOS was written entirely in 68k assembler. A byte-coded Pascal interpreter, painfully slow, was available from the original installation disks.

Offline DiTBhoTopic starter

  • Super Contributor
  • ***
  • Posts: 3796
  • Country: gb
Re: any examples of OS not written in C/C++?
« Reply #104 on: April 17, 2021, 11:12:47 am »
This morning I wrote an "interactive mean function" to fix a couple of problems I had on two sensors. Both the ultrasonic and IR reflective sensors are noisy and their means tend to overflow.

In the past I embedded a smart mean function within each "sensor driver", it worked, it was guaranteed to not overflow, but it wasted precious code space.

The ADC used for the reflective sensor was 8bit now it's 12 bit, the free running timer used for the ultrasonic sensor is 16bit, what I wrote this morning is one the mean-function that does the job nicely for both of them.

It was funny to do, not exactly easy but funny, but also doing it in assembly also allowed me to  make the function able to invoke several methods by just having its base_address in a "index" register passed as argument.

value0 = mean_get(get_addr(sensor0) /* callback */ );
value1 = mean_get(get_addr(sensor1) /* callback */ );

output: reg D is the function returned value
input: reg X is the callback to the sensor, method requires index+service
used services: get_data, get_window_size
wasted registers: D,X

The mean function can invoke "sensor.data_get" and "sensor.get_window_size" methods from both the sensors by just having the base address passed by a register like if it was a callback in C.

The MPU is able to perform jsr X, and X is calculated as sensor_base + method, I exploited a trick offered by the linker script to have the method addresses expressed as relative to the base_address.

The strange but funny thing is that doing it in assembly + linker script was much simpler and less byte consuming than writing it in C :o :o :o

Next step, rewriting them as "task" for the scheduler with an additional "sensor fusion" task.
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Offline DiTBhoTopic starter

  • Super Contributor
  • ***
  • Posts: 3796
  • Country: gb
Re: any examples of OS not written in C/C++?
« Reply #105 on: April 17, 2021, 11:19:07 am »
After this project, I'd like to play with a simple OS not written in C/C++.
I mean, I like to compile (modify?) some good piece of code, upload something on a board (68k? modern STM32?), and play with it.

Ada? Pascal? Modula2? Oberon? Assembly? All welcome :D
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Offline coppice

  • Super Contributor
  • ***
  • Posts: 8605
  • Country: gb
Re: any examples of OS not written in C/C++?
« Reply #106 on: April 17, 2021, 12:50:13 pm »
Amusingly, until recently it wasn't even possible to write an OS in C. I know it is ridiculous, but as late a 2004 Hans Boehm had to point that out to many people in "Threads Cannot be Implemented as a Library" http://www.hpl.hp.com/techreports/2004/HPL-2004-209.html
I think Hans Boehm is also someone who wrote an excellent article about how poorly understood the memory models of various x86 cores was (even by their own developers), and how this shot holes in most threading systems. I don't see how this makes running C code an impediment to progress.

Strawman question!
Try reading what I wrote again without the bad attitude. Hans Boehm is an important figure who pointed out a lot of sloppy thinking related to how poorly understood hardware memory models interact with threading and multi-CPU environments.  I don't see how this makes running C code an impediment to progress. Single threaded C code has no real issues. Mullti-threaded C code certainly inhibits change, but so does every other kind of multi-threaded code. They are ALL incompatible with change.
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 19281
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: any examples of OS not written in C/C++?
« Reply #107 on: April 17, 2021, 01:14:03 pm »
Amusingly, until recently it wasn't even possible to write an OS in C. I know it is ridiculous, but as late a 2004 Hans Boehm had to point that out to many people in "Threads Cannot be Implemented as a Library" http://www.hpl.hp.com/techreports/2004/HPL-2004-209.html
I think Hans Boehm is also someone who wrote an excellent article about how poorly understood the memory models of various x86 cores was (even by their own developers), and how this shot holes in most threading systems. I don't see how this makes running C code an impediment to progress.

Strawman question!
Try reading what I wrote again without the bad attitude. Hans Boehm is an important figure who pointed out a lot of sloppy thinking related to how poorly understood hardware memory models interact with threading and multi-CPU environments.  I don't see how this makes running C code an impediment to progress. Single threaded C code has no real issues. Mullti-threaded C code certainly inhibits change, but so does every other kind of multi-threaded code. They are ALL incompatible with change.

I have never claimed anything similar to "makes running C code an impediment to progress".

C code including single-threaded code - as found in the wild - does have many issues.

I have no idea what you mean by "Mullti-threaded C code certainly inhibits change, but so does every other kind of multi-threaded code. They are ALL incompatible with change."
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Online brucehoult

  • Super Contributor
  • ***
  • Posts: 4000
  • Country: nz
Re: any examples of OS not written in C/C++?
« Reply #108 on: April 17, 2021, 01:21:33 pm »
After this project, I'd like to play with a simple OS not written in C/C++.
I mean, I like to compile (modify?) some good piece of code, upload something on a board (68k? modern STM32?), and play with it.

Ada? Pascal? Modula2? Oberon? Assembly? All welcome :D

Other than assembly language, those are all isomorphic to C/C++, certainly the GNU version if not the standard (e.g. with nested functions possible). They differ only in surface syntax, the standard library, and things such as how visibility of names is controlled. Generate code is identical. The same goes for Lisp.

If you want something different, try the Hindley–Milner type system languages -- and even most of those are not *so* different, except Haskell.
 
The following users thanked this post: DiTBho

Offline Karel

  • Super Contributor
  • ***
  • Posts: 2214
  • Country: 00
Re: any examples of OS not written in C/C++?
« Reply #109 on: April 17, 2021, 01:32:43 pm »
With dynamic linking, every program running on the system at the same time can use the same physical RAM copy of the dynamic libraries.

Only the code and constant data part. All the rest is not shared.
Non-constant data (variables) can be a big part of a library.
So, in practice, the memory-savings by using dynamic linking is not as big as hoped for.
 

Offline coppice

  • Super Contributor
  • ***
  • Posts: 8605
  • Country: gb
Re: any examples of OS not written in C/C++?
« Reply #110 on: April 17, 2021, 01:49:02 pm »
With dynamic linking, every program running on the system at the same time can use the same physical RAM copy of the dynamic libraries.

Only the code and constant data part. All the rest is not shared.
Non-constant data (variables) can be a big part of a library.
So, in practice, the memory-savings by using dynamic linking is not as big as hoped for.
Right. Most big things are big because of the working data, not the code. I have libraries of a couple of hundred k, that take up gigabytes on running systems, because so many instances are used, and each instance has a lot of working data.

I'm not sure the original intent of dynamic link libraries was mostly about memory saving. The ability to swap out one bug fixed library, and fix every app using it, was an important driving force. That's more an area where the hype didn't work out well, as we fell into a DLL hell that the industry has taken a long time to cilmb out of.
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 19281
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: any examples of OS not written in C/C++?
« Reply #111 on: April 17, 2021, 02:10:57 pm »
After this project, I'd like to play with a simple OS not written in C/C++.
I mean, I like to compile (modify?) some good piece of code, upload something on a board (68k? modern STM32?), and play with it.

Ada? Pascal? Modula2? Oberon? Assembly? All welcome :D

Other than assembly language, those are all isomorphic to C/C++, certainly the GNU version if not the standard (e.g. with nested functions possible). They differ only in surface syntax, the standard library, and things such as how visibility of names is controlled. Generate code is identical. The same goes for Lisp.

Really? You can get buffer overflow in Ada using the normal cliche programming style? Or access/mutate aCamel as if it was aHorse?
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline Karel

  • Super Contributor
  • ***
  • Posts: 2214
  • Country: 00
Re: any examples of OS not written in C/C++?
« Reply #112 on: April 17, 2021, 02:22:36 pm »
With dynamic linking, every program running on the system at the same time can use the same physical RAM copy of the dynamic libraries.

Only the code and constant data part. All the rest is not shared.
Non-constant data (variables) can be a big part of a library.
So, in practice, the memory-savings by using dynamic linking is not as big as hoped for.
Right. Most big things are big because of the working data, not the code. I have libraries of a couple of hundred k, that take up gigabytes on running systems, because so many instances are used, and each instance has a lot of working data.

I'm not sure the original intent of dynamic link libraries was mostly about memory saving. The ability to swap out one bug fixed library, and fix every app using it, was an important driving force. That's more an area where the hype didn't work out well, as we fell into a DLL hell that the industry has taken a long time to cilmb out of.

There are people out there that have the opinion that static linking is bad practice but they don't have problems with flatpak or snap...
 

Offline techman-001

  • Frequent Contributor
  • **
  • !
  • Posts: 748
  • Country: au
  • Electronics technician for the last 50 years
    • Mecrisp Stellaris Unofficial UserDoc
Re: any examples of OS not written in C/C++?
« Reply #113 on: April 17, 2021, 02:32:00 pm »
According to https://www.merriam-webster.com an operating system is  "software that controls the operation of a computer and directs the processing of programs (as by assigning storage space in memory and controlling input and output functions)"

So Forth is a good example of a OS not generally written in C/C++ but it could be.

I have Forths written in just about everything including Scheme, Bash, Perl and many others, but the one I use everyday is written in ARM Thumb1 assembly language.
 

Online brucehoult

  • Super Contributor
  • ***
  • Posts: 4000
  • Country: nz
Re: any examples of OS not written in C/C++?
« Reply #114 on: April 17, 2021, 02:42:05 pm »
With dynamic linking, every program running on the system at the same time can use the same physical RAM copy of the dynamic libraries.

Only the code and constant data part. All the rest is not shared.
Non-constant data (variables) can be a big part of a library.
So, in practice, the memory-savings by using dynamic linking is not as big as hoped for.

I'm really not sure what your point is here.

We're talking about code size.

Initialized data from a dynamic library is shared, until a program writes to it, at which time it gets its own writable copy of that memory page. Constant data remains always shared -- at least as long as it is not intermingled on the same memory page with data that is modified. Since data the compiler knows to be constant is put in a different section to initialised data that the compiler expects to be modified, each type is gathered together and there should be at most one memory page (but quite likely zero) per library with a mix of constant and modifiable initialized data.

RSS data is not shared, but then it is not present in the program or library files at all.
 

Online brucehoult

  • Super Contributor
  • ***
  • Posts: 4000
  • Country: nz
Re: any examples of OS not written in C/C++?
« Reply #115 on: April 17, 2021, 02:45:12 pm »
After this project, I'd like to play with a simple OS not written in C/C++.
I mean, I like to compile (modify?) some good piece of code, upload something on a board (68k? modern STM32?), and play with it.

Ada? Pascal? Modula2? Oberon? Assembly? All welcome :D

Other than assembly language, those are all isomorphic to C/C++, certainly the GNU version if not the standard (e.g. with nested functions possible). They differ only in surface syntax, the standard library, and things such as how visibility of names is controlled. Generate code is identical. The same goes for Lisp.

Really? You can get buffer overflow in Ada using the normal cliche programming style? Or access/mutate aCamel as if it was aHorse?

You don't get buffer overflows in properly-written C (or especially C++) code. What problems there are are generally caused by using poorly designed libraries (including the convenient but dangerous standard library).
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 19281
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: any examples of OS not written in C/C++?
« Reply #116 on: April 17, 2021, 03:29:36 pm »
After this project, I'd like to play with a simple OS not written in C/C++.
I mean, I like to compile (modify?) some good piece of code, upload something on a board (68k? modern STM32?), and play with it.

Ada? Pascal? Modula2? Oberon? Assembly? All welcome :D

Other than assembly language, those are all isomorphic to C/C++, certainly the GNU version if not the standard (e.g. with nested functions possible). They differ only in surface syntax, the standard library, and things such as how visibility of names is controlled. Generate code is identical. The same goes for Lisp.

Really? You can get buffer overflow in Ada using the normal cliche programming style? Or access/mutate aCamel as if it was aHorse?

You don't get buffer overflows in properly-written C (or especially C++) code.

I wondered how long it would be until the There's No True Scotsman fallacy would rear its head!  https://en.m.wikipedia.org/wiki/No_true_Scotsman

Quote
What problems there are are generally caused by using poorly designed libraries (including the convenient but dangerous standard library).

Q.E.D. :)
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14302
  • Country: fr
Re: any examples of OS not written in C/C++?
« Reply #117 on: April 17, 2021, 05:31:18 pm »
Why is everybody ignoring and not mentioning ADA, the best way that is not C/C++ to write an operating system ?

"The Army Secure Operating System (ASOS) was written almost entirely in Ada. It was designed to meet Orange Book A1 protection requirements, support Ada applications more directly, and run on a commodity Sun3. The total software was 55,000 lines of code. It even had checkpointing/restore and later a secure RDBMS."

Here, freshly declassified:
https://apps.dtic.mil/dtic/tr/fulltext/u2/a340370.pdf
https://moscow.sci-hub.se/1864/6e4bd79db1e4753ea76c251441a45133/waldhart1990.pdf

There is more recent stuff:
https://marte.unican.es/
https://m2os.unican.es/
 

Offline madires

  • Super Contributor
  • ***
  • Posts: 7695
  • Country: de
  • A qualified hobbyist ;)
Re: any examples of OS not written in C/C++?
« Reply #118 on: April 17, 2021, 06:12:14 pm »
 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6173
  • Country: fi
    • My home page and email address
Re: any examples of OS not written in C/C++?
« Reply #119 on: April 17, 2021, 07:25:05 pm »
After this project, I'd like to play with a simple OS not written in C/C++.
I mean, I like to compile (modify?) some good piece of code, upload something on a board (68k? modern STM32?), and play with it.

Ada? Pascal? Modula2? Oberon? Assembly? All welcome :D

Other than assembly language, those are all isomorphic to C/C++, certainly the GNU version if not the standard (e.g. with nested functions possible). They differ only in surface syntax, the standard library, and things such as how visibility of names is controlled. Generate code is identical. The same goes for Lisp.

Really? You can get buffer overflow in Ada using the normal cliche programming style? Or access/mutate aCamel as if it was aHorse?

You don't get buffer overflows in properly-written C (or especially C++) code.

I wondered how long it would be until the There's No True Scotsman fallacy would rear its head!  https://en.m.wikipedia.org/wiki/No_true_Scotsman
That is an unfair statement.

Unlike C++, C has two different "modes": hosted environment and freestanding environment.  The former includes the standard C library – including functions like fgets(), strcpy(), and so on –; whereas the latter is used when programming kernels and microcontrollers, often with a replacement set of functions (see Linux kernel C functions, or the Arduino environment, for examples).

Buffer overflows are intrinsic part of the C standard library, but not the C freestanding environment.  It is quite possible to replace the standard C library with a completely different API, including arrays with explicit bounds and garbage collection, but keep the C compiler and syntax.

Therefore, this is not a No True Scotsman argument, because it identifies the problematic but optional half of C.  I know this, because I myself am working on a "better" substitute (for my own needs and uses).
 
The following users thanked this post: DiTBho

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 19281
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: any examples of OS not written in C/C++?
« Reply #120 on: April 17, 2021, 09:20:34 pm »
After this project, I'd like to play with a simple OS not written in C/C++.
I mean, I like to compile (modify?) some good piece of code, upload something on a board (68k? modern STM32?), and play with it.

Ada? Pascal? Modula2? Oberon? Assembly? All welcome :D

Other than assembly language, those are all isomorphic to C/C++, certainly the GNU version if not the standard (e.g. with nested functions possible). They differ only in surface syntax, the standard library, and things such as how visibility of names is controlled. Generate code is identical. The same goes for Lisp.

Really? You can get buffer overflow in Ada using the normal cliche programming style? Or access/mutate aCamel as if it was aHorse?

You don't get buffer overflows in properly-written C (or especially C++) code.

I wondered how long it would be until the There's No True Scotsman fallacy would rear its head!  https://en.m.wikipedia.org/wiki/No_true_Scotsman
That is an unfair statement.

Unlike C++, C has two different "modes": hosted environment and freestanding environment.  The former includes the standard C library – including functions like fgets(), strcpy(), and so on –; whereas the latter is used when programming kernels and microcontrollers, often with a replacement set of functions (see Linux kernel C functions, or the Arduino environment, for examples).

Buffer overflows are intrinsic part of the C standard library, but not the C freestanding environment.  It is quite possible to replace the standard C library with a completely different API, including arrays with explicit bounds and garbage collection, but keep the C compiler and syntax.

Therefore, this is not a No True Scotsman argument, because it identifies the problematic but optional half of C.  I know this, because I myself am working on a "better" substitute (for my own needs and uses).

So you think it is ana acceptable argument to exclude "half" of C uses and concentrate on the less inconvenient other half?

More interestingly, you highlight a problem that C and C++ made for themselves in the early/mid 90s....

There was two directions in which C could go: be a general purpose high level applications language, or be a low level systems programming language. Either would have been a good choice with a good result, but the standards committees couldn't decide and fudged the issue. The result is that they are less good for either.

One example of the dichotomy was the endless arguments over whether is must be possible/impossible to "cast away fondness". High level applications require it to be impossible, since constness guarantees enable large scale performance optimisations. Low level systems require it in,, for example, debuggers.

The deficiencies were most noticeable in the applications domain, so now Java, Python and possibly Rust are dominant.

Personally I'd have preferred it if C had remained optimise for systems programming, since there were already better languages available, and C++ was clearly the wrong answer to any useful question.
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline Karel

  • Super Contributor
  • ***
  • Posts: 2214
  • Country: 00
Re: any examples of OS not written in C/C++?
« Reply #121 on: April 17, 2021, 10:54:38 pm »
..., so now Java, Python and possibly Rust are dominant.



https://www.tiobe.com/tiobe-index/

 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 19281
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: any examples of OS not written in C/C++?
« Reply #122 on: April 17, 2021, 11:16:37 pm »
..., so now Java, Python and possibly Rust are dominant.



https://www.tiobe.com/tiobe-index/

Tiobe doesn't measure anything useful, let alone something related to the part of the sentence you omitted.
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6173
  • Country: fi
    • My home page and email address
Re: any examples of OS not written in C/C++?
« Reply #123 on: April 17, 2021, 11:52:42 pm »
After this project, I'd like to play with a simple OS not written in C/C++.
I mean, I like to compile (modify?) some good piece of code, upload something on a board (68k? modern STM32?), and play with it.

Ada? Pascal? Modula2? Oberon? Assembly? All welcome :D

Other than assembly language, those are all isomorphic to C/C++, certainly the GNU version if not the standard (e.g. with nested functions possible). They differ only in surface syntax, the standard library, and things such as how visibility of names is controlled. Generate code is identical. The same goes for Lisp.

Really? You can get buffer overflow in Ada using the normal cliche programming style? Or access/mutate aCamel as if it was aHorse?

You don't get buffer overflows in properly-written C (or especially C++) code.

I wondered how long it would be until the There's No True Scotsman fallacy would rear its head!  https://en.m.wikipedia.org/wiki/No_true_Scotsman
That is an unfair statement.

Unlike C++, C has two different "modes": hosted environment and freestanding environment.  The former includes the standard C library – including functions like fgets(), strcpy(), and so on –; whereas the latter is used when programming kernels and microcontrollers, often with a replacement set of functions (see Linux kernel C functions, or the Arduino environment, for examples).

Buffer overflows are intrinsic part of the C standard library, but not the C freestanding environment.  It is quite possible to replace the standard C library with a completely different API, including arrays with explicit bounds and garbage collection, but keep the C compiler and syntax.

Therefore, this is not a No True Scotsman argument, because it identifies the problematic but optional half of C.  I know this, because I myself am working on a "better" substitute (for my own needs and uses).

So you think it is an acceptable argument to exclude "half" of C uses and concentrate on the less inconvenient other half?
No, I think it is an error to consider hosted C environment the only valid C, and call relying on freestanding C 'excluding "half" of C', when the main problems are all in the hosted C environment only.

The above linked argument is not a case of No True Scotsman, exactly because of the dual nature of the C standard, and the problems being avoidable by using freestanding C.  It is a valid argument, because many C developers are not aware of the differences between the hosted environment and the freestanding environment, and conflate the two.

(Technically, one does not even need to write freestanding C, just avoid using most of the standard C library API; and use other APIs, like say Boehm GC for memory allocation, and mutable data buffers with explicit bounds instead of standard C strings, to basically completely avoid both buffer overruns and dynamic memory management problems.)

I fully agree that the C standard committee has dropped the ball over two decades ago, mainly due to increased vendor pressure and complete rejection of the POSIX standard, and instead veering into C++ and vendor-specific optional interfaces (like the so-called "safe I/O functions", which are nothing of the sort).

Put another way, buffer overruns and dynamic memory management issues are not an inherent part of C; only an inherent part of the library that forms the core of the hosted C environment: the standard C library.  It is quite possible, and indeed very feasible, to either replace, or just augment the standard C library with something completely different that 1) does not suffer from buffer overruns because array boundaries are part of the data structures used by the replacement library interfaces, and 2) has an efficient automatic garbage collection; and the code will still be C that a typical C developer will be able to read and maintain.  To develop such code, a typical C developer will have to learn those new interfaces, but that's it.

Having experimented and delved into this, it amazes me that no real work has been published on this front, because I'm basically drowning in possibilities and having to write a lot of test code just to see which options I prefer right now, for code running under the Linux kernel on typical ARM and Intel hardware.
To me, it feels like computer scientists are arguing amongst themselves how many sides should a polygonal wheel have, completely ignoring round, circular wheels... We really have not made much real progress in software engineering (and I'm suspecting in computer science too) in the last two or three decades.  Small optimizations only.
Things like the Arduino library (which replaces the standard C library for Arduino development; and although the code is compiled using a C++ compiler, it relies on the GNU C++ compiler providing a freestanding C++ environment based on the C freestanding environment) are honestly quite horrible, possibly even worse than the standard C library.  I shan't talk much about the various vendor-provided Hardware Abstraction Libraries, just that every single one I've seen has been a disappointment (in the software engineering sense – compare to a contractor seeing a house built with timber but using twine instead of nails or screws (or even pegs) to hold things together).

The dual nature is important to realize, because the non-library part of C is so simple yet powerful.  It could be much better (code-level concurrency, barriers, memory semantics/coherency etc.), but that sort of stuff is better explored with other languages.  However, the C library part, which is not a compulsory/required part of C, only an optional part, is the biggest problem with C, and is easily replaced with something else. (That is, all C compilers I have used, provide compile time flags and options that allow trivially replacing/omitting the standard C library with something else.)
 
The following users thanked this post: brucehoult

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4196
  • Country: us
Re: any examples of OS not written in C/C++?
« Reply #124 on: April 18, 2021, 05:04:58 am »
Quote
I'd like to play with a simple OS not written in C/C++.
How much do you consider "a simple OS"?
I mean, it's pretty trivial (and frequently necessary) to write task switching in assembly language, and not much more effort to add a simple scheduler.  That might be all you need to count as an OS in embedded spaces; just figure out how you're going to interface it to application code that is perhaps written in a different language...
But that's very much less than what would be considered a "small OS" for a slightly bigger computer - you'd have to at least add a file-system and a network stack, a windowing system, and probably a whole suite of core user-level applications - when one talks about linux or Windows as being an OS it's not done till it includes at least one web browser, a fancy file manager, and a game...
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf