food for thought - swift 5 released - bottom types, string interpolation, and stuff.

Nick Sabalausky (Abscissa) SeeWebsiteToContactMe at semitwist.com
Wed Apr 17 06:11:56 UTC 2019


On 4/13/19 4:38 AM, Abdulhaq wrote:
> On Saturday, 13 April 2019 at 05:37:31 UTC, Walter Bright wrote:
>> On 4/12/2019 10:18 PM, H. S. Teoh wrote:
>>> writing (x % 2) conveys intent much better
>>> than (x & 1).
>>
>> They produced different code.
> 
> This is a non-sequitur, the fact that some compilers produce different 
> assembly does not say anything about how well the functions convey intent.
> 
> However, in general, knowing that the bit-twiddling variety of a 
> function produces different code to the mathematically precise 
> expression, would just make me stop and think twice, three or even four 
> times

Actually, this right here is *EXTREMELY* good reason in favor if 
isOdd/etc (again, not that my intent is to get it into Phobos).

Even if a programmer IS fully versed in low-level bit twiddling[1] and 
they know full-well (and remember off-the-top-of-their head) that "& 1" 
is a parity check (AND they remember offhand which 0-vs-1 result means 
which) AND they know full-well (and remember off-the-top-of-their head) 
that "% 2" *ALSO* means parity check (and remember offhand not only 
which result means which, but ALSO remembers offhand without having to 
think about it, whether the the "&1" result is equal or inverted from 
the "%2" result)...

[1] Not all programmers are, and frankly, not all programmers need to be 
- even as much as I believe low-level experience improves a programmer.

...EVEN (falsely) assuming ALL of that above is off-the-top-of-the-head 
basic knowledge for ALL users of your supposedly *MULTI-PARADIGM* 
language...then...you *STILL* face the problem of whether your users 
know that there's a FREAKING CODEGEN DIFFERENCE in "&1" vs "%2"..AND 
that one results in better codegen, *AND* *WHICH ONE* results in better 
codegen!!!

This example is *the whole freaking point(!!!)* behind basic HLL 
abstractions!@!!

People need to know the even/odd parity of a value, either they check it 
via some provided guaranteed-optimal interface...or they roll-their own 
and are EXPECTED to guess the preferred implementation between two 
theoretically-equivalent implementations by enumerating and verifying 
the codegen details of the known-possible implementations. Is it an 
unstated GOAL here to waste developers' time and effort???

Again, I am *not* looking for inclusion of isOdd/etc into Phobos. If you 
really want your language to be a systems-language instead of 
multi-paradigm, then that's your business. But what I *DO* care about is 
that at *least* one of the leaders behind D actually *comprehends* the 
freaking basics of programming psychology and fundamental logic well 
enough to admit the validity of this reasoning without allowing 
themselves to be biased by their own personal programming abilities.

I'm not a fan of Apple products (aside from Apple II), or Apple 
platforms (beyond Apple II), or even modern-day Apple as a company...but 
even *I* can recognize these basic, obvious truths:

1. Apple has a vested interest in being inclusive of novice and 
less-than-expert programmers.

2. Apple's inclusion of isOdd/etc successfully addresses what is quite 
*obviously* (based on the very same stackoverflow data that Walter & 
Andrei have mocked and knee-jerk disregarded) what is *clearly* a very 
real, common stumbling block among non-low-level-experienced 
programmers. (Again, disregarded by W&A as incompetent and unworthy of 
D-user status.)

3. DLang leadership considers both novice developers as well as other 
developers who lack sufficient low-level experience as failing to meet 
the minimum bar for being a D user.

4. DLang isn't especially interested in recruiting novice developers nor 
other developers who lack sufficient low-level experience, whereas other 
languages like Swift are.

5. Therefore, when it comes to language adoption, Swift has a notable 
leg-up against D - which D leadership willingly accepts.

If W&A are content with the truths of 1-5, then I have no issue with D 
beyond the disappointment that it's not as multi-paradigm as I'd thought 
and hoped for. But if W&A object to any of 1-5, then that's far worse - 
I take issue with the ability and willingness of D leadership to 
recognize, value, and follow basic psychology of programming, and basic 
logic and reason in favor of flawed, unvalidated personal biases.


More information about the Digitalmars-d mailing list