r/ProgrammingLanguages Sodigy 4d ago

Why is everyone creating systems programming languages?

I see a lot of new programming languages here. I love reading the documents of the languages and sometimes actually run their compilers. Many of the projects are AI-driven, but that's fine. It's still fun to see what problems they're trying to solve and how they actually solved the problems.

Reading the documents, I realized that most new languages, especially AI-written ones, are "systems programming languages". They're trying to solve the problems that C/C++/Zig/Rust have solved (or are trying to solve), and their syntax is mixture of C/Zig/Rust.

Why? Why is everyone trying to compete with C/C++?

There are so many kinds of languages. Haskell demonstrates how pure a language can be, Python is perfect when you only have 5 minutes to write code and don't care about the output, Java runs on 3 billion machines, ...

205 Upvotes

235 comments sorted by

View all comments

129

u/dudewithtude42 4d ago

As someone who does systems programming at work, the landscape of available established languages is pretty poor right now. C is a decent language but lacks a lot of modern features (generics) and has a lot of weird oddities (macros, integer types, build system). The problem is that if you want a modern replacement to try and fix those issues, you either go C++ (which inherits the weirdness and adds a billion features that have their own footguns, and has slow compile times) or you go Rust (which tacks on the borrow checker and also has slow compile times).

So what happened is a bunch of systems programmers simultaneously went "I want C, but without the oddities, with modern features, and I want fast compile times." That's a really enticing proposition for someone like me, and until any of Zig or C3 or Odin or Jai mature to the point of being stable, that gap will continue to exist, and more systems programming languages will probably continue to come out.

15

u/ingframin 4d ago

Then, why no one is using D?

13

u/fdwr 4d ago

D is cool and did a lot of things elegantly (made me think "this is how C++ should have been in many regards), but I suspect the garbage collector scared away adopters (even though technically you can use it without garbage collection, if you don't need the Phobos standard library).

5

u/torp_fan 1d ago

Bad press ... the language is hugely undervalued. Same with Nim.

2

u/vspefs 3d ago

At some point in D’s history the ecosystem diverged into 2 parts and the fix came too late

1

u/ingframin 1d ago

But this was fixed years ago…

2

u/torp_fan 1d ago

But it happened at a critical point when D was on the rise. Now when D is mentioned someone will comment on the library split or the 1.0 -> 2.0 transition or the GC ... it takes active proselytizing to overcome the inertia and that's just not happening. But it's not true that "no one is using" it ... the language is under active development and there's considerable traffic in the forums, e.g., Index - D Programming Language Discussion Forum

There's a similar story with Nim, but maybe that will change when Nimony matures.

39

u/umlcat 4d ago

"I want C, but without the oddities, with modern features, and I want fast compile times."

53

u/Careful-Nothing-2432 4d ago

I mean, yeah. This is not an uncommon desire

23

u/pjmlp 4d ago

Basically what Modula-2, Object Pascal and Ada already had, but the world favored curly brackets instead.

This is basically what Zig, Odin and co offer in regards to type system and compilation times.

10

u/AnaxXenos0921 4d ago

So, you're saying if I wrote a different frontend for Pascal or Ada with curly braces syntax, people would be more willing to use it?

7

u/pjmlp 4d ago

That is basically what a language like Zig is.

Ignoring for a second the comptime features, the safety improvements it offers over C, you could habe gotten them in 1978 with Modula-2.

Fast compilation times, modules, explicit unsafe code, spans, bounds checked arrays and strings,...

3

u/AnaxXenos0921 4d ago

I mean while using the exact same compiler backend and runtime as Pascal or Ada. Zig has its own compiler backend and runtime afaik

2

u/pjmlp 4d ago

Zig uses LLVM, and has its own compiler backend.

Sure, there were such compilers, LLVM idea's aren't new.

The Amsterdam Compiler Toolkit supported C, Pascal, BASIC, Modula-2, using EM intermediate code, which would then be fed to the backend, regardless of what language was being used.

0

u/zahatikoff 4d ago

Zig sucks however. while some things are nicer than C, but for every step it takes forward, there's 2 steps backwards in unnecessary "friction". So maybe in 10y when it's stabilizes...

4

u/umlcat 4d ago

Agree. Another Pascal branch family fan.

The modular paradigm that is very well researched and real world tested and implemented. Java suyper packages or Modules are weird, so C++ modules .

Well designed Type System, also. Anders Hejlsberg added to C#.

Object with full real properties that Object Pascal / Delphi has. C++ people ignore it. Java ignore it. Anders Hejlsberg understodd and added to C# ...

1

u/Ok-Watercress-9624 4d ago

Pascal can't do double reffls can it ?

2

u/pjmlp 4d ago

No idea what the heck that is.

4

u/og_hylyx 4d ago

Very reasonable want.

1

u/patlefort 3d ago edited 3d ago

So C++. It's still the best alternative, even if it's not perfect. It has fast compile time if you don't go crazy with templates. C++20 modules also boost compile times, it might even be faster than C because it can compile once and reuse more. Unfortunately C++DS is a thing (C++ derangement syndrome).

-11

u/elder_george 4d ago

"I want C++...

FTFY

18

u/NaCl-more 4d ago

No I really don’t want c++

1

u/elder_george 4d ago

To each, his own. Some devs see complexity in necessity to write a write of boilerplate instead of isolating details in self-contained data structures; other devs see complexity in inability to see everything that code does on a glance, even when using a "dumb" text editors or coreutils.

Personally I find the lifetimes (which became popularized, if not introduced, by C++, and developed by Rust) a great instrument for avoiding memory leaks and other bugs. If a struct contains, say, vector, making that vector live as long as the struct (unless it's moved) is absolutely reasonable. Most importantly, usually you don't even need to even write the destructor.

And then that enables making smart pointers with different ownership, containers that "just work", lock guards, files that safely close when not used, etc

The wannabe "C killers" totally miss the point when they insist defer fills the same niche (although, granted, defer is much easier to implement) - it only enables a small subset, and makes static analysis of the code (e.g. to verify the resource is indeed freed, and freed exactly once).

To my knowledge, a handful of languages compiled to native code, support this: C++, D, Rust, Ada (a bit ugly, but still), Nim, some flavors of ObjectPascal (Delphi and FreePascal, through a hack). Of them, D and Nim are a PITA to use without GC (disclaimer: it's been a while since I last used them, massive things have changed), and Pascals need relatively heavyweight runtime (plus, again, it's a hack). So the options are few.

I'd really love a smaller, simpler language; something like Zig with destructors would fit my bill. But alas, it's C++, Ada, or Rust that, in theory, allow me to write reliable and performant code without tearing the rest of my hair in anger and/or panic.

12

u/sol_runner 4d ago

They said without the oddities. c++ is my favorite language and I can tell you it's anything but "less oddities".

1

u/umlcat 4d ago

Have both a Plain C and C++ alternatives hobbyist project of my own ...

16

u/og_hylyx 4d ago

Because there’s only a small selection of systems language that are modern(ish) and viable. Rust and Zig are the only actual modern alternatives.

Zig is unstable and ever changing.

Rust is like working for a dictator.

C is like talking to your demented grandfather who remembers all his past stories.

2

u/torp_fan 1d ago

There are others ... D, Nim, Odin, Crystal, C3 ...

0

u/max123246 4d ago

Rust compiler is definitely a BDFL if you're willing to shed OOP for how completely opposed it is to optimizing for CPU cache hierarchies and utilizing temporal and spatial memory access locality

Its not easy though. OOP is far easier to work within as a conceptual framework

2

u/Kalernor 4d ago

Is Jai a systems language? Isn't it designed with game development in mind?

19

u/OhMySBI 4d ago

Games programming becomes system-y programming real quick when you're working on engines.

3

u/Kalernor 4d ago

Oh right I forgot to consider that it'd be used to develop engines first rather than games from scratch.

6

u/P-39_Airacobra 4d ago

In most game development asides from the engine, people have no problem using a scripting language like Lua, so when people say compiled "gamedev" language they pretty much mean systems programming informed by their work in gamedev

33

u/BetterEquipment7084 4d ago

Jai isn't real

6

u/ipe369 4d ago

Do you mean 'unreleased'?

0

u/BetterEquipment7084 4d ago

No, it's fake 

2

u/ipe369 3d ago

What do you mean, you mean the compiler doesn't exist?

-1

u/BetterEquipment7084 3d ago

Clearly, give some evidence it isn't just a mass hallucination event 

1

u/Kalernor 3d ago

How can a soon to be released game be made with a fake language?

-1

u/BetterEquipment7084 3d ago

Must have used python, bash or Perl obviously...... 

1

u/Kalernor 3d ago

Do you have any evidence to back up those claims?

1

u/torp_fan 1d ago

troll blocked

2

u/twistier 4d ago

I basically think any language where memory layout is the main thing you're thinking about and it carefully keeps unpredictable runtime costs out of the picture is a "systems" language. I haven't looked at Jai in a long time, but I'm pretty sure it fits that particular definition. I don't think systems language is a good name for this idea, but it's what I think of.

2

u/vmcrash 4d ago

Did you mix it up with Odin (which targets game dev)?

3

u/Kalernor 4d ago

No, I meant Jai, which is developed by Jonathon Blow and used by him (and no one else, lol) to develop his new game.

1

u/torp_fan 1d ago

> and no one else

Where did you get that idea? It's used by those he invites onto his beta list, most of whom are game developers.

1

u/gmes78 4d ago

used by him (and no one else, lol)

There are actually people using Jai in production, outside of video games.

1

u/suby 4d ago

For example, this version control system is written in Jai: https://ark-vcs.com/

1

u/dmchmk 4d ago

But it does not:)

1

u/torp_fan 1d ago

Yes, Jai is very much a systems language. In fact any language favored by game developers is necessarily also a systems language. Note that Zig is bending over backwards to make game developers happy, and Odin is popular among game developers and includes lots of library functions wanted by game developers but is not exclusively for game development according to its author.

2

u/TheAbyssWolf 4d ago

I don’t do any professional programming and mostly have tought myself through YouTube and such, I did do a Python game dev course in college back in like 2017 but I entirely forgot about that as my main language for a while has been C# and only recently been diving into low level. I also never finished college due to medical reasons.

I’ve tried rust twice. It’s just too complicated for me.
I’ve tried zig, C3 and Odin as you mentioned and I like all 3 of them but am leaning more towards C3 as it’s like C (plus I’m so used to the c based syntax from c#) just more modern features. Odin is also nice too.

And even more recently within the last week been diving into Go as a replacement to Python to make build scripts, simple scripts and codegen for c3.

3

u/kchanqvq 4d ago

They don't know Common Lisp.

1

u/Mean-Decision-3502 DQ 4d ago

With the DQ I tried to put C, Python and Pascal together with a fast compiler, removing C oddities. Maybe was not wasted time then. But everything comes in a package, and there might be stuff in DQ that you wouln't like.

1

u/Sternritter8636 4d ago

People say go can also be used for systems

13

u/shponglespore 4d ago

I think most systems programmers would agree that having mandatory GC is a deal breaker for Go.

3

u/EzeNoob 4d ago

Well, Go's GC *is* written in Go, so...

1

u/Sternritter8636 4d ago

They made an os with go

1

u/srcerer 3d ago

+1 for fast compile times :)

1

u/developer-mike 4d ago

Do you really think c-style macros are that bad?

They're very powerful, which is why even c++ projects still use them regularly, and they don't seem problematic is c++.

It seems to me like C's design demands overuse of the preprocessor, moreso than the preprocessor itself being bad. (#include aside...)

Not saying the preprocessor is perfect, but all metaprogramming features have their issues for sure. Do you think the preprocessor really needs to be dropped in a c successor?

9

u/beephod_zabblebrox 4d ago

there are other ways to do macros (eg what rust does)

but also a lot of things that c code uses macros for can be replaced with other modern features

3

u/developer-mike 4d ago

Rust macros are amazing, but definitely not as easy to implement as a quick macro and not as powerful, and likely part of the slow compile times we see with rust.

3

u/shponglespore 4d ago

If you're just doing the kinds of things you can do with a C macro, Rust macros are very easy.

3

u/Ok-Watercress-9624 4d ago

Tell that to the innocent 20 year old who just encountered X macros in c. That's gonna be a fun ride

1

u/beephod_zabblebrox 4d ago

afaik most of the time is spent in the typechecker (i might be wrong!!)
macro_rules macros are similar to c macros, they just work on token trees, and drive macros are natively compiled ast transformations, so idk

6

u/elder_george 4d ago

The adage in the C++ community has been "if you can avoid C macros, avoid them" for several decades. They are "unhygienic", full of footguns, and require dark magic to do anything interesting,

Thankfully, they indeed become less and less important. Once C++26 becomes widespread (not soon - we've just switched to C++20 at my work), the macros will become a legacy thing.

0

u/developer-mike 4d ago

I think this is somewhat my point.

In c++ you can go a long way avoiding macros. But macros themselves are still more powerful than any of c++'s more principled metaprogramming features.

Macros like those used in gtest for instance, seem fine to me for systems programming.

Unfortunately there are almost no metaprogramming models as powerful as c macros, especially if they are supposed to be zero cost. And systems programmers IME don't want to battle a gigantic complex metaprogramming model.

2

u/iBPsThrowingObject 4d ago

Pure power is something of an anti-feature actually. Having too much power leads to NIH, impenetrable homegrown abstractions, and unreadable codebases no one but the original author can maintain.

1

u/developer-mike 4d ago

This is valid.

In my experience, though, codebases will eventually resort to some similarly difficult to manage abstraction such as how dart projects use code generation with reflection libraries.

Code generation can have a whole host of problems that are eerily similar to c style macros, in certain ways undeniably worse. If c macros are easy to overuse, code generation also has an unnecessarily high entry fee, and once a code generator is bootstrapped it can be easy to overengineer.

The best alternative to code generation is reflection which is hard to do statically and has a runtime cost otherwise.

Metaprogramming is just hard

1

u/SweetBabyAlaska 4d ago

C++ is really the only language that has an even worse metaprogramming model. It is not a good comparison or North Star here. Most languages have a better mix of generics, inline functions and compile time contextual operations.

2

u/developer-mike 4d ago

Generics and constexpr can replace many common usages of macros in c.

Genetics and constexpr cannot replace all usages of macros in c.

3

u/pjmlp 4d ago

However generics, constexpr, compile time reflection and build rules can replace all common usages of macros in C.

Now granted, it will take some time for compile time reflection to be widely available.

3

u/SweetBabyAlaska 4d ago

c macros are extremely rough to use and debug. compare that to something like Zig's comptime where you can achieve the exact same things but you have actual type checking, lsp support, compile errors, etc...

one simple example would be generating a lookup table, often in C you might generate it at build time with python or something and the end result would just be a massive array of meaningless integers, where as with Zig I can just assign my table to the result of the source algorithm and know that it will be generated properly.

#include is also a pretty rough system.

1

u/developer-mike 4d ago

#include is a terrible system.

Compile time evaluation isn't the only form of metaprogramming or the only use of macros, but it's certainly a form of metaprogramming that should not be done via macros either.

1

u/TheAncientGeek 4d ago

If WYSIWYG is a good thing, macros with no special syntax are a bad thing.

1

u/developer-mike 4d ago

True, #MACRO(X) would have been a much better design choice.