April 12, 2019
On Friday, 12 April 2019 at 02:29:38 UTC, Walter Bright wrote:

> No they don't. For example, if I saw "isOdd" in code, I'd wonder what the heck that was doing. I'd go look up its documentation, implementation, test cases, etc., find out "oh, it's just doing the obvious thing", and be annoyed at the waste of my time.
>
> It wastes the time of everyone reading the code, documenting the function, and the QA staff. It hides the useful stuff in the library when it's alongside a morass of junk like this. It wastes the time of the poor shlub perusing the library. It makes the library look like a bunch of filler rather than useful stuff.
>
> I don't believe anybody's code is so well-documented that this is all that's left. Meaning you're wasting your time documenting the wrong things.
>
> I call this sort of stuff the "Illusion of Progress".

And what do you have to say about this gem?  https://github.com/dlang/dmd/blob/4c65b8726a66314e12ad1cad66b099d358e7165d/src/dmd/optimize.d#L62-L65

Or this? https://github.com/dlang/dmd/blob/master/src/dmd/clone.d#L150-L154

Both of which were added by you.  It's the same thing.

Mike

April 12, 2019
On Friday, 12 April 2019 at 04:19:19 UTC, Mike Franklin wrote:

> And what do you have to say about this gem?  https://github.com/dlang/dmd/blob/4c65b8726a66314e12ad1cad66b099d358e7165d/src/dmd/optimize.d#L62-L65

```
Expression nullReturn()
{
    return null;
}

return nullReturn;
```

That leaves me dumbfounded every time I see it.

Mike


April 12, 2019
On 4/11/19 10:29 PM, Walter Bright wrote:
> 
>> Creating functions like `isOdd` or `GetLeastSignificantBit` help convey intent without having to supplement code with comments.
> 
> No they don't. For example, if I saw "isOdd" in code, I'd wonder what the heck that was doing. I'd go look up its documentation, implementation, test cases, etc., find out "oh, it's just doing the obvious thing", and be annoyed at the waste of my time.
> 
> It wastes the time of everyone reading the code, documenting the function, and the QA staff. It hides the useful stuff in the library when it's alongside a morass of junk like this. It wastes the time of the poor shlub perusing the library. It makes the library look like a bunch of filler rather than useful stuff.
> 
> I don't believe anybody's code is so well-documented that this is all that's left. Meaning you're wasting your time documenting the wrong things.
> 
> I call this so

Parson me here, but: Bullshit.

I'll qualify that: For code that you write for yourself, I have no doubt that your approach here is both valid and good, and even optimal. But in the general case...umm, no...

See, here's the thing: You, undeniably, have vastly more low-level programming experience than 99.99% of programmers (I would know, I have greater-than-average low-level experience myself)...but to be more specific...to YOU, the pattern "xyz & 1" is (presumably) cognitively synonymous with BOTH "look at the LSB" and "check evenness/oddness". And that's reasonable, because, after all, both interpretations are certainly technically true.

But here's the problem: That's your superpower. It's enviable, it's impressive, but it's absolutely NOT shared by the vast majority of GOOD programmers, let alone rank-and-file ones.

Granted, I will be the FIRST person to jump out and shout "The vast majority of programmers are incompetent hacks, have no idea what they're doing, and don't deserve their own jobs." And yet...Well...look at my low-level experience: I've done videogame programming targeting 386 via Watcom's Doom-famed DOS extender, plus PalmOS equivalent (we're talking Dragonball processor days here, not ARM). I've studied and scrutinized every word publicly written by such low-level greats as Michael Abrash about all of their famed low-level tweaks. I've written homebrew for such now-simplistic systems as the GameBoy Advance and Parallax's "Propeller" microcontroler, including the Propeller's very first audio driver (multichannel, written in 100% ASM, supporting frequency sweeps, music notes A-G, ADSR envelopes, general PCM, and a realtime interactive Piano demo), and the Propeller's first EEPROM driver, plus the Propeller's very first psuedo-3D applications (despite the microcontroller being between NES and SNES in capabilities). I was the first person to get D code running on a Gameboy Advance, period. I implemented Bresenham's line drawling algorithm inside a freaking web browser *loooong* before HTML5. Heck, I entered a GBA coding competition and won the highest spot awarded to an entry by a one-person team. I was writing assembler code on the Apple II when my age was single digit. And I wrote playable software for the Atari VCS/2600 AND designed and built the real-world EEPROM burner and PC driver I used to run said software on a physical Atari VCS/2600.

In short: I...know...low-level. Period.

And yet, even *I* look at "x & 1" or "x % 2", and my first instinct is..."WTF is going on...? Some bit twiddling, but to what purpose...". *Then* I work out what it's actually doing.

And then, if it's "x & 1", I think "This environment uses two's complement, so what are the implications for negative values, and do I need to worry about them?"

If YOU look at "x & 1" and *instictually* see an even/odd check that also supports, and is not thwarted by, two's complement negatives...then  I tip my hat to you good sir for your impressive skills, but you are clearly NOT, by any stretch of the mind, a normal, typical programmer, You're not even a normal/typical *GOOD* programmer. You're an elite. One of the rare, the proud, the few.

For the rest of us, this "x & 1" (heck, even my first instinct would've been to do "x % 2") is *an implementation detail*.
April 12, 2019
On Thursday, 11 April 2019 at 23:23:25 UTC, Tony wrote:
> On Tuesday, 9 April 2019 at 06:23:26 UTC, aliak wrote:
>>
>
>> [0] https://swift.org/blog/swift-5-released/
>
> Still, no (official at least) Windows support. Don't know if that is because there is no interest in broadening the usage or if it is considered too difficult or not worth the effort to do so.

From Chris Lattner (swift/llvm creator): "I think that first class support for Windows is a critical thing, and I doubt anyone in the Swift community would object to it. The problem is that we need to find someone who wants it badly enough and has the resources/know-how to make it happen."

And the Swift for Tensorflow project that he's involved in is also actively looking for someone to add Windows support - but they just can't find anyone :p
April 12, 2019
On Friday, 12 April 2019 at 06:20:39 UTC, aliak wrote:
> On Thursday, 11 April 2019 at 23:23:25 UTC, Tony wrote:
>> [...]
>
> From Chris Lattner (swift/llvm creator): "I think that first class support for Windows is a critical thing, and I doubt anyone in the Swift community would object to it. The problem is that we need to find someone who wants it badly enough and has the resources/know-how to make it happen."
>
> And the Swift for Tensorflow project that he's involved in is also actively looking for someone to add Windows support - but they just can't find anyone :p

I bet if either Google or Apple were willing to actually hire them, they would already have found someone.
April 12, 2019
On Friday, 12 April 2019 at 02:13:12 UTC, Walter Bright wrote:
> On 4/11/2019 6:24 PM, Timon Gehr wrote:
>>>    bool isOdd(int i) { return i & 1; }
>>>
>>> Filling the standard library with trivia is not a good idea.
>> 
>> Yes, if it is used often enough across many projects, adding functions with a simple implementation can be a very good idea. The main point is to standardize the function name and avoid duplicated equivalent code in everyone's personal util libraries.
>
> That would make sense if there was some application-specific higher level meaning to oddness, such as maybe the low bit being used as a flag. But there isn't when it is named "isOdd".
>

I've used n % 2 == 0 millions of times in GUI logic. Applying properties to things that are row'ed-out. Games is another one - very common. Fuzzy matching another one. isOdd would've made the call site a lot more clear.

>
>>> Not knowing about a common operator is not a reason to add library functions.
>> No, but there can be other reasons.
>
> That was the reason given. I'm open to hearing a better one.

Using n & 1 has always been a hack for oddness. It says nothing about what your code is doing. The average programmer would look at it and have to think about what's happening there.

I do understand what you mean about being a bit suspicious about isOdd though when seeing it in code. But I think the same would apply to abs if we had not grown up with it being in math.h. We'd be doing "n>0?n:-n" or "(n+(n>>31))^(n>>31)" - or the more saner would write their own. And then when someone comes and tries to add abs to a standard library functions one could also say "not knowing about [a] common operator[s] is not a reason to add a library functions".

But after all this time working on products as low level as drivers to as high level as web apps, the three things that have been the most important have been readability, maintainability, and correctness.



April 12, 2019
On Friday, 12 April 2019 at 06:50:08 UTC, Paulo Pinto wrote:
> On Friday, 12 April 2019 at 06:20:39 UTC, aliak wrote:
>> On Thursday, 11 April 2019 at 23:23:25 UTC, Tony wrote:
>>> [...]
>>
>> From Chris Lattner (swift/llvm creator): "I think that first class support for Windows is a critical thing, and I doubt anyone in the Swift community would object to it. The problem is that we need to find someone who wants it badly enough and has the resources/know-how to make it happen."
>>
>> And the Swift for Tensorflow project that he's involved in is also actively looking for someone to add Windows support - but they just can't find anyone :p
>
> I bet if either Google or Apple were willing to actually hire them, they would already have found someone.

Swift for Tensorflow *is* a google project.
April 12, 2019
On Friday, 12 April 2019 at 06:14:05 UTC, Nick Sabalausky (Abscissa) wrote:
> Parson me here, but: Bullshit.
...
> But here's the problem: That's your superpower. It's enviable, it's impressive,
...
> In short: I...know...low-level. Period.
>
> And yet, even *I* look at "x & 1" or "x % 2", and my first instinct is..."WTF is going on...?

This is some incredibly strident language to deploy in favor of
isOdd/isEven. Is isOdd actually Julius Caesar? Is this speech
directed at Brutus? After this kind of talk, it would be an
embarrassment if the other party said "OK, actually I agree."
The crowd expects a ritual suicide.

Meanwhile, if you ask a random programmer for a FizzBuzz, you'll
probably get something with a mod 15 in it. IMO that's an obvious
optimization of the task, something you'd think about *after*
writing more naive code that more closely follows the task
description. But everyone knows it now. Their ability to remember
this bit of numerical trivia didn't require them to first become
the "elite of the elite" of programmers.
April 12, 2019
On Friday, 12 April 2019 at 03:04:19 UTC, Andrei Alexandrescu wrote:
> On 4/11/19 10:29 PM, Walter Bright wrote:
>>> Creating functions like `isOdd` or `GetLeastSignificantBit` help convey intent without having to supplement code with comments.
>> 
>> No they don't. For example, if I saw "isOdd" in code, I'd wonder what the heck that was doing. I'd go look up its documentation, implementation, test cases, etc., find out "oh, it's just doing the obvious thing", and be annoyed at the waste of my time.
>> 
>> It wastes the time of everyone reading the code, documenting the function, and the QA staff. It hides the useful stuff in the library when it's alongside a morass of junk like this. It wastes the time of the poor shlub perusing the library. It makes the library look like a bunch of filler rather than useful stuff.
>> 
>> I don't believe anybody's code is so well-documented that this is all that's left. Meaning you're wasting your time documenting the wrong things.
>> 
>> I call this sort of stuff the "Illusion of Progress".
>
> Very well put.
>
> Funny tidbit: "% 2 == 0 appears 63 times in the Apple/Swift repository." That argument is quoted straight from the proposal. Of course, they conveniently neglect to mention that the project has over 2.4 MILLION lines of code. That's 0.002625% or better put 26 ppm. IF there's an argument in there, it must be of a homeopathic nature.
>
> The day we talk ourselves into entering the ilk of isOdd and isEven into the standard library someone please slip me that misericorde.

Not sure these numbers matter. It's the same as adding an identifier to a string that's used more than once. Would you find someone replacing a the string "xyz" with a constant surprising if it was used more than once even? Even if the project had centrillion lines of code?

For the record, I don't see a super need to add an isodd or iseven - i do see the value though. But asking for a misericorde is being a bit dramatic don't you think? :)

Anyway, someone recently posted this gem - https://fs.blog/2016/04/second-order-thinking/ ;). The second order here would be maintainability/learnability/adoption/pleasantness-of-reading/probably-more


April 12, 2019
On 4/11/2019 9:19 PM, Mike Franklin wrote:
> And what do you have to say about this gem? https://github.com/dlang/dmd/blob/4c65b8726a66314e12ad1cad66b099d358e7165d/src/dmd/optimize.d#L62-L65 

Glad you asked. I added it so I could hook the return, which I often do when debugging.


> Or this? https://github.com/dlang/dmd/blob/master/src/dmd/clone.d#L150-L154

The commented out printf gives away the purpose.


> It's the same thing.

Nope.