News for hackers. Stuff that matters.
Re:Google’s Go Style Guide by raverbashing on Friday November 18, 2022 @08:24AM (#33654214)
Good

Apple APIs are infamous for their long names. Not sure what they gain by it

Re:Google’s Go Style Guide by Cthulhu_ on Friday November 18, 2022 @08:36AM (#33654391)
I never minded it so much in Apple code; with the syntax for calling methods, it made method invocations sound like sentences, more like literal programming. Plus, intrinsic named parameters, so many languages - including Go IMO - would benefit from named parameters.
Re:Google’s Go Style Guide by wingerlang on Friday November 18, 2022 @09:15AM (#33654989)
Never having to figure out what a function actually does is nice.

builder.makeThing("a", true, true, 46)

[builder makeThingNamed:"a" isRound:YES isRed:YES size:46]

or lately

builder.makeThing(named: "a", isRound:true, isRed:true, size:46)

Re:Google’s Go Style Guide by speedyapoc on Friday November 18, 2022 @09:44AM (#33655422)
Right? I have never understood the frustration around named parameters like this. It helps reduce cognitive load quite a bit.
Re:Google’s Go Style Guide by Jiro on Friday November 18, 2022 @10:39AM (#33656278)
It increases cognitive load when writing the function call, since you now need to remember what kind of true to use. It also increases cognitive load for people who either do already understand the parameters or who are doing something for which the parameters are not relevant; it's harder to ignore a long thing than to ignore a plain "true".
Re:Google’s Go Style Guide by masklinn on Friday November 18, 2022 @11:28AM (#33657094)
> It increases cognitive load when writing the function call, since you now need to remember what kind of true to use.

There is no "kind of true".

> It also increases cognitive load for people who either do already understand the parameters

By letting them see what the parameter they remember is? There's no cognitive load to seeing what you expect.

> or who are doing something for which the parameters are not relevant;

If the language doesn't have optional parameters, all parameters are relevant. By making parameters named, you avoid having to count positional parameters as in MS APIs to ensure you didn't get one in the wrong slot.

> it's harder to ignore a long thing than to ignore a plain "true".

Which is very much valuable. It's much easier to notice mistakes than when you've got 11 positional parameters of which 2/3rds are usually set to 0/null.

Re:Google’s Go Style Guide by masklinn on Friday November 18, 2022 @11:21AM (#33656972)
> Apple APIs are infamous for their long names. Not sure what they gain by it

Clarity.

It's also a factor of Objective-C's compound methods (inherited from Smalltalk), as each parameter names appears in the method, and which leads to a very phrase-like style.

By osmosis, the C APIs use a similar style.