5 ms·
Do you consider add(a,multiply(b,c)) certainly more readable than a+b*c? The article shows some nice k idioms that I find much more readable written in a conci
by yiyus 7y ago
Do you consider add(a,multiply(b,c)) certainly more readable than a+b*c?
The article shows some nice k idioms that I find much more readable written in a concise form. For example, I find |^... easier than reverse(sort_ascending(...)), or <>... easier than grade_down(grade_up(...)). I guess the solution in other languages would be to define more functions for all these common operations, but then you will need much more documentation for all these extra functions and learn them, so I don't see it as an improvement.
At difference of most golfing languages, the set of k primitives is very small. Many people who criticize k forget that property, but it's a very important one. It would be interesting to see the R version and compare the amount of documentation you need to read to completely understand what each of the programs is doing (ie. to read the program). That would be, in my opinion, a better measurement of readability than a subjective opinion (unfortunately, the k9 documentation is too scarce at this point to make this exercise in a proper way).
- chrispsn 7y agoYes. When each function is a single character [1], juxtaposition is enough to show the calling order - eliminating the need for brackets in many cases, and reducing syntactic noise. [1] There's a handful of two-character primitives, as well as some special callable symbols (eg `freq @), but they don't come up nearly as often as the base set.
- newswasboring 7y ago> Do you consider add(a,multiply(b,c)) certainly more readable than a+b*c? No, but it took me 12 years of school education to get to that point. Question is, for a large code base how many symbols are you willing to remember? At some point it hits diminishing returns, doesn't it?
- yiyus 7y agoWell, 12 years is an exaggeration. Once you have learned the concepts (which you need to learn independently of which programming language you use), getting used to the symbols is just a matter of a bit of practice. For example, I learnt to multiply with 3x2, but it did not take me 12 years to get used to the 3*2 notation used by most programming languages. The symbols you have to remember are the ASCII symbols (most of them are used in other programming languages too), with two operations for symbol, plus a few special cases and a bunch of extra functions. In total, less than 50 primitives. I think that any programmer can easily handle that. There are many people who do not agree with this, but there is objective data (see the papers by Iverson about his efforts to teach mathematics using APL) that say it is easy to learn. In all these threads, most people with experience in array languages say it is not so hard as it looks, although there are some exceptions. You may prefer other kind of languages or other kind of notation. There certainly is some subjective factor here. But I suggest everyone to give it a try before forming an opinion.