printf() metaprogramming challenge
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Sat May 25 14:40:09 UTC 2019
On 5/24/19 7:58 PM, Mike Franklin wrote:
> 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.
The high impact part is the metaprogramming and introspection machinery.
This is where D can contribute something innovative to the larger
programming community. Yet another implementation of formatting
primitives is low impact.
More information about the Digitalmars-d
mailing list