Fear of Compiler Magic

IchorDev zxinsworld at gmail.com
Fri Aug 2 03:22:28 UTC 2024


I hear people complain about compiler magic a lot. Yes, being 
able to do everything in-language is nice, but compiler magic is 
inevitable and also can be very useful. `assert` is my favourite 
example. Things like Python’s `print` are more dubious. You can 
always make a better print function on your own, right? Whereas 
one assert is never going to transcend another assert, even if 
the way it prints its assertion failure is slow, who cares? The 
program is already functionally dead anyway. Do we really want 
C’s ‘everyone assert for themself’ problem?
And besides that, isn’t ‘compiler magic’ at its logical 
conclusion generally applicable to *any* task performed by the 
compiler? Exception handling, code optimisation, inlining, 
template expansion, `new`, adding two numbers? Compiler magic.


More information about the Digitalmars-d mailing list