So, to print or not to print?
ixid via Digitalmars-d
digitalmars-d at puremagic.com
Tue Apr 26 01:50:23 PDT 2016
On Tuesday, 26 April 2016 at 03:13:22 UTC, Jonathan M Davis wrote:
> On Tuesday, April 26, 2016 01:44:07 Jack Stouffer via
> Digitalmars-d wrote:
>> On Monday, 25 April 2016 at 19:35:04 UTC, Andrei Alexandrescu
>>
>> wrote:
>> > https://github.com/dlang/phobos/pull/3971
>>
>> I really don't see the utility of the function over writefln
>> being great enough to warrant inclusion. I'd vote not to
>> include it.
>
> I concur. IMHO, it doesn't add enough value to be worth it, and
> given that it adds yet another printing function, it'll
> increase confusion with newcomers.
>
> - Jonathan M Davis
Please find an example of a newcomer who would be confused by
print. This is an objectionable argument because none of the
people making it are newcomers, you're using an entirely
theoretical newcomer as your argument, and seem to think
'print(a, b, c);' is going to confuse people more than
'writefln("%s %s %s", a, b, c);' which is ridiculous.
Print function names are hardly pristine snow of simplicity that
'print' is going to muddy. What do you think goes through a
newcomer's mind when they see 'writefln'? For the vast majority
it's almost certainly not 'write formatted line', it's 'write
wagarble' and they'll forget wagarble next time they want to use
it.
Print is incredibly simple and a low barrier to entry. When
people need more complexity they can read up on other functions.
You barely need to read anything to use print and you don't need
to recheck the documents for using it the second time. Most users
will find functions like writefln a bit nightmarish when they
just want the program to do the most basic thing to interact with
it in the first place. This has been further compounded by some
of the alternative suggestions where people immediately suggest
turning it into a template function etc.
Yes, you could sugar up everything and turn the language into an
unmaintainable mess, it's a question of effort vs reward.
Barring main, printing something is likely the most commonly used
function and this covers 90% of what people use it for in the
simplest and easiest way. People fall into using languages
because they're elegant, powerful and easy to use. Suddenly all
the little code examples people will be exposed to are that much
clearer and more elegant. The benefit is far greater than the
cost.
More information about the Digitalmars-d
mailing list