by switchbak · 1w ago · 0 comments
I think we could do something similar today - very fast compilation, and straightforward but efficient machine code. And perhaps bolt on the heavy duty optimizations where it is needed. Many JIT's work similar to this, but it seems like you could do it in an AOT style too.
Well, in a world where many among most used apps are made of NodeJS and Electron frontend, I think we are very far away from having to worry about those optimizations in most contexts. Having those written in TP with zero optimizations would still be more resource efficient and performant.
And when it comes down to squeezing last drop of performance, we forget compilers and still rely on assembly wizards tuning BLAS routines, crypto code etc.
It does make you wonder how much we could simplify and take away while still having things be blazing fast. I would assume some of the old optimizations are actually hurting things on newer architectures.
But I mean more like
- being able to explicitly tell to unroll this loop N times
- native support for builtin SIMD vector types (it can use platform-dependent instructions, whatever)
- specifying aliasing manually, built-in support for range types
- having explicit control over switch statement code generation
- good metaprogramming (doesn't matter if compile-time maths doesn't exactly match runtime behaviour), compile-time code generation/modification
- [[likely]] hints but actually respected i.e. having a guaranteed effect on code layout
- of course no headers, the unit of compilation being a whole library
I don't think it really needs to be single-pass in order to be fast, just cut out most of the heuristic-based optimisations from the backend and make them explicit keywords/attributes in the code...
What you are describing is what Zig spent years to try to become while running away from LLVM. Sure thing there are other less popular attempts which I can't even bother to list here, not because they are somehow worse, but because they are even further away from gamedev practice that I care about.
I don't know what the economy of generated code would be. It is up for debate right now.
What I can definitely see now is that human-only code made this way is not going to pay off. It can only be an expense for someone who has unlimited budget to spend on a whim.