Author Topic: DARPA suggests turning old C code automatically into Rust  (Read 14243 times)

0 Members and 1 Guest are viewing this topic.

Online SiliconWizardTopic starter

  • Super Contributor
  • ***
  • Posts: 16385
  • Country: fr
Re: DARPA suggests turning old C code automatically into Rust
« Reply #150 on: December 23, 2024, 08:54:13 am »
I didn't know he wrote that, but it was quite a funny one.
Quote
- <odd>.x.x: Linus went crazy, broke absolutely _everything_, and rewrote
   the kernel to be a microkernel using a special message-passing version
   of Visual Basic. (timeframe: "we expect that he will be released from
   the mental institution in a decade or two").
 

Offline magic

  • Super Contributor
  • ***
  • Posts: 7571
  • Country: pl
Re: DARPA suggests turning old C code automatically into Rust
« Reply #151 on: December 23, 2024, 09:19:50 am »
Speaking of microkernels written in a memory safe version of Visual Basic, I have heard that Redox is nearly 10 years old and still doesn't even have working USB support.

Linux did have USB in 2001, so I guess that's a win for languages which make it possible to write, compile and run sloppy code. People will use such software if its price is right, but they won't use something that doesn't run merely because it isn't correct, or written yet because of pedantry and analysis paralysis.

This will trigger both Linux and R&$# fanboys, but I think that Linux (and certainly its HW drivers) owes its existence to C, and for the same reasons Redox will owe its non-existence to R&$# :box:
« Last Edit: December 23, 2024, 09:26:47 am by magic »
 
The following users thanked this post: Siwastaja

Online SiliconWizardTopic starter

  • Super Contributor
  • ***
  • Posts: 16385
  • Country: fr
Re: DARPA suggests turning old C code automatically into Rust
« Reply #152 on: December 23, 2024, 09:52:49 pm »
Agreed.
The language may not be the only issue though - I think the overall attitude plays a big role too. But it's tightly linked to Rust, so it's hard to tell which came first.
 

Offline DiTBho

  • Super Contributor
  • ***
  • Posts: 4657
  • Country: gb
Re: DARPA suggests turning old C code automatically into Rust
« Reply #153 on: December 24, 2024, 04:37:16 pm »
rewriting the Linux kernel in a different language is... just impossible.

It's already a problem to
  • to support different kernel families, for example you can't compile kernel 6.12 with gcc v<10, and it's compiled with many scripts, some in perl, some in bash... some depend on "Makefile", early 2000s is not compatible with 2010s, which is not compatible with 2020s, ...
  • to separate the sources from the objects, let's say you want to share the sources with different platforms, you have to clone the folder over and over
Forget it.
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Offline DiTBho

  • Super Contributor
  • ***
  • Posts: 4657
  • Country: gb
Re: DARPA suggests turning old C code automatically into Rust
« Reply #154 on: December 24, 2024, 04:49:03 pm »
I tried to write a simple kernel module for Linux.
myC does not produce assemblies compatible with GNU binutils, so I had to put it against a translator

myC -> myAS -> myAS to GAS/mips32 -> object file

Although it apparently compiles successfully, all the monad support is missing, because standard C doesn't need it.

So kernel panics as soon as you load the module.

There's more work to do and I don't know if it makes sense to do it...  :-//
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4415
  • Country: us
Re: DARPA suggests turning old C code automatically into Rust
« Reply #155 on: December 25, 2024, 02:58:37 am »
It seems to me that the problem with "memory safe" languages, is that all the libraries and run-time support has to be memory-safe as well.  That tends to make such languages either very large and difficult to implement (like Ada or Java), or (and/or?) ... unable to do the things that need to be done (USB support being a fine example, I guess.)

C has the advantage that it CAN do anything; just set a pointer to your hardware registers and off you go!  And it doesn't HAVE to do anything in the language; write a few basic math functions and a bit of startup code, and you can say you have a C compiler (POSIX and LIBC be damned!)
 
The following users thanked this post: DiTBho

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 22438
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: DARPA suggests turning old C code automatically into Rust
« Reply #156 on: December 25, 2024, 08:01:14 am »
It seems to me that the problem with "memory safe" languages, is that all the libraries and run-time support has to be memory-safe as well.  That tends to make such languages either very large and difficult to implement (like Ada or Java), or (and/or?) ... unable to do the things that need to be done (USB support being a fine example, I guess.)

C has the advantage that it CAN do anything; just set a pointer to your hardware registers and off you go!  And it doesn't HAVE to do anything in the language; write a few basic math functions and a bit of startup code, and you can say you have a C compiler (POSIX and LIBC be damned!)

Java:C languages is like digital:analogue circuits.

Typical applications are large programs, and the the interaction between all parts is too complex to understand. The runtime support is much smaller and more constrained, and should therefore have interactions and be easier to understand.

That basic principle occurs in many places, e.g. the difference between analogue and digital circuits.  Analogue circuits can do every thing digital circuits can and more, but guess which allows more complex systems. In addition, many people forget that digital circuits are analogue circuits operating in a constrained mode - usually, until so something subtle bites them. Simple example: DRAM - analogue or digital? Which is more usable?

If you think C (worse C++) is a simple language, then you really don't understand the subtleties. In the 90s compiler writers frequently had to ask what the standard meant - and conflicting answers from different committee members. Disgraceful.

Java is a much simpler language.
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
 
The following users thanked this post: DiTBho


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf