printf() metaprogramming challenge
Mike Franklin
slavo5150 at yahoo.com
Fri May 24 23:58:46 UTC 2019
On Friday, 24 May 2019 at 22:59:10 UTC, Walter Bright wrote:
> C's printf has been hammered on by literally generations of
> programmers over 3 decades. While the interface to it is
> old-fashioned and unsafe, the guts of it are rock solid, fast,
> and correct.
That may be true, but one problem with `printf` is it is much too
large and inefficient for some problem domains [1].
Rust has a more efficient `printf` alternative which is not
dependent on a runtime or libc [2].
D could offer a *much* more efficient, pay-for-what-you-use
implementation that doesn't require libc, a runtime, etc., like
Rust's implementation. It wouldn't be easy (especially wrt
floating point types), but it would be a great benefit to D and
its users. Maybe I'll add it to dlang/projects [3].
There seems to be a perception about C that because it's old and
proven, it's magical. There's nothing `printf` is doing that D
can't do better, if someone would just be willing to do the hard
work.
Mike
[1] - Minimizing memory use in embedded systems Tip #3 – Don’t
use printf() -
https://embeddedgurus.com/stack-overflow/tag/printf/
[2] - std.fmt : https://doc.rust-lang.org/std/fmt/
[3] - dlang/projects - https://github.com/dlang/projects
More information about the Digitalmars-d
mailing list