www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - food for thought - swift 5 released - bottom types, string

reply aliak <something something.com> writes:
I personally love swift as a language because it's just a 
pleasure to write _and_ read. Swift 5 was released recently [0] 
and has a few interesting additions, particularly the additions 
they've added to string interpolation [1] so that you could do 
things like

let a: MyType = "this is an \(type: .interpolated) string"

The "this is a" part is parsed separately by 'a' and the 
interpolated part "\(min: 1) is parsed as a type that is expected 
by your StringInterpolation implementation

// member function that implements string interpolation
mutating func appendInterpolation(min: Int) {
   //...
}

And then as is usual with swift, they try and make it as readable 
as easy to reason with as possible, so they added things like 
isOdd, isEven, and isMultiple(of:) [2] so that you don' t have to 
mentally parse something like "% x == 0" or any bit operation 
magic that tries to be too clever to do the same thing.

And another cool thing was they took their bottom type and made 
it conform to a hashable and equatable type [3]. It would be the 
equivalent if D had an Expect(SuccessType, ErrorType) type and if 
either success or error type could never happen, could be 
replaced by Bottom:

alias NeverError(SuccessType) = Expect!(SuccessType, bottom_t);
alias NeverSuccess(ErrorType) = Expect!(bottom_t, ErrorType);

[0] https://swift.org/blog/swift-5-released/
[1] 
https://github.com/apple/swift-evolution/blob/master/proposals/0228-fix-expressiblebystringinterpolation.md
[2] 
https://github.com/apple/swift-evolution/blob/master/proposals/0225-binaryinteger-iseven-isodd-ismultiple.md
[3] 
https://github.com/apple/swift-evolution/blob/master/proposals/0215-conform-never-to-hashable-and-equatable.md

Cheers,
- Ali
Apr 08
next sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 4/8/2019 11:23 PM, aliak wrote:
 [2] 
 https://github.com/apple/swift-evolution/blob/master/proposals/0225-binaryinteger-iseven
isodd-ismultiple.md 
"Stack Overflow questions: c - How do I check if an integer is even or odd? 300,000+ views java - Check whether number is even or odd 350,000+ views Check if a number is odd or even in python 140,000+ views" Huh.
Apr 10
parent reply mate <aiueo aiueo.aiueo> writes:
On Wednesday, 10 April 2019 at 21:39:36 UTC, Walter Bright wrote:
 On 4/8/2019 11:23 PM, aliak wrote:
 [2] 
 https://github.com/apple/swift-evolution/blob/master/proposals/0225-binaryinteger-iseven-isodd-ismultiple.md
"Stack Overflow questions: c - How do I check if an integer is even or odd? 300,000+ views java - Check whether number is even or odd 350,000+ views Check if a number is odd or even in python 140,000+ views" Huh.
Shocking indeed.
Apr 11
parent reply Dennis <dkorpel gmail.com> writes:
On Thursday, 11 April 2019 at 20:32:33 UTC, mate wrote:
 On Wednesday, 10 April 2019 at 21:39:36 UTC, Walter Bright 
 wrote:
 On 4/8/2019 11:23 PM, aliak wrote:
 [2] 
 https://github.com/apple/swift-evolution/blob/master/proposals/0225-binaryinteger-iseven-isodd-ismultiple.md
"Stack Overflow questions: c - How do I check if an integer is even or odd? 300,000+ views java - Check whether number is even or odd 350,000+ views Check if a number is odd or even in python 140,000+ views" Huh.
Shocking indeed.
I don't get it. What's shocking about it, that people often need to know the parity of a number or that people aren't born with the knowledge that the % operator can be used for that?
Apr 11
next sibling parent Julian <julian.fondren gmail.com> writes:
On Thursday, 11 April 2019 at 21:21:16 UTC, Dennis wrote:
 On Thursday, 11 April 2019 at 20:32:33 UTC, mate wrote:
 On Wednesday, 10 April 2019 at 21:39:36 UTC, Walter Bright
 wrote:
 On 4/8/2019 11:23 PM, aliak wrote:
 [2]
 https://github.com/apple/swift-evolution/blob/master/proposals/0225-binaryinteger-iseven-isodd-ismultiple.md
"Stack Overflow questions: c - How do I check if an integer is even or odd? 300,000+ views java - Check whether number is even or odd 350,000+ views Check if a number is odd or even in python 140,000+ views" Huh.
Shocking indeed.
I don't get it. What's shocking about it, that people often need to know the parity of a number or that people aren't born with the knowledge that the % operator can be used for that?
The perspective of the shocked is: these people are asking if a value has a particular property. Rather than *thinking* about the property and the tools at hand, and connecting them to arrive at a solution, they're just groping for a language valueHasProperty feature--and are given it, when it's lacking. This obviously can't scale to real software, though. There's no expectation that Swift learners will put Applications.Games.SimilarTo(Games.AngryBirds, 0.95); in a file and compile that and then ship the result. And it seems to be obvious that no thought at all happened, because oddness is a really easy property of a number to test. Geez, it's not like we're expecting people to have memorized their hex and octal digits. But, I'd say that's not so obvious. On the simplest stuff especially, people are not satisfied with only coming up with a solution. They want a solution that can't be criticized. Suppose someone was learning D, and when they couldn't remember writeln offhand hand, they wrote something like foreach (char; str) { asm { // hardcoded Linux write() syscall of single character } } Would you reaction to this code be: a) Wow! It's great how you filled your D library gap with so much other knowledge, to arrive at a functional solution. b) Criticism #1: this will be obnoxiously slow. ... Criticism #40: I hate you. If a language *does* have a valueHasProperty built-in, people want to know so that they can use it.
Apr 11
prev sibling next sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 4/11/2019 2:21 PM, Dennis wrote:
 I don't get it. What's shocking about it, that people often need to know the 
 parity of a number or that people aren't born with the knowledge that the % 
 operator can be used for that?
bool isOdd(int i) { return i & 1; } Filling the standard library with trivia is not a good idea. Not knowing about a common operator is not a reason to add library functions.
Apr 11
next sibling parent reply Mike Franklin <slavo5150 yahoo.com> writes:
On Thursday, 11 April 2019 at 23:03:00 UTC, Walter Bright wrote:

   bool isOdd(int i) { return i & 1; }

 Filling the standard library with trivia is not a good idea. 
 Not knowing about a common operator is not a reason to add 
 library functions.
For me it's not about knowledge of the operator. It's about conveying the reason for why that operation is being done. For example, if you do `i & 1` are you checking for even or odd, or are you masking off irrelevant bits. Creating functions like `isOdd` or `GetLeastSignificantBit` help convey intent without having to supplement code with comments. Mike
Apr 11
parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 4/11/2019 4:24 PM, Mike Franklin wrote:
 On Thursday, 11 April 2019 at 23:03:00 UTC, Walter Bright wrote:
 
   bool isOdd(int i) { return i & 1; }

 Filling the standard library with trivia is not a good idea. Not knowing about 
 a common operator is not a reason to add library functions.
For me it's not about knowledge of the operator.
That was the reason given for it.
 It's about conveying the 
 reason for why that operation is being done.  For example, if you do `i & 1`
are 
 you checking for even or odd, or are you masking off irrelevant bits.
If you're masking bits, you should call it: return i & MyBitFlag;
 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".
Apr 11
next sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
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.
Apr 11
next sibling parent matheus <m g.com> writes:
On Friday, 12 April 2019 at 03:04:19 UTC, Andrei Alexandrescu 
wrote:
 The day we talk ourselves into entering the ilk of isOdd and 
 isEven into the standard library someone please slip me that 
 misericorde.
Just for fun: https://old.reddit.com/r/programming/comments/886zji/why_has_there_been_nearly_3_million_installs_of/ https://news.ycombinator.com/item?id=16901188 Matheus.
Apr 11
prev sibling parent aliak <something something.com> writes:
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
Apr 12
prev sibling next sibling parent reply Mike Franklin <slavo5150 yahoo.com> writes:
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
Apr 11
next sibling parent reply Mike Franklin <slavo5150 yahoo.com> writes:
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
Apr 11
parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 4/12/19 12:32 AM, Mike Franklin wrote:
 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/dm
/optimize.d#L62-L65 
``` Expression nullReturn() {     return null; } return nullReturn; ``` That leaves me dumbfounded every time I see it.
Well it's a local function which drastically restricts its clowniness. In all likelihood appeared as a result of refactoring gotos away. Could safely go, but either way won't sensibly change the state of affairs. The other you mentioned seems to be a debugging hook, which seems reasonable. At any rate, we need to make progress from the pot-calling-the-kettle-black stance to a net positive gradient, e.g. pull requests that improve the codebase.
Apr 12
prev sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
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/dm
/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.
Apr 12
parent Mike Franklin <slavo5150 yahoo.com> writes:
On Friday, 12 April 2019 at 10:45:15 UTC, Walter Bright wrote:
 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.
Ok, you got me, Walter. Touchez.
Apr 12
prev sibling next sibling parent reply "Nick Sabalausky (Abscissa)" <SeeWebsiteToContactMe semitwist.com> writes:
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*.
Apr 11
next sibling parent reply Julian <julian.fondren gmail.com> writes:
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.
Apr 12
parent Laeeth Isharc <laeeth kaleidic.io> writes:
On Friday, 12 April 2019 at 07:04:07 UTC, Julian wrote:
 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.
I'm more in the Walter and Andrei camp here, but I could see that in a different context isOdd would be a useful contribution to the standard library. When people have strong emotional reactions to technical questions then quite often it's an indication that it's a question of values that has a technical expression. From a narrowly technical perspective there's no way to decide I think - it's not like one choice strictly dominates another. So you have to make a choice based on what's most important to you, and that's what values are about. I think for me and in my commercial context it's the values that are the most appealing aspect of D, with the technical aspects of D as it stands today being an expression of those. For example making D accessible to people who are put off by discomfort - it's not like anyone here thinks yes the user must suffer. It's just that some other things are much more important to the leadership and community and choices are made accordingly. It's a terrible idea to try to be all things to all people, and a much better idea to be the thing that you uniquely are destined to be. Because the world is quite large these days and having an inordinately high appeal to part of the population is a better position to be in than being moderately appealing to everyone. An inordinate love of comfort is the civilisation-killer and it's not great for an enterprise either. There's a growing movement to embrace discomfort and they might just have something.
Apr 14
prev sibling next sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 4/11/2019 11:14 PM, Nick Sabalausky (Abscissa) wrote:
 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.
Knowing what (x & 1) is is a superpower? What about (x + x) ? I'll cop to knowing half the x86 hex opcodes is a tad unusual, like knowing all the dialog to Star Trek TOS, but not (x & 1). (Before you ask, the opcodes applies to me, the STTOS applies to at least 3 people I know.) If you want isOdd() for your own personal library, feel free. Putting it into Phobos, however, is not happening.
Apr 12
next sibling parent Dennis <dkorpel gmail.com> writes:
On Friday, 12 April 2019 at 11:03:21 UTC, Walter Bright wrote:
 Knowing what (x & 1) is is a superpower? What about (x + x) ?
Most new programmers have a math background and (x + x) is taught in middle school. CPU math can be very unintuitive however. You might not raise an eyebrow when I state `1/2 == 0` or `1.0 - 0.9 - 0.1 != 0`, but it surprises newcomers. (x & 1) assumes knowledge of bitwise operators and integer representations (it wouldn't work on negative integers in 1's complement). This is part of a student's implementation of a hash function in Java, taken from an algorithms course I was teaching assistant for: ``` String bstring = Integer.toBinaryString(b); if(bstring.length() > 31) { bstring = bstring.substring(bstring.length() - 31, bstring.length()); } b = Integer.parseInt(bstring, 2); ``` The description of the last step was "H = (the last 31 bits of of b) mod s". Many students did it like this. It's tempting to think they are just ignorant, but is it really reasonable to expect ANY programmer to be comfortable with bit-math?
 If you want isOdd() for your own personal library, feel free. 
 Putting it into Phobos, however, is not happening.
I can't speak for everyone, but I'm not vowing for anything like this in D. D is a system's programming language, and it can expect a certain of level of proficiency of its adopters. I just feel like some responses here express the sentiment 'look what a dumb decision Swift developers just made', while I think that it can be very reasonable given the userbase of Swift.
Apr 12
prev sibling next sibling parent Steven Schveighoffer <schveiguy gmail.com> writes:
On 4/12/19 7:03 AM, Walter Bright wrote:
 On 4/11/2019 11:14 PM, Nick Sabalausky (Abscissa) wrote:
 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.
Knowing what (x & 1) is is a superpower? What about (x + x) ? I'll cop to knowing half the x86 hex opcodes is a tad unusual, like knowing all the dialog to Star Trek TOS, but not (x & 1). (Before you ask, the opcodes applies to me, the STTOS applies to at least 3 people I know.) If you want isOdd() for your own personal library, feel free. Putting it into Phobos, however, is not happening.
Here's the deal: 1. You don't include it in the standard library. 2. People who don't know the best way look it up on stackoverflow, and learn that they can do x & 1. 3. Now they have a superpower too. Win-win. -Steve
Apr 12
prev sibling next sibling parent reply Nicholas Wilson <iamthewilsonator hotmail.com> writes:
On Friday, 12 April 2019 at 11:03:21 UTC, Walter Bright wrote:
 On 4/11/2019 11:14 PM, Nick Sabalausky (Abscissa) wrote:
 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.
Knowing what (x & 1) is is a superpower? What about (x + x) ?
Its not about not knowing, its that it takes more time to decipher. People do waaaay more math than bit operations (which is why hash functions are still black magic to me).
Apr 12
parent reply "Nick Sabalausky (Abscissa)" <SeeWebsiteToContactMe semitwist.com> writes:
On 4/12/19 2:33 PM, Nicholas Wilson wrote:
 On Friday, 12 April 2019 at 11:03:21 UTC, Walter Bright wrote:
 Knowing what (x & 1) is is a superpower? What about (x + x) ?
Its not about not knowing, its that it takes more time to decipher. People do waaaay more math than bit operations (which is why hash functions are still black magic to me).
I'd argue it's not really even about the time it takes. It's about the cognitive load. (Though that does admittedly translate into additional time, among other things.) ... Come to think of it, just a random stray thought here...I think it would benefit the programming world if the relationship between code, languages and cognitive load (and heck, just the psychology of code in general)), plus why cognitive load matters, were incorporated directly into programming instruction. Really, if you think about it, real-world programming is *all about* managing the interplay between logic and psychology. I think we would do well to incorporate the psychological aspects in teachings just like we do the logic side. (Maybe then, things like dynamic languages and silver-bullet "everything-is-a-..." languages (and...PHP...) would gain less traction in the first place.)
Apr 12
parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 4/12/2019 9:38 PM, Nick Sabalausky (Abscissa) wrote:
 It's about the cognitive load.
As I pointed out upthread, isOdd() has a higher cognitive load.
Apr 12
parent reply "Nick Sabalausky (Abscissa)" <SeeWebsiteToContactMe semitwist.com> writes:
On 4/13/19 1:44 AM, Walter Bright wrote:
 On 4/12/2019 9:38 PM, Nick Sabalausky (Abscissa) wrote:
 It's about the cognitive load.
As I pointed out upthread, isOdd() has a higher cognitive load.
Not for normal programmers.
Apr 13
parent reply mate <aiueo aiueo.aiueo> writes:
On Saturday, 13 April 2019 at 07:47:03 UTC, Nick Sabalausky 
(Abscissa) wrote:
 On 4/13/19 1:44 AM, Walter Bright wrote:
 On 4/12/2019 9:38 PM, Nick Sabalausky (Abscissa) wrote:
 It's about the cognitive load.
As I pointed out upthread, isOdd() has a higher cognitive load.
Not for normal programmers.
If you don’t know the modulo operator you should probably not be programming, and should spend some time in learning the basics of the language first. You don’t drive a car before knowing where the blinkers are. I think it would be right to have functions such as `bool goLeft(int n) { return n % 2 == 0; }` or `bool isTail(int n) { return n % 2 == 0; }` since they abstract some decision logic in the application code. Whether or not you implement them with bitwise operators is not relevant. But `isOdd()` is just another way of expressing code that should be written directly with the language operators because it is trivial, short, and meaningless on its own.
Apr 13
parent reply "Nick Sabalausky (Abscissa)" <SeeWebsiteToContactMe semitwist.com> writes:
On 4/13/19 8:22 PM, mate wrote:
 On Saturday, 13 April 2019 at 07:47:03 UTC, Nick Sabalausky (Abscissa) 
 wrote:
 On 4/13/19 1:44 AM, Walter Bright wrote:
 On 4/12/2019 9:38 PM, Nick Sabalausky (Abscissa) wrote:
 It's about the cognitive load.
As I pointed out upthread, isOdd() has a higher cognitive load.
Not for normal programmers.
If you don’t know the modulo operator you should probably not be programming, and should spend some time in learning the basics of the language first. You don’t drive a car before knowing where the blinkers are.
How many flippin' times to I have point out the freaking difference between knowing something, vs having it so deeply internalized it ceases to be on a separate level of abstraction??? People! Quit using this stupid "...not knowing XYZ..." strawman!!
Apr 15
parent reply Julian <julian.fondren gmail.com> writes:
On Monday, 15 April 2019 at 23:02:34 UTC, Nick Sabalausky 
(Abscissa) wrote:
 How many flippin' times to I have point out the freaking 
 difference between knowing something, vs having it so deeply 
 internalized it ceases to be on a separate level of 
 abstraction???

 People! Quit using this stupid "...not knowing XYZ..." 
 strawman!!
This is a forum rather than interpersonal communication, so you can't have noticed that everyone rolls their eyes and dismisses you when you make this argument. Or rather, you just did notice that, but you attributed the dismissal to inattention. You get silence rather than refutation because it's hard to actually refute your claims. I can't point to any of my own language knowledge and give it a 1..10 rank of "internalization". I can't point to anything and say "aha, that's internalized its way to a different abstraction level". For me you may as well have argued that the problem with &1 is that it resembles a rune of confusion and that the reader of bitwise math accidentally casts a spell that makes it harder to read the surrounding expression. I don't believe that at all but I also don't want to get into magical runes with anyone making the claim. Although it's true that there can be a preferred description to code that isn't literally expressed in the code, ex. "x&1" as "test if x is odd" or "x++" as "advance to the next field" or "x++" as "count this additional connection" or "x++" as "include the zero byte in the length", I don't think "levels of internalization" has anything to do with this. It's just, to risk using an obvious synonym, simple familiarity. When you see "x++" you have a small set of ideas about what that can mean and foremost are those you've used yourself or see frequently. And I'd say the bar for &1 "internalizing its way to a different abstraction level" is to have used it deliberately (not as a copy&paste) even once in your code in any language even once in your life. On preferred descriptions, you might find this fun reading: https://mises.org/library/must-austrians-embrace-indifference
Apr 15
parent "Nick Sabalausky (Abscissa)" <SeeWebsiteToContactMe semitwist.com> writes:
On 4/15/19 10:40 PM, Julian wrote:
 On Monday, 15 April 2019 at 23:02:34 UTC, Nick Sabalausky (Abscissa) wrote:
 How many flippin' times to I have point out the freaking difference 
 between knowing something, vs having it so deeply internalized it 
 ceases to be on a separate level of abstraction???

 People! Quit using this stupid "...not knowing XYZ..." strawman!!
This is a forum rather than interpersonal communication, so you can't have noticed that everyone rolls their eyes and dismisses you when you make this argument. Or rather, you just did notice that, but you attributed the dismissal to inattention.
I've already clearly pointed out multiple times that I am NOT talking about the case where somebody "doesn't know" something. Therefore, counter-arguments based on "If somebody doesn't know..." have NO bearing whatsoever. No amount of your eye rolling, dismissing or flat out excuse-making is ever going to change that.
Apr 16
prev sibling next sibling parent reply "Nick Sabalausky (Abscissa)" <SeeWebsiteToContactMe semitwist.com> writes:
On 4/12/19 7:03 AM, Walter Bright wrote:
 On 4/11/2019 11:14 PM, Nick Sabalausky (Abscissa) wrote:
 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.
Knowing what (x & 1) is is a superpower?
No. Like I said, I know what it is too, so do tons of programmers. But there's a big difference between possessing that knowledge vs having it internalized at a glance so deeply that a mere glace mentally registers as "is this an odd/even number". The former is common, and such people have to do a mental translation step (even if they're not always aware they're doing it). The latter, where no mental translation is even needed, does occur, but it's not especially common, even among good programmers. Naturally I can't say this for sure, but based on your arguments, it sounds like you may very well be in the latter, uncommon category, meaning you would posses the genuine benefit of lacking a mental distinction between "& 1" and "evenness". In effect, it's mean you see straight through to the core truth (analogous to rain man's counting, hence the allusion to "superpowers"). If so, then that's fantastic, and I can certainly understand why you would balk at an isOdd/etc. It's just like how I would balk at anyone wrapping "x++" syntax with a "x.increment()" function. Like most with C-like experience, I look at "x++" and I instinctually "see" an increment, thus abstracting it would be pointless. But understand that such lack of mental distinction between "& 1" and "evenness" isn't common, even among good programmers with low-level experience. And that distinction is exactly what high-level languages are all about: Not mixing high-level intent from from mechanical implementation in order to cope with the human brain's difficulty at handling different levels of abstraction simultaneously. If for you, they're the same level of abstraction, that's great. For most, it isn't.
Apr 12
next sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 4/12/2019 9:15 PM, Nick Sabalausky (Abscissa) wrote:
 If for you, they're the same level of abstraction, that's great. For most, it 
 isn't.
If you want to write a library of such, and contribute it to Dub, feel free. If you find an audience for it, great.
Apr 12
parent reply Julian <julian.fondren gmail.com> writes:
On Saturday, 13 April 2019 at 04:40:08 UTC, Walter Bright wrote:
 On 4/12/2019 9:15 PM, Nick Sabalausky (Abscissa) wrote:
 If for you, they're the same level of abstraction, that's 
 great. For most, it isn't.
If you want to write a library of such, and contribute it to Dub, feel free. If you find an audience for it, great.
Done: https://code.dlang.org/packages/isodd It doesn't seem like there's a way to run library unit tests with dub? I'll add non-manpage documentation later. And a logo, of course.
Apr 13
next sibling parent reply Andre Pany <andre s-e-a-p.de> writes:
On Saturday, 13 April 2019 at 07:04:23 UTC, Julian wrote:
 On Saturday, 13 April 2019 at 04:40:08 UTC, Walter Bright wrote:
 On 4/12/2019 9:15 PM, Nick Sabalausky (Abscissa) wrote:
 If for you, they're the same level of abstraction, that's 
 great. For most, it isn't.
If you want to write a library of such, and contribute it to Dub, feel free. If you find an audience for it, great.
Done: https://code.dlang.org/packages/isodd It doesn't seem like there's a way to run library unit tests with dub? I'll add non-manpage documentation later. And a logo, of course.
You can have different dub configurations, 1 of type library and 1 of type executable for the unit tests. The first configuration in the array list is the default configuration. I have a very bad feeling about such small dub packages, because we are now on the same quality level like NodeJS ): Kind regards Andre
Apr 13
parent aliak <something something.com> writes:
On Saturday, 13 April 2019 at 07:58:27 UTC, Andre Pany wrote:
 On Saturday, 13 April 2019 at 07:04:23 UTC, Julian wrote:
 On Saturday, 13 April 2019 at 04:40:08 UTC, Walter Bright 
 wrote:
 On 4/12/2019 9:15 PM, Nick Sabalausky (Abscissa) wrote:
 If for you, they're the same level of abstraction, that's 
 great. For most, it isn't.
If you want to write a library of such, and contribute it to Dub, feel free. If you find an audience for it, great.
Done: https://code.dlang.org/packages/isodd It doesn't seem like there's a way to run library unit tests with dub? I'll add non-manpage documentation later. And a logo, of course.
You can have different dub configurations, 1 of type library and 1 of type executable for the unit tests. The first configuration in the array list is the default configuration. I have a very bad feeling about such small dub packages, because we are now on the same quality level like NodeJS ): Kind regards Andre
Amen. I guess most people have seen this but: https://www.theregister.co.uk/2016/03/23/npm_left_pad_chaos/ TL;DR - library with 11 lines of js code, pulled from npm, broke thousands of projects.
Apr 13
prev sibling next sibling parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 4/13/19 3:04 AM, Julian wrote:
 On Saturday, 13 April 2019 at 04:40:08 UTC, Walter Bright wrote:
 On 4/12/2019 9:15 PM, Nick Sabalausky (Abscissa) wrote:
 If for you, they're the same level of abstraction, that's great. For 
 most, it isn't.
If you want to write a library of such, and contribute it to Dub, feel free. If you find an audience for it, great.
Done: https://code.dlang.org/packages/isodd
That we got to this kind of time investment is worrisome. There's so many places where work needs to go, and this is at the very best of negligible impact. Ironically isOdd and isEven were not approved for Swift - see Implementation Notes. Instead, the only nontrivial function isMultiple was approved: bool isMultiple(T)(T isThisMultiple, T of) if (isIntegral!T) { if (isThisMultiple == 0) return true; if (of == 0) return false; static if (T.min < 0) if (isThisMultiple == T.min && of == -1) return true; return isThisMultiple % of == 0; } Such a function has some subtleties and corner cases that even seasoned programmers can get wrong. It can't be reasonably written as inlined code. I find its presence in a language's standard library reasonable. If isMultiple were proposed for Phobos, the argument should be centered on frequency of use. It does happen that such queries appear with a constant on the right (e.g. a power of two) but general queries for arbitrary integers are rare.
Apr 13
prev sibling next sibling parent Abdulhaq <alynch4047 gmail.com> writes:
On Saturday, 13 April 2019 at 07:04:23 UTC, Julian wrote:
 On Saturday, 13 April 2019 at 04:40:08 UTC, Walter Bright wrote:
 On 4/12/2019 9:15 PM, Nick Sabalausky (Abscissa) wrote:
 If for you, they're the same level of abstraction, that's 
 great. For most, it isn't.
If you want to write a library of such, and contribute it to Dub, feel free. If you find an audience for it, great.
Done: https://code.dlang.org/packages/isodd It doesn't seem like there's a way to run library unit tests with dub? I'll add non-manpage documentation later. And a logo, of course.
;-) I'm stuck trying to think of a good logo....
Apr 13
prev sibling parent reply Basile B. <b2.temp gmx.com> writes:
On Saturday, 13 April 2019 at 07:04:23 UTC, Julian wrote:
 On Saturday, 13 April 2019 at 04:40:08 UTC, Walter Bright wrote:
 On 4/12/2019 9:15 PM, Nick Sabalausky (Abscissa) wrote:
 If for you, they're the same level of abstraction, that's 
 great. For most, it isn't.
If you want to write a library of such, and contribute it to Dub, feel free. If you find an audience for it, great.
Done: https://code.dlang.org/packages/isodd It doesn't seem like there's a way to run library unit tests with dub? I'll add non-manpage documentation later. And a logo, of course.
Hi posted a review on IRC: [13:10] <B4S1L3> It's a joke but I already see several bad things [13:11] <B4S1L3> 1. parameter should be const to prevent superfluous template instantiation [13:11] <B4S1L3> 2. no module name [13:11] <B4S1L3> 3. pragma(inline, true) not there [13:12] <B4S1L3> 4. no test for BigInt [13:12] <B4S1L3> "X" needs works, see review comments ;) [13:13] <alphaglosined> expression isOdd(T:ulong)(T value) => value & 1; [13:13] <B4S1L3> 5. floating point is accepted ... [13:15] <B4S1L3> so you see, this isOdd function we joke about. The package is not good. It's not phobos-grade at least
Apr 13
parent reply Julian <julian.fondren gmail.com> writes:
On Saturday, 13 April 2019 at 12:13:36 UTC, Basile B. wrote:
 Hi posted a review on IRC:

 [13:10] <B4S1L3> It's a joke but I already see several bad 
 things
 [13:11] <B4S1L3> 1. parameter should be const to prevent 
 superfluous template instantiation
To be clear, the actual problem with that is that error messages aren't as clear, in some misuse like isOdd("not even a number") ? And that a misuse will *accidentally* work, if & is overloaded.
 [13:11] <B4S1L3> 2. no module name
It has one though: isodd, the name of the file. Making that explicit might make it more like phobos modules but it probably also needs different style braces, javadoc-style comments, etc.
 [13:11] <B4S1L3> 3. pragma(inline, true) not there
I hadn't heard about that. nogc safe and such should also be there I suppose.
 [13:12] <B4S1L3> 4. no test for BigInt
 [13:12] <B4S1L3> "X" needs works, see review comments ;)
 [13:13] <alphaglosined> expression isOdd(T:ulong)(T value) => 
 value & 1;
 [13:13] <B4S1L3> 5. floating point is accepted
 ...
 [13:15] <B4S1L3> so you see, this isOdd function we joke about. 
 The package is not good. It's not phobos-grade at least
Thanks. The real challenge will be to find a justification to bump the major version number :-)
Apr 13
parent Basile B. <b2.temp gmx.com> writes:
On Saturday, 13 April 2019 at 12:38:03 UTC, Julian wrote:
 On Saturday, 13 April 2019 at 12:13:36 UTC, Basile B. wrote:
 Hi posted a review on IRC:

 [13:10] <B4S1L3> It's a joke but I already see several bad 
 things
 [13:11] <B4S1L3> 1. parameter should be const to prevent 
 superfluous template instantiation
To be clear, the actual problem with that is that error messages aren't as clear, in some misuse like isOdd("not even a number") ? And that a misuse will *accidentally* work, if & is overloaded.
 [13:11] <B4S1L3> 2. no module name
It has one though: isodd, the name of the file. Making that explicit might make it more like phobos modules but it probably also needs different style braces, javadoc-style comments, etc.
 [13:11] <B4S1L3> 3. pragma(inline, true) not there
I hadn't heard about that. nogc safe and such should also be there I suppose.
 [13:12] <B4S1L3> 4. no test for BigInt
 [13:12] <B4S1L3> "X" needs works, see review comments ;)
 [13:13] <alphaglosined> expression isOdd(T:ulong)(T value) => 
 value & 1;
 [13:13] <B4S1L3> 5. floating point is accepted
 ...
 [13:15] <B4S1L3> so you see, this isOdd function we joke 
 about. The package is not good. It's not phobos-grade at least
Thanks. The real challenge will be to find a justification to bump the major version number :-)
`pragma(inline, true)` is not infered but the function attributes are. So... you should anotate your unittests with safe pure nothrow nogc and put the pragma for the tempalted funcs. Anyway, I understand the joke, it's just like I think that the joke is not well executed ;)
Apr 13
prev sibling parent reply "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Sat, Apr 13, 2019 at 12:15:02AM -0400, Nick Sabalausky (Abscissa) via
Digitalmars-d wrote:
 On 4/12/19 7:03 AM, Walter Bright wrote:
[...]
 Knowing what (x & 1) is is a superpower?
[...]
 Naturally I can't say this for sure, but based on your arguments, it
 sounds like you may very well be in the latter, uncommon category,
 meaning you would posses the genuine benefit of lacking a mental
 distinction between "& 1" and "evenness". In effect, it's mean you see
 straight through to the core truth (analogous to rain man's counting,
 hence the allusion to "superpowers").  If so, then that's fantastic,
 and I can certainly understand why you would balk at an isOdd/etc.
 It's just like how I would balk at anyone wrapping "x++" syntax with a
 "x.increment()" function. Like most with C-like experience, I look at
 "x++" and I instinctually "see" an increment, thus abstracting it
 would be pointless.
Personally, even though I understand perfectly well what (x & 1) means, I much rather write it as (x % 2) instead and let the optimizer implement it as (x & 1), because that conveys intent better. I consider using (x & 1) for testing evenness/oddness akin to writing gotos in place of loops. It's semantically equivalent, but IMO at the wrong level of abstraction.
 But understand that such lack of mental distinction between "& 1" and
 "evenness" isn't common, even among good programmers with low-level
 experience. And that distinction is exactly what high-level languages
 are all about: Not mixing high-level intent from from mechanical
 implementation in order to cope with the human brain's difficulty at
 handling different levels of abstraction simultaneously.
[...] I don't find it difficult to parse (x & 1) as testing for odd/even, but I do find it distasteful the same way most people would find writing gotos instead of loops or if-statements distasteful. `&` is a bitwise operator, and as such has different connotations from (x % 2), which is more obviously equivalent to the mathematical concept of odd/even. The machine doesn't care about the difference -- and in the old days, & was preferred because it produced better machine code, though nowadays any non-joke compiler would optimize away the difference -- but writing code isn't merely just telling the machine what to do, it's also documenting to the next human reader what you intended the machine to do. For the latter purpose, writing (x % 2) conveys intent much better than (x & 1). OTOH, writing an entire function to abstract away even/oddness is going a bit too far. That'd be like writing a function ifThen(condition, trueBranch, falseBranch) that abstracts away if-statements -- it's redundant and needless complexity for something already expressible with built-in constructs. Such would be justifiable only if you're doing something like runtime metaprogramming or writing an interpreter where you need to parcel away built-in constructs into runtime-manipulable objects. T -- Question authority. Don't ask why, just do it.
Apr 12
next sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
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. Try this with your favorite C compiler: int foo(int x) { return x % 2; } int bar(int x) { return x & 1; }
Apr 12
next sibling parent reply "Nick Sabalausky (Abscissa)" <SeeWebsiteToContactMe semitwist.com> writes:
On 4/13/19 1:37 AM, 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. Try this with your favorite C compiler: int foo(int x) {     return x % 2; } int bar(int x) {     return x & 1; }
Sounds like compiler room-for-improvement.
Apr 13
next sibling parent reply Julian <julian.fondren gmail.com> writes:
On Saturday, 13 April 2019 at 07:49:13 UTC, Nick Sabalausky 
(Abscissa) wrote:
 On 4/13/19 1:37 AM, 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. Try this with your favorite C compiler: int foo(int x) {     return x % 2; } int bar(int x) {     return x & 1; }
Sounds like compiler room-for-improvement.
Contrast https://godbolt.org/z/aN8rRV
Apr 13
next sibling parent Julian <julian.fondren gmail.com> writes:
On Saturday, 13 April 2019 at 07:57:32 UTC, Julian wrote:
 On Saturday, 13 April 2019 at 07:49:13 UTC, Nick Sabalausky 
 (Abscissa) wrote:
 On 4/13/19 1:37 AM, 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. Try this with your favorite C compiler: int foo(int x) {     return x % 2; } int bar(int x) {     return x & 1; }
Sounds like compiler room-for-improvement.
Contrast https://godbolt.org/z/aN8rRV
er, these actually have the same unoptimized and -O3 output: int foo(int num) { return 0 == num % 2; } int bar(int num) { return 0 == (num & 1); } https://godbolt.org/z/oqP0Mn
Apr 13
prev sibling parent Julian <julian.fondren gmail.com> writes:
On Saturday, 13 April 2019 at 07:57:32 UTC, Julian wrote:
 Contrast [snip]
er, these actually have the same unoptimized and -O3 output: int foo(int num) { return 0 == num % 2; } int bar(int num) { return 0 == (num & 1); } links removed to see if this'll post.
Apr 13
prev sibling parent Patrick Schluter <Patrick.Schluter bbox.fr> writes:
On Saturday, 13 April 2019 at 07:49:13 UTC, Nick Sabalausky 
(Abscissa) wrote:
 On 4/13/19 1:37 AM, 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. Try this with your favorite C compiler: int foo(int x) {     return x % 2; } int bar(int x) {     return x & 1; }
Sounds like compiler room-for-improvement.
No. The code is different since C99 requires that modulo of negative dividends return a negative result. foo(-1) = -1 bar(-1) = 1
Apr 13
prev sibling parent reply Abdulhaq <alynch4047 gmail.com> writes:
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 if just perhaps, it's better to stick to the mathematically precise and clear rendering of the desired algorithm.
Apr 13
next sibling parent reply "Nick Sabalausky (Abscissa)" <SeeWebsiteToContactMe semitwist.com> writes:
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.
Apr 16
next sibling parent Walter Bright <newshound2 digitalmars.com> writes:
On 4/16/2019 11:11 PM, Nick Sabalausky (Abscissa) wrote:
 2. Apple's inclusion of isOdd/etc
Actually, Apple rejected it: "Only isMultiple(of:) was approved during review, so the final implementation does not include isEven or isOdd." https://github.com/apple/swift-evolution/blob/master/proposals/0225-binaryinteger-iseven-isodd-ismultiple.md
Apr 17
prev sibling parent aliak <something something.com> writes:
On Wednesday, 17 April 2019 at 06:11:56 UTC, Nick Sabalausky 
(Abscissa) wrote:
 On 4/13/19 4:38 AM, Abdulhaq wrote:
 [...]
Actually, this right here is *EXTREMELY* good reason in favor if isOdd/etc (again, not that my intent is to get it into Phobos). [...]
Just to note that isOdd/isEven was not actually accepted in swift 5. isMultiple(of:) was deemed worthy enough to cover all usecases. The initial post unfortunately maaaayyyy have made it seem like all were accepted because of the name of the file, which Andrei pointed out later :o) See the notes form the review manager and swift core team: https://forums.swift.org/t/accepted-with-modifications-se-0225-adding-ismultiple-to-binaryinteger/15689 Cheers, - Ali
Apr 17
prev sibling parent "Nick Sabalausky (Abscissa)" <SeeWebsiteToContactMe semitwist.com> writes:
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.
That may be so, but it *does* very clearly demonstrate the value of specifying intent rather than implementation. As with any abstraction, the separation here of intent vs implementation frees the code/programmer who needs to check parity from needing concern themselves with which implementation is optimal. This is the whole point of HLL-abstractions. That is demonstrably relevant in this case *because* the two possible implementations produce different code. Again, this is basic HLL Programming Abstractions 101.
Apr 17
prev sibling parent Timon Gehr <timon.gehr gmx.ch> writes:
On 13.04.19 07:18, H. S. Teoh wrote:
 Personally, even though I understand perfectly well what (x & 1) means,
 I much rather write it as (x % 2) instead and let the optimizer
 implement it as (x & 1)
(x % 2) and (x & 1) are not equivalent in all contexts. The modulo operator is insane, and there isn't really a good way to fix it because the hardware is doing it wrong.
Apr 13
prev sibling parent "Nick Sabalausky (Abscissa)" <SeeWebsiteToContactMe semitwist.com> writes:
On 4/12/19 7:03 AM, Walter Bright wrote:
 
 If you want isOdd() for your own personal library, feel free. Putting it 
 into Phobos, however, is not happening.
To be clear, I'm not pushing for that. Granted, I'd have zero objection if it did get in, and I'd even applaud it as a nice benefit for "D as a first language" and for other less-than-expert devs. But I'm certainly not pushing for it. I just disagree on a philosophical level with your objection to it. That's all.
Apr 12
prev sibling parent Nicholas Wilson <iamthewilsonator hotmail.com> writes:
On Friday, 12 April 2019 at 06:14:05 UTC, Nick Sabalausky 
(Abscissa) wrote:
 Parson me here, but: Bullshit.
 [snip]
Well said.
Apr 12
prev sibling parent reply Terry Arkson <email example.org> writes:
On Friday, 12 April 2019 at 02:29:38 UTC, Walter Bright wrote:
 On 4/11/2019 4:24 PM, Mike Franklin wrote:
 On Thursday, 11 April 2019 at 23:03:00 UTC, Walter Bright 
 wrote:
 
   bool isOdd(int i) { return i & 1; }

 Filling the standard library with trivia is not a good idea. 
 Not knowing about a common operator is not a reason to add 
 library functions.
For me it's not about knowledge of the operator.
That was the reason given for it.
 It's about conveying the reason for why that operation is 
 being done.  For example, if you do `i & 1` are you checking 
 for even or odd, or are you masking off irrelevant bits.
If you're masking bits, you should call it: return i & MyBitFlag;
 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".
Sorry to bump an old (hijacked) thread, but I have just discovered something hilarious that absolutely needs to go here: The same author of the is-odd npm package also has a package called 'is-even'. Now that, I'm sure we can all agree, is bullshit.
Apr 25
parent reply "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Thu, Apr 25, 2019 at 10:49:47PM +0000, Terry Arkson via Digitalmars-d wrote:
 On Friday, 12 April 2019 at 02:29:38 UTC, Walter Bright wrote:
 On 4/11/2019 4:24 PM, Mike Franklin 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.
[...]
 I call this sort of stuff the "Illusion of Progress".
Sorry to bump an old (hijacked) thread, but I have just discovered something hilarious that absolutely needs to go here: The same author of the is-odd npm package also has a package called 'is-even'. Now that, I'm sure we can all agree, is bullshit.
What would be actually useful is a package called is-prime. Unfortunately, its usefulness would be obscured by the proliferation of packages like is-even, is-odd, and others of their ilk. Just like comments that repeat what the code already says, thereby obscuring the actual intent of the code while giving an illusion of being well-documented. /* Look, Ma! I'm so well-documented! */ // loop from 0 to len for (i = 0; // set i to zero i < len; // check that i is less than len i++) // increment i { if (i & 2) { // if bit 0 is non-zero writeln("How odd!"); } else { // otherwise writeln("But even so..."); } } Blecch. T -- "I'm running Windows '98." "Yes." "My computer isn't working now." "Yes, you already said that." -- User-Friendly
Apr 25
next sibling parent aberba <karabutaworld gmail.com> writes:
On Thursday, 25 April 2019 at 23:40:31 UTC, H. S. Teoh wrote:
 On Thu, Apr 25, 2019 at 10:49:47PM +0000, Terry Arkson via 
 Digitalmars-d wrote:
 On Friday, 12 April 2019 at 02:29:38 UTC, Walter Bright wrote:
 On 4/11/2019 4:24 PM, Mike Franklin wrote:
[...]
 Creating functions like `isOdd` or 
 `GetLeastSignificantBit` help convey intent without having 
 to supplement code with comments.
Probably one reason D is not gaining much adoption (at least for beginners) is because the maintainers are so smart that they ignore some basic (or less cognitive load) details. Like functions that might appeal to beginners...but Andre and Walter overlook them...thinking its so obvious (in their experience). If true, they'll have problem teaching beginners programming. Another example is Ali's book, may seem normal to someone with some programming experience but definitely not a beginner's book...I have personally seen that with some folks.
Apr 25
prev sibling parent =?UTF-8?B?SsO8cmdlbg==?= Reichmann <jr rdvsb.de> writes:
LOL

On Thursday, 25 April 2019 at 23:40:31 UTC, H. S. Teoh wrote:
 ...
   Just like comments that repeat what the code already says, 
 thereby obscuring the actual intent of the code while giving an 
 illusion of being well-documented.
 ...
 		if (i & 2) {	// if bit 0 is non-zero
... Q.E.D. JR
Apr 27
prev sibling parent reply Timon Gehr <timon.gehr gmx.ch> writes:
On 12.04.19 01:03, Walter Bright wrote:
 On 4/11/2019 2:21 PM, Dennis wrote:
 I don't get it. What's shocking about it, that people often need to 
 know the parity of a number or that people aren't born with the 
 knowledge that the % operator can be used for that?
  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.
 Not knowing about a common operator is not a reason to add library functions.
No, but there can be other reasons.
Apr 11
parent reply Walter Bright <newshound2 digitalmars.com> writes:
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".
 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.
Apr 11
next sibling parent reply aliak <something something.com> writes:
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.
Apr 11
next sibling parent reply Patrick Schluter <Patrick.Schluter bbox.fr> writes:
On Friday, 12 April 2019 at 06:52:39 UTC, aliak wrote:
 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".
funny you mention abs(). My current job was enabled because the project leader was impressed with my optimisation skill. The first change I made in the code base (in the Levenshtein routine) was to replace the call to abs() by a macro doing nothing more fancy than "n>0?n:-n". The gain in performance was so massive, it completely floored me at that time. People underestimate the cost of a call, especially into a dynamic library (it is an indirect jump via the GOT), if it is in the hot loop it can be a massive cycle waster.
 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.
Apr 12
parent jmh530 <john.michael.hall gmail.com> writes:
On Friday, 12 April 2019 at 10:52:00 UTC, Patrick Schluter wrote:
 [snip]

 funny you mention abs(). My current job was enabled because the 
 project leader was impressed with my optimisation skill. The 
 first change I made in the code base (in the Levenshtein 
 routine) was to replace the call to abs() by a macro doing 
 nothing more fancy than "n>0?n:-n". The gain in performance was 
 so massive, it completely floored me at that time. People 
 underestimate the cost of a call, especially into a dynamic 
 library (it is an indirect jump via the GOT), if it is in the 
 hot loop it can be a massive cycle waster.
Was this C code (based on the reference to macros)? Could you get the same performance boost by pulling abs out into a static library?
Apr 12
prev sibling next sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 4/11/2019 11:52 PM, aliak wrote:
 isOdd would've made the call site a lot more clear.
Feel free to add such a function to your code.
 Using n & 1 has always been a hack for oddness. It says nothing about what
your 
 code is doing.
isOdd() doesn't say what your code is doing, either.
 The average programmer would look at it and have to think about 
 what's happening there.
I'm happy to elevate them to the next level with such thoughts :-)
 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.
(x & 1) isn't any harder to read than (x + 1). More bluntly, it'll be hard for someone to succeed with D if they have only a vague understanding of what 2's complement arithmetic is, and a conceptual problem with the & operator. isOdd() isn't going to fix that for them.
Apr 12
parent aliak <something something.com> writes:
On Friday, 12 April 2019 at 11:12:55 UTC, Walter Bright wrote:
 On 4/11/2019 11:52 PM, aliak wrote:
 isOdd would've made the call site a lot more clear.
Feel free to add such a function to your code.
 Using n & 1 has always been a hack for oddness. It says 
 nothing about what your code is doing.
isOdd() doesn't say what your code is doing, either.
 The average programmer would look at it and have to think 
 about what's happening there.
I'm happy to elevate them to the next level with such thoughts :-)
🖖:)
 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.
(x & 1) isn't any harder to read than (x + 1).
Maybe, dunno. I can see that x + 1 means "i add one to x", and that x & 1 means "I'm masking out the bit pattern of 1 from x". For the former, you can derive that "oh, that means the next index" (i.e. if(x.nextIndex) and for the latter, you can derive that "oh only odd numbers will have a value of one" (i.e. x.isodd). But the derivations are more secondary thoughts implied by the initial operation. So I can see the difference as well. Granted they're certainly not harder to read, but I do think they are not exactly the same.
 More bluntly, it'll be hard for someone to succeed with D if 
 they have only a vague understanding of what 2's complement 
 arithmetic is, and a conceptual problem with the & operator. 
 isOdd() isn't going to fix that for them.
Can't argue with that :)
Apr 13
prev sibling parent Walter Bright <newshound2 digitalmars.com> writes:
On 4/11/2019 11:52 PM, aliak wrote:
 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".
abs() is different. Note that `n` appears multiple times in your examples, which matters if the expression `n` contains side effects. This side effect problem is a common one C programmers encounter when they use an abs() macro. Avoiding the side effect without using the function can be awkward, thus justifying the function.
Apr 12
prev sibling parent reply Timon Gehr <timon.gehr gmx.ch> writes:
On 12.04.19 04:13, 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". ...
Parity is an important property of integers. Not all integer data types support efficient bitwise arithmetic.
 
 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.
std/range/primitives.d --- property ref T front(T)(T[] a) safe pure nothrow nogc if (!isNarrowString!(T[]) && !is(T[] == void[])) { assert(a.length, "Attempting to fetch the front of an empty array of " ~ T.stringof); return a[0]; } -- "Who's the clown who's put that there? Don't D programmers know about the array index operator?!"
Apr 12
parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 4/12/2019 6:31 AM, Timon Gehr wrote:
 "Who's the clown who's put that there? Don't D programmers know about the
array 
 index operator?!"
front() is there for arrays as an adapter so one can use range operations on it.
Apr 12
parent reply Timon Gehr <timon.gehr gmx.ch> writes:
On 12.04.19 21:41, Walter Bright wrote:
 On 4/12/2019 6:31 AM, Timon Gehr wrote:
 "Who's the clown who's put that there? Don't D programmers know about 
 the array index operator?!"
front() is there for arrays as an adapter so one can use range operations on it.
My point exactly. x & 1 is not the best implementation of isOdd for all integer-representing types of x, and you may want to determine if an integer is odd in generic code. The reason why isOdd is not in Phobos is that Phobos has poor support for discrete mathematics in general, not necessarily that isOdd is too easy to implement for built-in integral types, and I hope my example demonstrates that. There are of course other reasons why you would want to add functions with a simple implementations, I already mentioned standardization of function names, also, e.g. filter!isOdd is both faster to read and easier to type than filter!(x=>x&1). Furthermore, it's just not nice when you are solving a problem and notice that a lot of functions you need to naturally express it are missing from the standard library and you need to add them to your own utility library first, presumably being too lazy to add the correct template constraints.
Apr 13
next sibling parent reply mate <aiueo aiueo.aiueo> writes:
On Sunday, 14 April 2019 at 00:27:18 UTC, Timon Gehr wrote:
 There are of course other reasons why you would want to add 
 functions with a simple implementations, I already mentioned 
 standardization of function names, also, e.g. filter!isOdd is 
 both faster to read and easier to type than filter!(x=>x&1).
Would not you check the function definition if you saw `isOdd()` in the code?
 Furthermore, it's just not nice when you are solving a problem 
 and notice that a lot of functions you need to naturally 
 express it are missing from the standard library and you need 
 to add them to your own utility library first, presumably being 
 too lazy to add the correct template constraints.
Maybe your math utils library(ies) would be popular on dub. Even if some template constraints are missing, they would probably get fixed over time by some willing contributing users.
Apr 13
parent reply Timon Gehr <timon.gehr gmx.ch> writes:
On 14.04.19 02:42, mate wrote:
 On Sunday, 14 April 2019 at 00:27:18 UTC, Timon Gehr wrote:
 There are of course other reasons why you would want to add functions 
 with a simple implementations, I already mentioned standardization of 
 function names, also, e.g. filter!isOdd is both faster to read and 
 easier to type than filter!(x=>x&1).
Would not you check the function definition if you saw `isOdd()` in the code? ...
Probably not. What would be the trigger for that?
 Furthermore, it's just not nice when you are solving a problem and 
 notice that a lot of functions you need to naturally express it are 
 missing from the standard library and you need to add them to your own 
 utility library first, presumably being too lazy to add the correct 
 template constraints.
Maybe your math utils library(ies) would be popular on dub. Even if some template constraints are missing, they would probably get fixed over time by some willing contributing users.
Maybe. However, often, the quickest way to make the thing I was working on work with sufficient code quality is not actually to implement the missing standard library functions, even though it would have been easier with those functions there. (E.g., compute the thing with a a few for loops instead of with a more elegant and readable range-based solution.) I'll consider writing some libraries in the future, but right now I don't really get enough of my productive time to work on projects I already started, such as getting better tuple support, and I'd really prefer obvious omissions to be in the standard library. I see that scan has finally been added, but I'm a bit disappointed it was called cumulativeFold. Here, I was mainly objecting to the general idea that functions that are simple to implement in terms of a few other functions/built-in operators have no business being in the standard library. (This has come up before.) It's not even consistently applied in Phobos. E.g., there is max and min even though they are trivially implemented in terms of each other by switching around the comparison predicate, but it would clearly be ridiculous to require this by arbitrarily picking one over the other. On the other hand, we have until, but not takeWhile, even though it is more common to want to specify the kinds of elements that you like instead of a condition on the first one that you don't want.
Apr 13
next sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 4/13/2019 7:20 PM, Timon Gehr wrote:
 It's not even consistently applied in Phobos.
That's a general problem with anything that's been worked on for 20 years by successive waves of different people with different ideas. Phobos has accumulated a lot of technical debt. BTW, did you know that Phobos used to contain secant() and cosecant() functions? I removed them :-)
Apr 14
parent reply Timon Gehr <timon.gehr gmx.ch> writes:
On 14.04.19 10:27, Walter Bright wrote:
 On 4/13/2019 7:20 PM, Timon Gehr wrote:
 It's not even consistently applied in Phobos.
That's a general problem with anything that's been worked on for 20 years by successive waves of different people with different ideas. Phobos has accumulated a lot of technical debt. ...
The right answer here really isn't to remove the `max` function.
 BTW, did you know that Phobos used to contain secant() and cosecant() 
 functions? I removed them :-)
That seems like a bad idea even assuming your criteria. `sec(x)` rounds once (if implemented correctly) while `1/cos(x)` rounds twice. Phobos also contains `sin` and `cos` functions. Please don't remove either of them.
Apr 14
parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 4/14/2019 5:13 AM, Timon Gehr wrote:
 BTW, did you know that Phobos used to contain secant() and cosecant() 
 functions? I removed them :-)
That seems like a bad idea even assuming your criteria. `sec(x)` rounds once (if implemented correctly) while `1/cos(x)` rounds twice.
Of course, they were implemented simply as reciprocals.
 Phobos also contains `sin` and `cos` functions. Please don't remove either of
them.
Not likely. Those functions are rather difficult to implement correctly, and so are perfect candidates for library functions. Even as recently as just 5 years ago, some C compilers got them wrong. (The D phobos test suite would fail on them.) Phobos was pretty much forced to provide its own implementations of many math functions because of erratic behavior of many C compiler library versions. It turns out that being good at writing compilers has no relevance to competence at the intricacies of implementing math functions :-)
Apr 15
parent reply Timon Gehr <timon.gehr gmx.ch> writes:
On 15.04.19 09:44, Walter Bright wrote:
 On 4/14/2019 5:13 AM, Timon Gehr wrote:
 BTW, did you know that Phobos used to contain secant() and cosecant() 
 functions? I removed them :-)
That seems like a bad idea even assuming your criteria. `sec(x)` rounds once (if implemented correctly) while `1/cos(x)` rounds twice.
Of course, they were implemented simply as reciprocals. ...
Then they were incorrect and removing them was reasonable. But of course, in this case this anecdote has no bearing on the current discussion: you removed them (instead of fixing them), because they were too hard to implement, not because they were too easy to implement. :)
Apr 15
parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 4/15/2019 5:54 AM, Timon Gehr wrote:
 Then they were incorrect and removing them was reasonable. But of course, in 
 this case this anecdote has no bearing on the current discussion: you removed 
 them (instead of fixing them), because they were too hard to implement, not 
 because they were too easy to implement. :)
I removed them because they were implemented as trivia, and hence offered no value. (Yes, that is not just a reformulation of the reason you gave.) If they were implemented in such a way as to offer value that 1/sin did not, then I would have considered retaining them.
Apr 15
parent "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Mon, Apr 15, 2019 at 01:15:07PM -0700, Walter Bright via Digitalmars-d wrote:
 On 4/15/2019 5:54 AM, Timon Gehr wrote:
 Then they were incorrect and removing them was reasonable. But of
 course, in this case this anecdote has no bearing on the current
 discussion: you removed them (instead of fixing them), because they
 were too hard to implement, not because they were too easy to
 implement. :)
I removed them because they were implemented as trivia, and hence offered no value. (Yes, that is not just a reformulation of the reason you gave.) If they were implemented in such a way as to offer value that 1/sin did not, then I would have considered retaining them.
Didn't he just say that 1/sin gives different rounding behaviour from a correct, direct implementation of csc? T -- Don't throw out the baby with the bathwater. Use your hands...
Apr 15
prev sibling parent mate <aiueo aiueo.aiueo> writes:
On Sunday, 14 April 2019 at 02:20:22 UTC, Timon Gehr wrote:
 On 14.04.19 02:42, mate wrote:
 [...]
Probably not. What would be the trigger for that?
I would think that having an isOdd() is… odd. It seems so trivial and short that I would suspect something different.
 [...]
Maybe. However, often, the quickest way to make the thing I was working on work with sufficient code quality is not actually to implement the missing standard library functions, even though it would have been easier with those functions there. (E.g., compute the thing with a a few for loops instead of with a more elegant and readable range-based solution.) I'll consider writing some libraries in the future, but right now I don't really get enough of my productive time to work on projects I already started, such as getting better tuple support, and I'd really prefer obvious omissions to be in the standard library. I see that scan has finally been added, but I'm a bit disappointed it was called cumulativeFold.
I understand. I did not mean to suggest you to start a new project. I am already grateful for the contributions you made to dlang, thank you.
 Here, I was mainly objecting to the general idea that functions 
 that are simple to implement in terms of a few other 
 functions/built-in operators have no business being in the 
 standard library. (This has come up before.) It's not even 
 consistently applied in Phobos. E.g., there is max and min even 
 though they are trivially implemented in terms of each other by 
 switching around the comparison predicate, but it would clearly 
 be ridiculous to require this by arbitrarily picking one over 
 the other. On the other hand, we have until, but not takeWhile, 
 even though it is more common to want to specify the kinds of 
 elements that you like instead of a condition on the first one 
 that you don't want.
I see. I was not arguing for the minimum set by removing reciprocal functions though. What would be your criteria for inclusion?
Apr 16
prev sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 4/13/2019 5:27 PM, Timon Gehr wrote:
 My point exactly. x & 1 is not the best implementation of isOdd for all 
 integer-representing types of x,
It is for all the basic integral types in D, and I would expect anyone implementing their own integral type to make x&1 work. I.e. when you make your own integral type, the onus is on you to make the integer operators do the expected thing with it. D's template constraints should be good enough to recognize x&1 and make it efficient for the user defined type implementation. isOdd() would be problematic for floating point types, which is a reason to avoid doing it for them, so people don't get surprised. (What is isOdd(infinity) supposed to do? true? false? throw exception? abort? launch nuclear missiles?)
Apr 14
next sibling parent reply Timon Gehr <timon.gehr gmx.ch> writes:
On 14.04.19 10:37, Walter Bright wrote:
 On 4/13/2019 5:27 PM, Timon Gehr wrote:
 My point exactly. x & 1 is not the best implementation of isOdd for 
 all integer-representing types of x,
It is for all the basic integral types in D, and I would expect anyone implementing their own integral type to make x&1 work. ...
What if it is stored as a series of primes and exponents in the number's prime factorization?
 I.e. when you make your own integral type, the onus is on you to make 
 the integer operators do the expected thing with it. D's template 
 constraints should be good enough to recognize x&1 and make it efficient 
 for the user defined type implementation.
 ...
But this is not the case now. It is not possible to require specific values as function arguments in template constraints. And it would be awfully strange. `x&1` is an implementation detail that works well for built-in integer types, `isOdd` is the abstract meaning. What you are proposing to do is to take the implementation and elevate it to the abstract level. It's a bit like making the only way to call the library `sort` routine to manually implement some sorting algorithm which is then magically replaced by a library call. Or if we stick with the same example, you would seem to be arguing in favor of removing `r.front`, `r.popFront` and `r.empty` and forcing every range type to support `r[0]`, `r=r[1..$]` and `r.length==0` instead, even those that don't support indexing nor slicing, nor have a way to compute length in constant time. Note that the issue isn't that I am not able to understand or write the implementation without thinking about it. I also immediately see that `x&&!(x&x-1)` checks whether x stores a power of two, or that x&-x extracts the least significant bit that's set to one.
 isOdd() would be problematic for floating point types, which is a reason 
 to avoid doing it for them, so people don't get surprised. (What is 
 isOdd(infinity) supposed to do? true? false? throw exception? abort? 
 launch nuclear missiles?)
Probably floating-point types shouldn't have an `isOdd` function, because they are not integer-representing types and rounding can cause `isOdd` to switch from true to false in a way that goes against the way addition of odd/even integers is supposed to work. However, if we check Wikipedia, it is clear what the function should do, if it would be implemented: https://simple.wikipedia.org/wiki/Odd_number (simple Wikipedia because in main wikipedia, "odd number" redirects to "parity".) --- An odd number is an integer which is not a multiple of two; --- It should return `false` for every input that is not an integer.
Apr 14
parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 4/14/2019 5:58 AM, Timon Gehr wrote:
 It is not possible to require specific values as 
 function arguments in template constraints.
I believe it is if you use the "template expression" technique popularized in C++. Even if not, or if you understandably don't care for expression templates (I don't, either), you can overload based on the right operand being an int, and then special case it with a runtime test for '1'. That test won't add significantly to the runtime if you've represented the integer as a series of primes and exponents.
 It should return `false` for every input that is not an integer.
Of course, the compiler will give an error for (f & 1), so the user will have an opportunity to decide what to do about it and if his algorithm makes any sense with odd floating point values, which it likely wouldn't. He then can write his own isOdd() function as necessary. We don't need to do it for him, and are not likely providing a useful service even if we did.
Apr 15
parent Timon Gehr <timon.gehr gmx.ch> writes:
On 15.04.19 09:36, Walter Bright wrote:
 On 4/14/2019 5:58 AM, Timon Gehr wrote:
 It is not possible to require specific values as function arguments in 
 template constraints.
I believe it is if you use the "template expression" technique popularized in C++. Even if not,
It's not possible.
 or if you understandably don't care for 
 expression templates (I don't, either), you can overload based on the 
 right operand being an int, and then special case it with a runtime test 
 for '1'.
 
 That test won't add significantly to the runtime if you've represented 
 the integer as a series of primes and exponents.
 ..
It would be ridiculous though. What do you suggest happens if the runtime check fails?
  > It should return `false` for every input that is not an integer.
 
 Of course, the compiler will give an error for (f & 1), so the user will 
 have an opportunity to decide what to do about it and if his algorithm 
 makes any sense with odd floating point values, which it likely 
 wouldn't. He then can write his own isOdd() function as necessary. We 
 don't need to do it for him, and are not likely providing a useful 
 service even if we did.
That's basically what I wrote earlier in the same post. I then proceeded to answer your question anyway, showing that the behaviour of isOdd(infinity) is actually clear. isOdd(infinity), if it compiles at all, should return false. (There may be some miscommunication going on. I believe this has happened a few times in the past as well. Sometimes, I explicitly agree with your conclusion, but I don't agree with your argumentation. You then seem to wrongly assume that I disagree with the conclusion, from which you conclude that I am wrong and my arguments do not matter.)
Apr 15
prev sibling parent reply lithium iodate <whatdoiknow doesntexist.net> writes:
On Sunday, 14 April 2019 at 08:37:26 UTC, Walter Bright wrote:
 On 4/13/2019 5:27 PM, Timon Gehr wrote:
 My point exactly. x & 1 is not the best implementation of 
 isOdd for all integer-representing types of x,
It is for all the basic integral types in D, and I would expect anyone implementing their own integral type to make x&1 work.
I personally would expect bitwise operations to operate on the underlying bit pattern instead of its two's-complement equivalent representation.
Apr 14
parent reply Adam D. Ruppe <destructionator gmail.com> writes:
On Sunday, 14 April 2019 at 13:19:22 UTC, lithium iodate wrote:
 I personally would expect bitwise operations to operate on the 
 underlying bit pattern instead of its two's-complement 
 equivalent representation.
Aren't those the same thing?
Apr 14
parent reply lithium iodate <whatdoiknow doesntexist.net> writes:
On Sunday, 14 April 2019 at 13:23:27 UTC, Adam D. Ruppe wrote:
 On Sunday, 14 April 2019 at 13:19:22 UTC, lithium iodate wrote:
 I personally would expect bitwise operations to operate on the 
 underlying bit pattern instead of its two's-complement 
 equivalent representation.
Aren't those the same thing?
For the inbuilt integral types? Sure. For custom integral types? Not necessarily. When dealing with protocols and compression you might get into the situation of defining an integer with some special coding as internal representation.
Apr 14
parent reply Julian <julian.fondren gmail.com> writes:
On Sunday, 14 April 2019 at 13:28:13 UTC, lithium iodate wrote:
 On Sunday, 14 April 2019 at 13:23:27 UTC, Adam D. Ruppe wrote:
 On Sunday, 14 April 2019 at 13:19:22 UTC, lithium iodate wrote:
 I personally would expect bitwise operations to operate on 
 the underlying bit pattern instead of its two's-complement 
 equivalent representation.
Aren't those the same thing?
For the inbuilt integral types? Sure. For custom integral types? Not necessarily. When dealing with protocols and compression you might get into the situation of defining an integer with some special coding as internal representation.
How would adding isOdd to phobos change this?
Apr 14
parent lithium iodate <whatdoiknow doesntexist.net> writes:
On Sunday, 14 April 2019 at 15:01:22 UTC, Julian wrote:
 On Sunday, 14 April 2019 at 13:28:13 UTC, lithium iodate wrote:
 On Sunday, 14 April 2019 at 13:23:27 UTC, Adam D. Ruppe wrote:
 On Sunday, 14 April 2019 at 13:19:22 UTC, lithium iodate 
 wrote:
 I personally would expect bitwise operations to operate on 
 the underlying bit pattern instead of its two's-complement 
 equivalent representation.
Aren't those the same thing?
For the inbuilt integral types? Sure. For custom integral types? Not necessarily. When dealing with protocols and compression you might get into the situation of defining an integer with some special coding as internal representation.
How would adding isOdd to phobos change this?
By selecting suitable treatment for the given type: inbuilt integer -> &1 (or whatever) does it provide a isOdd function? -> call isOdd of that type perhaps it somehow declared that oddity can't be determined -> fail fast and loud else try %2 != 0 else fail fast and loud none of which include making possibly incorrect assumptions about its representation.
Apr 14
prev sibling parent reply Alex <AJ gmail.com> writes:
On Thursday, 11 April 2019 at 21:21:16 UTC, Dennis wrote:
 On Thursday, 11 April 2019 at 20:32:33 UTC, mate wrote:
 On Wednesday, 10 April 2019 at 21:39:36 UTC, Walter Bright 
 wrote:
 On 4/8/2019 11:23 PM, aliak wrote:
 [2] 
 https://github.com/apple/swift-evolution/blob/master/proposals/0225-binaryinteger-iseven-isodd-ismultiple.md
"Stack Overflow questions: c - How do I check if an integer is even or odd? 300,000+ views java - Check whether number is even or odd 350,000+ views Check if a number is odd or even in python 140,000+ views" Huh.
Shocking indeed.
I don't get it. What's shocking about it, that people often need to know the parity of a number or that people aren't born with the knowledge that the % operator can be used for that?
Exactly, but funny how you attacked me for calling a person ignorant yet say the same thing. We are all born ignorant. There was a time when everyone in this forum and all the "greatest" programmers didn't even know what an even number was. We are all born in to ignorance and as we learn we add to our knowledge base. There are 7B people on this planet, if 1/10 of those are children and 1/10 of those are kids that are into programming and if we further drop it down 1/10*1/100 just for the hell of it, that is 70k. Also, I doubt views are a good estimate of what is related to how much people know something. The shocking fact is, is that all human beings know squat in the absolute since. We are all morons... some of us, well, very few, just realize that. You can bet there is a musician somewhere in some forum saying how shocking it is that "What is a tritone" got 100k views and thinks everyone else in the world is a moron for not knowing that... and he's right, he just forgets to include himself. Or some chemist and talking about some basic chemistry fact... or whatever. The problem with knowledge/intelligence is that those who have the least of it think they have the most.
Apr 11
parent Alex <AJ gmail.com> writes:
...and my point was that knowledge/intelligence is learned. So 
people that don't know something or understand something is due 
to them not having learned it. It has nothing to do with some 
innate abilities(which is just BS perpetrated on us by other 
ignorant people who use things like genetics to explain why some 
people are ignorant and others are "geniuses"(of which most 
"geniuses" are morons at everything else)).
Apr 11
prev sibling next sibling parent Arun Chandrasekaran <aruncxy gmail.com> writes:
On Tuesday, 9 April 2019 at 06:23:26 UTC, aliak wrote:
 I personally love swift as a language because it's just a 
 pleasure to write _and_ read.
I understand this is subjective. Still this is _not_ pleasure to read. Feels like C++ syntax reborn. // Bool.swift in apple/swift public static func random<T: RandomNumberGenerator>(using generator: inout T) -> Bool { return (generator.next() >> 17) & 1 == 0 }
Apr 10
prev sibling next sibling parent aliak <something something.com> writes:
On Tuesday, 9 April 2019 at 06:23:26 UTC, aliak wrote:
 I personally love swift as a language because it's just a 
 pleasure to write _and_ read. Swift 5 was released recently [0] 
 and has a few interesting additions, particularly the additions 
 they've added to string interpolation [1] so that you could do 
 things like

 let a: MyType = "this is an \(type: .interpolated) string"
This should've been: let a: MyType = "this is an \(min: 1) string"
Apr 10
prev sibling next sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 4/9/19 2:23 AM, aliak wrote:
 [2] 
 https://github.com/apple/swift-evolution/blob/master/proposals/0225-binaryinteger-iseven-isodd-ismultiple.md
Wow. And here I was thinking we have clowny things in the standard library...
Apr 11
parent Dennis <dkorpel gmail.com> writes:
On Thursday, 11 April 2019 at 17:52:41 UTC, Andrei Alexandrescu 
wrote:
 Wow. And here I was thinking we have clowny things in the 
 standard library...
I don't get what's clowny about it, it gives a clear name for a common function and it hides unnecessary implementation details. Do you think properties like int.min are clowny too and that people should just write (1 << (int.sizeof*8-1)) or use a D equivalent of limits.h?
Apr 11
prev sibling next sibling parent Guillaume Piolat <first.last gmail.com> writes:
On Tuesday, 9 April 2019 at 06:23:26 UTC, aliak wrote:
 I personally love swift
It's important to not that Apple has a vested interest into breaking your code often and later, and it will happen eventually when Swift is deprecated and the next Apple langage is out. This is because Apple sells hardware and breaking software often makes up reasons for software providers to be incompatible with older hardware, which leads to hardware selling more.
Apr 11
prev sibling parent reply Tony <tonytdominguez aol.com> writes:
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.
Apr 11
next sibling parent reply aliak <something something.com> writes:
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
Apr 11
next sibling parent reply Paulo Pinto <pjmlp progtools.org> writes:
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.
Apr 11
parent aliak <something something.com> writes:
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.
Apr 11
prev sibling parent Walter Bright <newshound2 digitalmars.com> writes:
On 4/11/2019 11:20 PM, aliak 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."
They haven't sent me an offer so they can't want it that bad :-) But I'm too old to be a "cultural fit", so you guys are stuck with me.
Apr 12
prev sibling parent reply "Nick Sabalausky (Abscissa)" <SeeWebsiteToContactMe semitwist.com> writes:
On 4/11/19 7:23 PM, 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.
It's probably because there's nothing in Swift that appeals to the same sheeple who consider it perfectly normal and acceptable in 2019 to hand your entire machine over to a randomly-activated process that hijacks all control over your own personal physical property (including the ability to close the lid, unplug it, and stick it into its own stupid carrying case so you can drive the F*&*ck home without corrupting the entire freaking operating system) for an *unspecified* number of **HOURS**, while requiring both fast internet access and ZERO interactivity, so it can perform the absolute most poorly-implemented update process **in computing history**, at its own discretion, while silently disabling your complex, hard-to-discover, unintuitively-activated pro-privacy settings.
Apr 13
parent reply Timon Gehr <timon.gehr gmx.ch> writes:
On 13.04.19 10:22, Nick Sabalausky (Abscissa) wrote:
 On 4/11/19 7:23 PM, 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.
It's probably because there's nothing in Swift that appeals to the same sheeple who consider it perfectly normal and acceptable in 2019 to hand your entire machine over to a randomly-activated process that hijacks all control over your own personal physical property (including the ability to close the lid, unplug it, and stick it into its own stupid carrying case so you can drive the F*&*ck home without corrupting the entire freaking operating system) for an *unspecified* number of **HOURS**, while requiring both fast internet access and ZERO interactivity, so it can perform the absolute most poorly-implemented update process **in computing history**, at its own discretion, while silently disabling your complex, hard-to-discover, unintuitively-activated pro-privacy settings.
I'm not sure why similar arguments do not apply to users of Apple devices.
Apr 13
parent reply "Nick Sabalausky (Abscissa)" <SeeWebsiteToContactMe semitwist.com> writes:
On 4/13/19 8:34 PM, Timon Gehr wrote:
 On 13.04.19 10:22, Nick Sabalausky (Abscissa) wrote:
 It's probably because there's nothing in Swift that appeals to the 
 same sheeple who consider it perfectly normal and acceptable in 2019 
 to hand your entire machine over to a randomly-activated process that 
 hijacks all control over your own personal physical property 
 (including the ability to close the lid, unplug it, and stick it into 
 its own stupid carrying case so you can drive the F*&*ck home without 
 corrupting the entire freaking operating system) for an *unspecified* 
 number of **HOURS**, while requiring both fast internet access and 
 ZERO interactivity, so it can perform the absolute most 
 poorly-implemented update process **in computing history**, at its own 
 discretion, while silently disabling your complex, hard-to-discover, 
 unintuitively-activated pro-privacy settings.
I'm not sure why similar arguments do not apply to users of Apple devices.
Dunno. I haven't really used Apple devices much in a good while (not a fan for various reasons), but based on what I have seen, Windows Update is faaar worse as of...around Win7? XP? I forget...and has only gotten *worse* with Win10. And I'm not talking OS upgrades, just the ordinary regular updates. Do Apple devices regularly do force-updates just upon normal shutdown/startup and then take as many as 4 or even 8 or so hours to complete? 'Cause I've seen that on many people's Windows computers many times.
Apr 15
parent reply "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Mon, Apr 15, 2019 at 07:18:17PM -0400, Nick Sabalausky (Abscissa) via
Digitalmars-d wrote:
[...]
 Dunno. I haven't really used Apple devices much in a good while (not a
 fan for various reasons), but based on what I have seen, Windows
 Update is faaar worse as of...around Win7? XP? I forget...and has only
 gotten *worse* with Win10. And I'm not talking OS upgrades, just the
 ordinary regular updates.
Two decades after graduating from college, I thought I had finally grown out of my college years' anti-MS Linux zealotry, only to be rudely awakened when one day my wife's Windows laptop popped up a notice that there were important security updates to be installed, and upon clicking "OK", it suddenly ended up upgrading the *entire lousy OS* to Windows 10 -- with no option of backing out, and which took who knows how many hours, during which my wife could not get any work done. I beat a hasty retreat back to my former stance of not touching Windows with a 10-foot pole for any non-toy purposes.
 Do Apple devices regularly do force-updates just upon normal
 shutdown/startup and then take as many as 4 or even 8 or so hours to
 complete? 'Cause I've seen that on many people's Windows computers
 many times.
Nothing surprises me anymore, after MS had the audacity to force-feed Windows 10 down my throat under the guise of a "security update". :-/ T -- One reason that few people are aware there are programs running the internet is that they never crash in any significant way: the free software underlying the internet is reliable to the point of invisibility. -- Glyn Moody, from the article "Giving it all away"
Apr 15
next sibling parent reply rikki cattermole <rikki cattermole.co.nz> writes:
On 16/04/2019 11:34 AM, H. S. Teoh wrote:
 Nothing surprises me anymore, after MS had the audacity to force-feed
 Windows 10 down my throat under the guise of a "security update". :-/
Strange, I remember it being opt-in. Are you sure it wasn't already scheduled?
Apr 15
parent reply "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Tue, Apr 16, 2019 at 11:41:14AM +1200, rikki cattermole via Digitalmars-d
wrote:
 On 16/04/2019 11:34 AM, H. S. Teoh wrote:
 Nothing surprises me anymore, after MS had the audacity to
 force-feed Windows 10 down my throat under the guise of a "security
 update". :-/
Strange, I remember it being opt-in. Are you sure it wasn't already scheduled?
The laptop was running either Win 7 or Win 8. It was only "scheduled" in the sense that that was the time when MS decided that everything before Win 10 was no longer supported / deprecated / whatever, and was pushing for everyone to upgrade to Win 10 (I was not the only one caught by surprise by this move). The notification was something like "you have important upgrades to install" or something like that, which we usually just press "OK" to -- it's one of those constant annoyances we've developed a knee-jerk reaction to. I vaguely remember at the time there were some security issues that needed to be patched, which was the only reason I even paid any attention to my wife's laptop at all, but the way it was done was basically "either upgrade to Win 10, or don't install any upgrades at all and leave your computer vulnerable to the latest nasty security flaw and ignore every Win Upgrade notification from then on, which will constantly pester you with reminders and further notifications". I actually googled online at the time and found several other similar complaints and descriptions of how the only way to *not* be force-upgraded to Win 10 was to turn off Windows Update completely by hacking some obscure registry setting. But by then it was already too late, since installing those "security updates" automatically puts your computer on the Win 10 installation track, and I didn't even want to think about what state it will leave your computer in were I to dare to interrupt the process. Needless to say, my wife & I were very unhappy about that "security update" taking many hours to install itself (IIRC we gave up waiting and left it to run overnight), during which she couldn't get any work done, and after which we were confronted with a brand new installation with a completely new, unfamiliar desktop with stuff randomly moved around so they weren't in the familiar places anymore, and random applications went "missing" or no longer working because they're now gratuitously incompatible with the OS, and thus required wasting several *more* hours to relearn how to operate the silly "desktop", reinstall/reconfigure stuff, and move icons back to where they used to be. Talk about adding insult to the injury of essentially having our arm twisted to upgrade to Win 10 even though we consciously decided *not* to when we bought the laptop in the first place. T -- The fact that anyone still uses AOL shows that even the presence of options doesn't stop some people from picking the pessimal one. - Mike Ellis
Apr 15
parent JN <666total wp.pl> writes:
On Tuesday, 16 April 2019 at 06:12:41 UTC, H. S. Teoh wrote:
 Needless to say, my wife & I were very unhappy about that 
 "security update" taking many hours to install itself (IIRC we 
 gave up waiting and left it to run overnight), during which she 
 couldn't get any work done, and after which we were confronted 
 with a brand new installation with a completely new, unfamiliar 
 desktop with stuff randomly moved around so they weren't in the 
 familiar places anymore, and random applications went "missing" 
 or no longer working because they're now gratuitously 
 incompatible with the OS, and thus required wasting several 
 *more* hours to relearn how to operate the silly "desktop", 
 reinstall/reconfigure stuff, and move icons back to where they 
 used to be.  Talk about adding insult to the injury of 
 essentially having our arm twisted to upgrade to Win 10 even 
 though we consciously decided *not* to when we bought the 
 laptop in the first place.


 T
I have a different experience. Windows 10 is one of my favourite OSes. I didn't really like Windows XP that much. Sure, it was better than 98, but it was buggy and unstable. 7 was a very solid OS. Vista had a rough launch, but was OK overall. 8 was a bit awkward with the metro interface, but they fixed most of it in 8.1. I don't ever have problems with updates. They usually install when I leave my PC to go to bed, and it doesn't take more than 5-10 minutes to update. Also, I'd love to get an update to 10 on my old laptop, unfortunately I missed the opportunity, so now I am stuck on Windows 8.1 there :( I installed Ubuntu with Unity instead, because it's the only Linux desktop environment I can stand, but it's not supported anymore, so yeah...
Apr 15
prev sibling parent "Nick Sabalausky (Abscissa)" <SeeWebsiteToContactMe semitwist.com> writes:
On 4/15/19 7:34 PM, H. S. Teoh wrote:
 On Mon, Apr 15, 2019 at 07:18:17PM -0400, Nick Sabalausky (Abscissa) via
Digitalmars-d wrote:
 [...]
 Dunno. I haven't really used Apple devices much in a good while (not a
 fan for various reasons), but based on what I have seen, Windows
 Update is faaar worse as of...around Win7? XP? I forget...and has only
 gotten *worse* with Win10. And I'm not talking OS upgrades, just the
 ordinary regular updates.
Two decades after graduating from college, I thought I had finally grown out of my college years' anti-MS Linux zealotry, only to be rudely awakened when one day my wife's Windows laptop popped up a notice that there were important security updates to be installed, and upon clicking "OK", it suddenly ended up upgrading the *entire lousy OS* to Windows 10 -- with no option of backing out, and which took who knows how many hours, during which my wife could not get any work done. I beat a hasty retreat back to my former stance of not touching Windows with a 10-foot pole for any non-toy purposes.
Yup, exactly. But what adds insult to injury is that in post-XP Windows-land this sort of "abruptly locked out of your own machine for the whole day, can't even pack it up to drive home" is common even for ordinary updates, not just the OS-upgrade ones. That *might* have been acceptable if they had ever bothered to address the patently absurd amount of time it's always taken to install Windows Updates ever since "Windows Update" was first introduced. (What the hell is it even doing?!?!?!? Downloading and overwriting three entire OS-sized blocks of data wouldn't take this long!!! So what in the hell are they *continuing* to waste their own customer's time with???) I can download and install an All-GUI-Bells-And-Whistles-Linux installation in *less* time than it frequently takes Win7 through 10 just to update itself with the latest patches. So just how incompetent are they? And on top of that, there are SOOOOO many perfectly-capable machines out there (including mine, as it turns out) where Win8/10 are rendered 99% non-interactive for literally an hour or more upon booting just because of Windows Update and/or other such default "background" services. (Unless you jump through enormous hidden hoops to kill the services...which doesn't always even survive the update!) I've been...umm...conned...into trying to "fix" other people's computers just because, as it turned out, the non-optional, no-warning, guerilla Windows Update forced them into shutting down their computers in the middle of an all-day update, which, unsurprisingly (*HINT!**HINT!* Microsoft! *HINT!**HINT!*, left their OS installations corrupted. And *that* was on Win7! Win 10 is famously even *more* forceful about incompetently-slow upgrades!!! I still (technically) have a Win10 dual-boot on my machine (upgraded, legitimately, from factory-installed 8.1), just for the ability to run non-wine-compatible tools (and games) when I need to. But personal experience had conditioned me to be SO incredibly afraid of booting into it (lest I face the wrath of the Windows Update Of Death commandeering both my machine and my life for as much as a day or so), that I haven't *dared* do so for well over a year. From what I recall, 8.1 was only slightly better. It's ***NO FREAKING WONDER*** smartphones and tablets have been making PCs look like yesteryear!!!! It's *not* because of "mobile" devices being so much better (they objectively AREN'T, not by a longshot)...It's because first, Microsoft has managed to equate its own shitty operating system with "Laptop" and "PC", and THEN managed to fuck it all up so incredibly badly, that even something as patently shit as the iOS and Android devices are...actually manage to look good by comparison to Microsoft's complete and utter platform-destroying epic-scale ineptitude. Apple never managed to achieve anything remotely resembling majority marketshare on PCs and Laptops what with MS's stranglehold over that mindshare (nevermind Apple's insane marketing-driven insistence that Macs somehow aren't Personal Computers, I mean f*ck, it was Apple..or rather Apple's *GOOD* co-founder Wozniak...who pretty much *INVENTED* the personal computer! But *no* they're not "PCs"...ok, sure Apple, fine, whatever...) But, despite MS's stranglehold over "PC"/Laptop mindshare, Apple easily won a major share of an alternative -to-"PC"/Laptop platform. Sooo...Anyone out there *really* wanna try to claim Apple's mobile success was in anything less than *huge* part due to the fact that they...just...simply...*didn't* screw it up as absurdly horrifically bad as MS continues to screw up, poisoning the well of the entire category of PCs/Laptops?
 Do Apple devices regularly do force-updates just upon normal
 shutdown/startup and then take as many as 4 or even 8 or so hours to
 complete? 'Cause I've seen that on many people's Windows computers
 many times.
Nothing surprises me anymore, after MS had the audacity to force-feed Windows 10 down my throat under the guise of a "security update". :-/
Ehhh...no surprise to me that MS had the audacity to pull that. It was extremely unfortunate, criminal even IMO, but the writing there was already on the wall. The REAL bets here are all on what clearly is a cutthroat industry-wide race to see which monolith (MS/Apple/Google/Facebook/Amazon/some-underground-newcomer) can secure the crown of "World's Largest Anti-Human T&rd". I can guarantee you one thing though: The winner of *that* mis-title will NOT be one formed under the "Socially Responsible Corporation" notion that a pathetically minuscule *3* states out of 50 even offer. Such an organization would be at a severe disadvantage in that race.
Apr 15