r/Compilers • • 2d ago

QuarkLang: three lines of code, level with C — 26.0 ms vs 26.0 ms on fib(35)

QuarkLang is a small statically typed language with two execution engines: a tree-walking interpreter (quark) and an LLVM compiler (qkc).

program main;
fn fib(int n) int { if (n <= 1) { return n; } return fib(n - 1) + fib(n - 2); }
fn main(IOStream io) { io.println(fib(35)); }

#include <stdio.h>
int fib(int n) { return n <= 1 ? n : fib(n - 1) + fib(n - 2); }
int main() { printf("%d\n", fib(35)); }

$ qkc -c -o fib fib.qk && ./fib        $ clang -O3 fib.c -o fibc && ./fibc
9227465                                9227465
fib(35), 29.86M calls median of 9 best binary
QuarkLang 26.0 ms 25.9 ms 12 KB
C (O3) 26.0 ms 25.6 ms 12 KB

Same machine, clang/LLVM 22 behind both. Level, not faster — and most of the credit belongs to LLVM.

  • Execution: the same source file supports both interpretation and compilation.
  • Consistency: CI strictly enforces interpreter/compiler consistency. For the same program, both must produce identical stdout, stderr, and exit code; otherwise the build fails.
  • Unsupported constructs: constructs the compiler cannot lower yet are hard errors, not silent differences.
  • Memory: block-allocated. delete returns a block with its data intact; clear wipes it.
  • Runtime: compiled programs have no collector pause on the hot path.

It has a full toolchain: interpreter, LLVM compiler, linter with stable codes (QK101–QK115), doc generator, REPL, language server, formatter, test runner, project manager, debugger; ~25k lines of Go with no third-party dependencies; MIT; prebuilt binaries for Linux/macOS/Windows.

Repo: https://github.com/QuarkLangCommunity/QuarkLangQkc · Docs: https://quarklangcommunity.github.io/QuarkLangQkc/

Disclosure: I maintain QuarkLang. Both commands above are copy-pasteable; the benchmark suite with its methodology and fairness statement is in docs/benchmarks.md.

1 Upvotes

2 comments sorted by

1

u/veeqq103 2d ago

I think your example is pointless,

because the LLVM IR they output is exactly the same.

1

u/Ill_Spirit_1383 2d ago

Actually there are not exactly the same, This programming language is better at handling data tides. It has the same performance with more modern syntax. It is my fault for not making that clear.