So, I like C. I like how simple it is and I just like using it. I'm tired of overcomplicated languages. But of course C is not a perfect language. There are so many features I'd really like to have. So many things that could be improved or redesigned in a better way. So many bad decisions and suboptimal tradeoffs.
If you don't care, you can just scroll to "The Elash language" section. I know I should've show some code example here to actually get you interested but I currently don't have much to show. But... here's a "game" made with SDL3 in Elash!
My problems with C
I'm very happy with C's philosophy, but there are some things I've always wished it did differently.
- Native tagged unions: In C, you usually build them as a struct with an enum tag plus a union (or use tricks like a common tag header in every variant). All of these require a lot of boilerplate, and there's no pattern matching. I don't think full pattern matching is strictly necessary, but I'd LOVE something like
if (SomeVariant v = my_union) use(v);. In C it's more like if (my_union.kind == MYUNION_SOME_VARIANT) use(my_union.as.some_variant);, and you repeat the field name every time. However you define it, it's never as convenient as a built-in tagged union, and the compiler can't enforce safety or stop you from accessing random fields before checking which one is actually active. - Optional types: For an optional int in C, you use a sentinel value such as 0, -1, or maybe even
INT_MAX/INT_MIN depending on which values you don't need. If you really need the whole range, you can wrap it in a struct with a bool has_value; field, which is really inconvenient, at least for me. On the other hand, we have pointers, and they have the standard NULL constant, but the problem is every pointer is "optional": there's no way to encode a pointer that can't be NULL in C's type system, so you rely on comments and docs, and the compiler doesn't read those or enforce them. There are compiler-specific "solutions" like __attribute__((nonnull)), but that's just not the same thing. - More advanced preprocessor: Many people will disagree, but I think the concept of a preprocessor separate from the core compiler is a great thing. But CPP is very limited and requires hacks if you want to use it for something more complex. It doesn't support recursion and iteration in a normal way and it cannot evaluate expressions (I mean, it can, but only in
#if directives). - Slice types: To declare a function that takes a slice you usually write
(int* xs, size_t count), and to store one you need two struct fields like things and things_count. That's inconvenient. It's much better to store a slice in one variable without defining your own struct every time you need a slice of a type that doesn't already have one. And int[] xs looks better than IntSlice xs (: - Declaration syntax: No need to explain. It's just terrible. But people don't get why. It's not because the type comes before the variable name. You can design readable, consistent type-first syntax. What separates good and bad declaration syntax is whether it reads naturally left to right or right to left without parentheses. Just reversing C's syntax doesn't make it readable.
(*signal(int, (*)(int): void)): void isn't any better than void (*signal(int, void (*)(int)))(int);. But void(int)* signal(int, void(int)*); is, because it reads cleanly left to right. Typedefs only partly solve this, and there are still footguns like int* x, y;. - Weak type aliases: Typedefs in C are only aliases. You can use the typedef and the original type interchangeably. You can wrap the type in a struct, but then you lose access to operators etc. It would be nice to have some way to define "strong type aliases", like in Go.
- No defer: Pretty obvious,
defer statements are really useful and C just doesn't support them. If you follow recent C standards you may know that this feature is slated for C29, but that standard will be released around 2029 and it'll take a few more years before it's production ready.
There are so many other examples, that I will not explain all of them, but a few more examples are: Bad standard library, No built-in collections, char vs unsigned char vs signed char, Built-in string views, Arrays as first class values, Loops over collections, Embedding files at compile time (C23 added #embed but most compilers don't support it yet), Anonymous functions, Implicit narrowing conversions, ...
The Elash language
I know of C3, Zig and other languages that tried to "replace C" but none of them is quite what I wanted, and also I want[ed] to learn langdev and compiler architecture, so I decided to create my own programming language, called Elash (the name doesn't mean anything, it just sounds cool).
It obviously won't "replace C", and that was never the goal. As I already said, I wanted to learn compilers architecture and experiment with designing my own language just how I want to.
It's meant to be a really simple, relatively low-level language that is [semi-]familiar to C developers, convenient to use, and fixes the issues listed above.
I started the project about 9 months ago, I took a couple of breaks but I was working on it regularly for a very long time, initially with a friend of mine but later I became the only maintainer. The project isn't finished. In fact, it's still in the early developement stage, though it's already (kind of) usable for simple tasks. Writing a programming language takes time and you can’t just finish it in a week like many vibecoded languages posted here and on other subreddits.
The compiler is written in C using the LLVM C API (it's built as a multi backend compiler from the start though currently LLVM is the only backend)
I'm looking for people interested in the project; if you want to contribute to the language, share your ideas or just see how development is going, you might want to join the Discord server I've just created. And here is the GitHub repository.