So, to print or not to print?
cym13 via Digitalmars-d
digitalmars-d at puremagic.com
Tue Apr 26 05:18:11 PDT 2016
On Tuesday, 26 April 2016 at 08:50:23 UTC, ixid wrote:
> 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.
It's not print itself that is likely to confuse a newcommer, you
seem to forget that there is a whole programming language and
ecosystem around it.
The first questions I expect are "when should I use print and
when use writeln?" for they share a common role with common
features.
The second thing is that it will only make it harder for them to
read other's code: having one way (although not perfect) to do
things helps maintaining coherence accross any codebase.
Multiplication of functions to do the same things with only a
slight change brings only disarray.
Finally it doesn't bring much. One learns writeln, laments a bit
that it doesn't put spaces itself then just accepts it. I do
think that easing the path of newcommers is important, I don't
think print is a good way to do that. I'm all with J.M.D there.
More information about the Digitalmars-d
mailing list