template statistics

Adam D. Ruppe destructionator at gmail.com
Fri Jun 5 20:41:53 UTC 2020


On Friday, 5 June 2020 at 20:10:30 UTC, Andrei Alexandrescu wrote:
> It would be great if someone took a look at that.

Yeah, this is why when reducing bugs I often prefer to use 
`printf` or even `assert(0)` or `asm { int 3; }` since it does 
result in a lot less code generated.

BUT, in the context of a regular program, I caution against 
making too big a deal of this. Yes, there's more code than there 
needs to be *for this simple case*, but much of it exists to 
support real world code that is more complicated out of necessity.

People don't actually write "hello world" programs. It'd be 
amusing to have the compiler recognize the input pattern and 
output some hand-tuned perfectly assembly for it.... but it'd 
also be useless. Once you start writing slices instead of 
literals, or enums and structs instead of basic types, much of 
that code is useful anyway.

Not all of it, again, I know some of writeln's branches are 
horrible, and I personally think the wrapping through C's lib 
with additional thread safety on top of it is silly. But those 
decisions are all made for debatably good reasons and at the end 
of the day, is it worth worrying about 0.04s and 200 bytes on a 
hello world build?


More information about the Digitalmars-d mailing list