During our Boston D Meetup today, we went through and deconstructed Walter's wonderfully elegant blog post from 2012 called "Component Programming in D"

http://www.drdobbs.com/article/print?articleId=240008321&siteSectionName=architecture-and-design

I stumbled upon this gem (and another score or so articles on the digital mars site) a few days back, while following various hyperlinks, within and around the blog on Walter's take on what was C's biggest mistake which has been getting a lot of comments over the past few days.

This post which I have been trying to digest bit-by-bit over the past few days, made me realize why I fell in love with D in the first place. To top it all, Steven played a lightening talk from 2018, called "values as types" by Andreas (https://youtu.be/Odj_5_pDN-U?t=21m10s) which is a parody on C++ and is so utterly ludicrous, we could not stop laughing. Anyway, back to the point.

During the same period, but independent of the thread on C's mistake, I found that Kotlin has something called "Extension Functions" and "Extension Properties" (https://kotlinlang.org/docs/reference/extensions.html) via. the following article on Medium

https://medium.com/@magnus.chatt/why-you-should-totally-switch-to-kotlin-c7bbde9e10d5

Specifically Item #14.

What I saw/read seemed eerily familiar. Almost like a "wolf in sheeps clothing". The example screamed of UFCS. Then, later, while reading the above Kotlin documentation, I saw a reference being made to similar functionality in C# and Gosu (apparently a programming language that I have never heard of before today) called Extensions.

Furthermore, I found that Project Lombok (https://projectlombok.org/features/experimental/ExtensionMethod) has tried to make this idiom/functionality available in Java through a @ExtensionMethod annotation. This also almost exactly represent UFCS functionality, though much more cludgy, I must say.

Therefore, after reading the word "Extension" in three different contexts, I started wondering and various questions came to mind, starting with---Whence came UFCS?

a. Did Walter and/or Andrei invent it independently of C#?
b. Was it called UFCS in some other language?
c. Were they not aware of Extensions when they coined UFCS?
d. Are UFCS and Extensions really one and the same thing?
e. If not, what is/are the difference(s)? And is this why a different term/acronym was coined?

As far as I can tell a Google search on UFCS leads to only material on D and a Wikipedia entry mentioning Stroustrup and Sutter's proposal from 2016 to extend C++ to have this facility. It is likely that the Wikipedia article is severely incomplete in its historical connections as there is no mention of C# or that of Walter's 2012 Dr. Dobbs post which already lists it towards the end---in the list of features that D has which allows the creation of elegant components---among other dozen or so features.

In the end I thought I might as well dump my thoughts on the D forum and hear straight from the horse's (or horses') mouth(s)---so to speak.

--
Sameer

Reply via email to