I only looked for a few minutes, so first impressions:<p>1. Try the declaration syntax<p><pre><code> x Foo;
</code></pre>
instead of<p><pre><code> Foo x;
</code></pre>
I tried it before, you might like it.<p>2. I think the way you're defining the AST types is a crapload of work. You should have had a bunch of dumb structs, all in one file.<p>Then you can see everything at once, and you aren't mixing AST representation with codegen logic. Sometimes that's a better way to do algebraic types in C or C++.<p>3. I don't know what "type Foo struct {...}" does but you'll save a lot of work if the type system only has names as types, nominative typing, without losing usability.<p>4. Personally I'd parse straight to the AST type you define and not use the mpc lib with its own AST implementation. I don't believe in parser combinator libraries, especially not in C. It's better to copy/paste those loops. Better than using a parser generator too. But since you have a parser already... not right now.<p>Edit: 5. Avoid looking at Zig, Myrddin, etcetera, if you can. There are obviously paths that any C-like language tends to go down in the 21st century, and the world would probably be better if you rethought the problems from a blanket slate.
Interesting project! I've written compiler frontends for both GCC and LLVM, and surprisingly found it easier to write one for GCC, despite LLVMs reputation on modularity. I'd love to hear the reasons why you chose LLVM for code generation over something else!
> Whack currently lacks a comprehensively designed type system.<p>The type system is 90% of programming language design effort.<p>This is like releasing a car without a 'comprehensively designed engine'.
would recommend looking into writing a grammar, have that generate your AST, then do some transformations on the AST to generate code. you will save a lot of time.<p>I recently did that for a language that i made, via instaparse. the flexibility and speed i gained was very big. my language isn't Turing complete, but it has functions, lookup tables, and some pattern matching.
I wanna see a language that is both dynamic and can be compiled. Runs on a VM and on bare metal. Something like C++, Java, and Python combined. It can definitely be done and would be an interesting exercise.
This is super cool, thanks for sharing!
Are there any books or other resources that you found helpful in learning and implementing Whack? I’m dabbling a little bit with PLs and would love to hear your opinion.
> Whack currently lacks a comprehensively designed type system.<p>To me, this statement means: currently whack is not a properly designed programming language.<p>Proofs are an important part of programming! This is the most important part.
I know that mentioning other language on a thread about A language is contentious, but if you haven’t played with Nim, I seriously recommend you check it out.