Hello,
Have never posted here before and just registered yesterday, although I have browsed the site a few times before. Love the handmade manifesto!
This seems like the right place to post about my language, called Gordon. It's a compiled imperative language similar to C. Here are some of its features:
The compiler is 34k lines of code with blanks and comments and it's self-hosting (using LLVM). The standard library on the other hand has almost nothing in it yet, it's a little over 600 lines. There are currently no known bugs because I have fixed every bug that has occurred to me along the way. Only x86-64/Linux is currently supported. Oh, and there is no website :P
Here is some Gordon code to look at: https://gist.github.com/tjhann/f26dac0b7c99e850c210a56d61193620
One thing I wanted to make sure is to keep the compiler from being too tightly coupled with LLVM which is the primary reason it uses an intermediate representation (IR). The IR makes it fairly easy to make other backends for Gordon and I hope to finally have a C backend and be able to reboot from C.
I might need a lot of help with that though because I don't actually have a background in C, I come from D, which clearly shows in the syntax and feel. I always liked the core D, but D never provided the quality and stability I wanted. I sticked to a very small subset of it too – I'm not a big fan of metaprogramming.
The compiler and std: https://github.com/tjhann/gordon
Binaries: https://github.com/tjhann/gordon-boot
Edit: I've got a little website now: https://tjhann.github.io/gordon-web/. For new users posting here, you may be shadow banned and nobody else can see your posts. I'm seeing a post from James indicated on the forums page but can't see the post.
Replicating C++ features is a fine way to learn making compilers, but if you want the language to gain popularity in the long run, you need some major advantages over C++ so that people want to make the switch after having used it for many decades. Many new languages add features on top of C that already exists in C++.
Some of the C++ pitfalls that can be addressed in your language as a start:
Then look at the worst coding nightmares people have and try to find a new language feature that can solve many of them without being a do everything code generator. Most progammers cannot handle macros and code generators safely but they should still have a language that lets them solve their problems in real life.
I'm not really replicating C++ features nor was I thinking C++ at all while I created this. I simply made Gordon based on my experiences with D and primarily for myself, to support my way of doing programming without trying to please anybody else. Besides that, it's only my gift to whoever knows how to appreciate it.
One big point about Gordon is that it's small and simple. That is an advantage that I love perhaps most about it.
If I could choose which group of programmers Gordon would attract the most, it would be C coders.
Yeah, I generally don't much like features that generate code. That's why Gordon's macros only ever yield a single expression, for instance, and there is no preprocessor. My way of working has never involved much metaprogramming and my experience is that it's often a huge mistake to go for it. People think they need it when they don't.
That's one reason why wanted to leave D behind, it provides lots of metaprogramming and just about every D coder seems to love that stuff – I was an exception.
A couple features to prevent mistakes:
Thanks a lot for your input!
Let me expand on the module system and how it works with conditional compilation.
It's influenced by Rust in that there's index modules, one per directory. Unlike other modules, they can contain module declarations. One might look like this:
// One can define custom conditional symbols like this. // They are automatically visible to all submodules. #define cond = abc || def; // Modules can be single files or directories of files. If the condition evaluates // to false, the compiler won't try to open the files or directories at all. #setup[macos && cond] { module math; module xyz; } #else { // ... } int main() { return 0; }