5 ms·
2_&{&/x!/:2_!x}'!R is very understandable to someone who knows K. (Or at least, the idea is, do you know what dialect it uses? Where's the code from?) The (rou
by rak1507 4y ago
2_&{&/x!/:2_!x}'!R is very understandable to someone who knows K. (Or at least, the idea is, do you know what dialect it uses? Where's the code from?)
The (roughly) equivalent python is filter(lambda x:all(x%i>0 for i in range(2,x)),range(2,R)) - is this really that much better? (yes if you know python, no if you know k)
- gjulianm 4y ago> (Or at least, the idea is, do you know what dialect it uses? Where's the code from?) From Wikipedia page of K programming language https://en.wikipedia.org/wiki/K_(programming_language) https://en.wikipedia.org/wiki/K_(programming_language) > filter(lambda x:all(x%i>0 for i in range(2,x)),range(2,R)) - is this really that much better? You don't need to know Python. Filter is probably doing a filter, "lambda x: ... " looks like a lambda function, for looks like a loop... I am 100% sure that, without any language knowledge, the Python version is far more easy to understand.
- rak1507 4y agoAh, that code was added to the wiki page in 2006 apparently. A modern version is basically the same anyway. I will (maybe) agree that the python is easier to understand without any language knowledge - but that does not mean the K is not understandable. If you know K, it is understandable, and knowing a language seems like a pretty low bar for understanding it.
- gjulianm 4y agoI mean, by the same measure, spaghetti code is not spaghetti code if it makes sense in your head. But we all understand that there are certain qualities of code that make it “spaghetti” or not independently of your understanding of it. Similarly there are features of languages (such as terseness, use of symbols, dependency on context) that makes them harder to read
- gitonthescene 4y agoIf you don’t know a language but are hoping to read it, for what purpose are you intending to read it? Is it a casual understanding? If you’re talking about maintaining the code it’s probably better to stipulate that people already know the language. If you want to maintain code in a language you don’t know, I’m not sure you’d be a great hire.
- gjulianm 4y agoUnless you have perfect memory and perfect recall, it’s very possible you’ll forget what a certain symbol meant. Specially if you read the code at a time you’re not being specially bright (say, Friday noon after an stressful week). Much harder to forget what the word “filter” means. Also much easier to recognize words than symbols where differences might be small.
- rak1507 4y agoIt's really unlikely (imo impossible) you'll forget what a symbol means in APL or K etc if you program in it reasonably often. There aren't many symbols, and most of them are used pretty frequently. If you do forget, there's plenty of resources to jog your memory though. The Dyalog RIDE has a language bar at the top, and hovering over a symbol gives a brief description with examples. https://janiczek.github.io/tryapl-elm/ https://janiczek.github.io/tryapl-elm/ replicates this if you want to see for yourself. I disagree that it's easier to recognise words than symbols if there are small differences, the symbols are distinctive anyway so that's not really a real problem.
- gjulianm 4y ago> It's really unlikely (imo impossible) you'll forget what a symbol means in APL or K etc if you program in it reasonably often. Well, of course, if you’re always practicing the same thing you’re unlikely to forget it. That’s not always the case, though. > the symbols are distinctive anyway so that's not really a real problem. Really? From that toolbar alone I’m seeing empty circle vs slightly smaller empty circle, a lot of symbols with/without a dash or umlaut, dot and comma… seems pretty easy to get a lot of those confused or misread.