Functional aliases, i.e. hypothetical ability to assign a different syntactic name to function and its argument labels, would alleviate that. Then everyone could just use their preferred version.
While I agree it is annoying to type long labels like withRespectTo: in some instances it would be very welcome. Say, for descriptive purposes like tutorials and learning materials. It is longer to type but easier to read.
I don't think wrt is more annoying than any other term specific to this field. You have to learn it once, and then it's fine. Having to type withRespectTo: everywhere would be far more annoying.
Just to chime in here; generally swift generally avoids abbreviations in favour of a more verbose syntax. As someone who is native English speaking I had no idea what 'wrt' stood for until it was discussed here. Abbreviations like that might be prolific in some circles, but it's not universal. In the interest of inclusivity and readability withRespectTo: is more favoured.
Except in specialized domains like mathematics, where the Swift API Design Guidelines make explicit exceptions for widely used terms of art:
Within a particular programming domain, such as mathematics, a widely precedented term such as sin(x) is preferable to an explanatory phrase such as verticalPositionOnUnitCircleAtOriginOfEndOfRadiusWithAngle(x). Note that in this case, precedent outweighs the guideline to avoid abbreviations: although the complete word is sine, “sin(x)” has been in common use among programmers for decades, and among mathematicians for centuries.
I'm not an enough (or anything) of an expert in differentiable computing to say whether wrt is a well-precedented term compared to withRespectTo to warrant the abbreviation; this was just intended to comment on the broader statement of when abbreviations are/are not preferred by the language guidelines.
The difference with sine function here is that sin(x) is pervasive across many programming languages and has been for a very long time. So, changing it to something else will add to confusion, not the other way around. I don't think wrt has come anywhere close to sin in terms of usage in programming. As obvious from comments here, "wrt" isn't easier to understand than "withRespectTo". It is just shorter to type.
Not only that — it's also used in many natural languages:
Just head over to Wikipedia and check Seno (matematica) - Wikipedia
The link shows the Spanish article, where the function is called "seno", which is spelled slightly different — but in written equations, the Spaniards seem to use sin as well. So do many other languages, even some which I could not name, because they have a custom alphabet ;-)
I think it's save to assume that a user knows a) about differentiation, and b) understands the English language — but this doesn't not mean they learned about differentiation using English words.
If there wouldn't be any label at all, or a simple fill word instead, there would be little chance that someone does not understand the meaning. On the other hand, when you add an element of surprise to the mix, this just causes needless confusion. wrt is definetly not a term of art in mathematics, unless you limit horizon to the English speaking world (Latin or Ancient Greek would be fine, though ;-).
I can't tell what I would chose, but I'd encourage everyone to talk to a pupil who just learned the concept, and take whatever word they use (for me, in direct translation, that would be "by" or "in" — not only very common words, but also even shorter than wrt ).
I think some noun like "variable" or "parameter" would also be ok — or just no label at all.
Firstly: Swift is a formal language based on the natural language English. Every single standard library function, including argument labels. But not only that, even if we exclude the standard library, and look at the core language, even then we can clearly see that Swift is based on English. We use words such as class, func, as, try, do, catch, throws, let, etc. Swift is English, whether we like it or not. And differentiable functions, is a mathematical concept. Whatever we call it, should be based on standard mathematical terminology in English.
Secondly: With respect to is a term of art, and has been used in mathematics since Leibniz' time. In other languages, there may be other phrasings (e.g in my mother language Norwegian, we say "den x-deriverte av f", literally "the x-derivative of f"). But still, in English it is a term of art.
Thirdly: Words such as "by" or "in" have different meanings in mathematics, which may be confusing. A function can e.g. be differentiable in a range or domain, or in some neighbourhood of a point.
I'm fine with spelling it out, but to replace it with another term would almost certainly be more confusing at best, and incorrect at worst.
Imho this strain of discussion is to specific and to general at the same time:
Too specific, because it's only about a minor detail of the pitch, and too general, because naming rules should be consistent, and not only apply to a single case.
Therefor, I switched over to Using jargon in the name of the @derivative attribute
This argument seems like an appeal to tradition and an is-ought problem.
Every new development has to start somewhere and without precedents. Imagine if C++'s developers didn't implement Generics (Template) because no other languages have it.
As a matter of historical interest, Ada had generics long before C++, and, many regard Ada's generics specification superior to everything that has come since, including Swift generics.
Yes. We (the authors) have been working on various features (e.g. differentiating through wrapped properties, differentiating with respect to inout parameters, support for @differentiable(linear) functions) and dogfooding the proposed features ourselves. We hope to draft an evolution proposal within the next year or so.
27 Likes
SwiftUI
({ @MainActor in M5.Extreme }(Swift))
155
So long to develop, looks it’s very hard for implementation. Wish to see it in Swift 7 !