There should only ever be one way to express yourself
https://shkspr.mobi/blog/2024/02/there-should-only-ever-be-one-way-to-express-yourself/
I've been thinking about programming languages and their design.
In her book about the divergence of the English and American languages, Lynne Murphy asks this question:
wouldn’t it be great if language were logical and maximally efficient? If sentences had only as many syllables as strictly needed? If each word had a single, unique meaning? If there were no homophones, so we’d not be able to mix up dear and deer or two and too?
That got me thinking about the creativity which can be expressed in code - and whether its a good thing.
Let's take an incredibly simple and common operation - incrementing an integer variable by one. How would you do that? You've probably see these variations:
$i = $i + 1;
or
$i = $i++;
or
$i = 1 + $i;
or
$i = int( float_adder( float($i), 1.00 ) );
or
i1, i2 = i1^i2, (i1&i2) << 1
I'm sure you can come up with a few more esoteric methods.
The Python programming language has a list of aphorisms for good programming practice. One of which is:
There should be one-- and preferably only one --obvious way to do it.
Is that right? As described in What is Pythonic?, the Python language itself has multiple ways to accomplish one thing.
But, is it a good idea?
Back to Lynne Murphy again:
No, absolutely not. No way. Quit even thinking that. What are you, some kind of philistine? If Shakespeare hadn’t played with the number of syllables in his sentences, he would not have been able to communicate in iambic pentameter.
Shakespeare wasn't writing Python though, was he?
https://shkspr.mobi/blog/2024/02/there-should-only-ever-be-one-way-to-express-yourself/
@blog I've been thinking about this recently.
An update to MS Outlook at work has made the style/grammar checker more fussy. My new phone does it, too.
Yes, "we definitely should do X" is more verbose than "we should do X", but the "definitely" is _my_ voice and I wanted to convey the enthusiasm.
If everyone takes the suggestion all the time, our communication may be more efficient, but it will also be bland.
@volcan01010 @blog I've had the same argument with the Office grammar editor. I want to tell it to mind its own business and be quiet. But then I also work with a lot of people where English is not their first language, and think it might be easier for them if I simplified my writing.
I'm always reluctant but I end up following the suggestion about 50% of the time—and hating how dull and flat it ends up sounding.