Hi, @everythingfunctional , nice to get your comments!
Your blog is definitely insightful and illuminating. I completely agree with the opinions inside. Indeed, I have forwarded your blog to a student of mine and convinced him to rewrite his code (partially) to align with the principles stressed in your blog.
(Here is the link again to the blog if others are interested: Communicating with Whom?. The link in my original post was broken and now fixed.)
As well elaborated in your blog, I wish literally everyone who codes nowadays realizes that she/he is communicating with not only machines but also humans, and that coding is not only to get some job done by machines but also to document human knowledge.
For this reason, I believe that it is very often not a bad idea to compromise performance/efficiency for clearness/readability/naturality. We need to keep in mind that computing power is increasing and will continue to increase in the foreseeable future. As a computational mathematician, I do understand the importance of performance/efficiency in algorithms/coding. However, any useful technique that truly improves performance/efficiency should be abstracted, standardized, encapsulated, and modularized so that it can be easily pulled out and plugged into programs, rather than spread in the code as tricks. “Tricks” that sacrifice clearness/readability/naturality may (quickly) become pointless with more powerful machines, but we cannot expect that mankind can magically become good at handling code of poor clearness/readability/naturality in a few years. Machines evolve much faster than humans. We should rely on the evolution of the former rather than the latter.
For the same reason, I also require myself not to write code that relies heavily on special features of programming languages unless those features are natural in human languages. When my student, who is a Python enthusiast, tells me that “Python has this great feature that does not exist in any other language, and it enables us to shorten the code a lot”, I am always skeptical and tell him not to rely too much on particular features of languages (even though I do not always succeed).
Talking about documenting human knowledge, we need a language that is as similar as possible to human languages (in a broad sense, mathematics is one of them), or, as mentioned in your reply, a language that enables us to code as if we communicate with a human on a blackboard. Fortran, thankfully, was invented to be such a language and has kept evolving towards this direction. I wish that the Fortran community always keep in mind that Fortran means “Formula Translator” when deciding whether a feature should be introduced into the language or not.
According to my experience at math departments for almost 20 years, people would write
(a, b) = f(x)
or
[a, b] = f(x),
similar to MATLAB. Of course, this is not true if a
and b
are two components of a single mathematical object C
that has a natural definition. In that scenario, a well-trained mathematician should write
C = f(x)
rather than naming the components of C unless necessary; the best way to code this f
is then a function outputing a structure/derived type, but again, the definition of C
must be natural and it should not be several pieces that are sewn together cumbersomely.
Thank you again!