One of the first things about Swift that I fell in love with was the difference between things like DrawRect(10, 20, 30, 40) in languages like C#, and DrawRect(at: origin, width: 30, height: 40) in Swift.
DrawRect({at: origin, width: 30, height: 40})
vs. DrawRect(at: origin, width: 30, height: 40)
I can understand why this is considered a nice-to-have. The verbosity didn't really change.function DrawRect(options) {...
Unless you're immediately destructuring it or whatever. I don't think it's _that_ straightforward to compare the two, unless I'm thinking of the wrong languages here.
It will be checked compile time that all keys are provided (unless dict comes from serialized json or something).
Well typing is one good reason, maps usually are not statically typed with key:value pairs. That's more of a class / struct thing. And then the verbosity increases quite a bit.
https://docs.microsoft.com/en-us/dotnet/api/system.drawing.r...
I'd rather have syntax-level support (works with ctrl+f, works outside IDEs, works in IDE when auto-analysis is broken), but if IDE support is what I can get, I'll take it.
One of the most pernicious myths of software engineering is that it happens.
If I see a chain of numbers like 1, 2, 3, 4 my brain has to recall the order of parameters or look it up.
If I'm looking for rectangles that should be wider than they are tall, I have to keep thinking "the third number should be higher than the fourth number"
Oh and I can't just Cmd+F "width:" or "height:" either.
And if you want, you can make arguments keyword-only:
def copyFile(*, source, dest):
...
Parameters after the asterisk cannot be specified by positional arguments. It must be called with keyword arguments: copyFile(source=src, dest=dst)The strategy you propose can only force other people to use kwargs when calling functions you write. When you're reading code, there is no guarantee that arguments to functions you didn't write will be labeled, and indeed they often aren't, even when they ought to be. In ObjC, all arguments are labeled, always. It's heavily opinionated, and the experience is qualitatively different as a result.
Honestly thinking back on Java there were a lot of design patterns and code (sometimes generated) that could've been avoided with e.g. named function parameters.
one can still make a hot mess of 1000-wide lines, bad variable names, and various other forms of spaghetti cowboy-ism.
My aim isn't to argue that forced named args will cure all that ails you, just to share that they "feel" quite different from optional named args, and that on the balance I felt they were a net positive.
[NSCarpalTunnelSyndromeInducer induceCarpalTunnelSyndromeForProgrammer: ....] [NSEyeStrainInducer induceEyeStrainForProgrammer: ....]
Unless XCode can read the signature for me in addition to writing it