Is Julia able to replace C?

AFAIK some things are written in C to build up the foundation for Julia. Could this stuff be replaced such that everything is written in Julia and a whole OS could be written in Julia? And if so, what’s the reason for stopping it?

3 Likes

Previous discussions of this:

I think a fair summary is that implementing Julia in Julia is possible but would require a lot of effort without a clearly worthwhile reward.

18 Likes

It’s also worth noting that — unlike other languages — the vast majority of Julia (and nearly all the important parts) are indeed written in Julia.

16 Likes

While Julia is a general-purpose language, compared to C it has a less direct interface to the low-level manipulations. Those are required to build an operating system for example. Julia even has a direct interface to C, but why write C in Julia for those purposes when you can just write C? Or as an analogy, why cut a paper with a machette when you can just use scissors?

Based on my limited understanding of Julia’s source code, Julia is built from a very minimal and rather lightweight C/C++ implementation of basic routines and hardware support, and a syntax parser written in Scheme. Everything on top of that is Julia with a some C calls here and there.

12 Likes

As far as replace everything written in C with Julia…For a desktop/server computer yes I guess you could. Embedded programmers however don’t really like Garbage Collection since it’s not deterministic. Also I’ve never heard of an OS that uses a Garbage Collection for memory management.

1 Like

Reference counting is a form of garbage collection techniques. Tracing GC is probably less common but I won’t be surprised at all if it is used in OS kernel in some ways and in some limited scope.

3 Likes

To summatize: it is possible but not really feasible and nobody has the intention to replace C for OSs. Moreover, since other OSs are written in C it’s much easier to keep the base in C. Got it! Thx :slight_smile:

But not its compiler, LLVM.

In future it could be easier to find compilers made with Rust.

He said “nearly”. There are many exceptions, but the compiler, especially llvm itself is the one that makes almost the least sense to replace, at least not for this reason.

3 Likes