[HN Gopher] Learning K programming: idiom by idiom [pdf]
___________________________________________________________________
Learning K programming: idiom by idiom [pdf]
Author : tosh
Score : 59 points
Date : 2024-05-12 17:06 UTC (5 hours ago)
(HTM) web link (nsl.com)
(TXT) w3m dump (nsl.com)
| mdaniel wrote:
| > http://www.finnapl.fi/texts/Idiot.htm
|
| I somehow doubt that is the actual URL, and doubly so since it's
| 404. I tried URL surgery into
| http://www.finnapl.fi/texts/Idiom.htm but that was also 404 and
| searching for "FinnAPL blue book" didn't cough up anythng
| moonchild wrote:
| https://aplwiki.com/wiki/FinnAPL_idiom_library
| tosh wrote:
| https://web.archive.org/web/20130630212847/http://www.finnap...
| hcfman wrote:
| Not to be confused with the language "K" I built for my masters
| thesis in Auckland in 1985 :-)
| jjtheblunt wrote:
| what's your K like?
| eointierney wrote:
| How antipodean. "I'll make my own from what I have handy."
|
| Deepest respects
| anonu wrote:
| KDB implements k3. By contrast, Arthur's latest endeavor, Shakti,
| is k9.
| RodgerTheGreat wrote:
| KDB+ provides Q, which is implemented in terms of k4.
| andoando wrote:
| Why dont the symbols just have names instead of stuff like ||\x.
|
| I assume it gets easy to read once you practiced it a bunch but I
| feel like its such a hindrance to readability/popularity for the
| sake of appearing simple (look we can reverse a list with a
| single character!)
| dan-robertson wrote:
| The symbols do have names, eg | is commonly called a 'vertical
| bar' or 'pipe'. I think when people read the code though, they
| say the name of the operator instead, e.g. your example is
| 'reverse max scan x'. A complication is that the meaning of a
| symbol depends on the surrounding symbols (eg | can be reverse
| or max) and another is that the meaning can depend on context,
| eg | is max but when the inputs are arrays of bits (where 1 is
| true and 0 is false), max is equivalent to logical or, and so
| people may call the operator 'or' in those contexts.
|
| I think advocates would claim that the symbols allow for faster
| interaction with the computer and for larger programs to fit in
| one's working memory.
| andylynch wrote:
| That's roughly where q comes in, as syntactic sugar on top of k
| andoando wrote:
| Nice just what I was looking for.
| segmondy wrote:
| why does Chinese or Japanese have symbols? Why does mathematics
| have symbols? Symbols represent concepts. Once you know what a
| symbol means you can grok a lot from it. They are limited by
| using keyboard characters, if the authors had their way, they
| would have a custom keyboard with custom symbols, but then most
| people will not be able to use it with any computer, so they
| stuck to such characters. The idea is notation as a tool of
| thought. You don't have to think of chunks of words to think of
| reversing a list. Yet, that's how we often think when we
| program, we read keywords or list expressions or loops and run
| the code in our head which slows comprehension.
|
| https://www.eecg.utoronto.ca/~jzhu/csc326/readings/iverson.p...
| or https://www.jsoftware.com/papers/tot.htm
| rak1507 wrote:
| If you want a serious answer, as a k programmer ||\|x (which I
| assume your example is based on) is instantly readable as
| producing a bitmask of ones up to the last. ie 0 1 0 0 1 0 -> 1
| 1 1 1 1 0. Or a max scan from the right on integer arrays. I
| don't know how to even describe that in English succinctly, let
| alone most mainstream programming languages. (Haskell -
| reverse.scanl1(||).reverse - ok, not too bad)
| andoando wrote:
| I dont see why one cant have both. Give it names and
| translate them down to the base symbols so it has a readable
| syntax.
|
| Id just call it something like exceptLast, lastOf, or endOff
| or something.
| bear8642 wrote:
| You can give them names if you want, and Q does so.
|
| However doing so looses the ease of recognition and the
| malleablity the symbols provide.
| rak1507 wrote:
| You've sort of answered your own question. None of those
| three would obviously mean the same thing to me. And that's
| just one possible combination. If you consider all possible
| combinations of 4 symbols in K, most of them will have a
| distinct but obvious (and useful) meaning that is extremely
| hard to summarise in a single word.
| omaranto wrote:
| Probably the same reason in algebra people went from using
| "plus" to "p." to "+": for readability.
| jacoblambda wrote:
| Note that this is about K, the APL derivative language for the
| kdb database software.
|
| Not to be confused with K, the rewrite based semantic execution
| language built by the University of Illinois Urbana-Champaign and
| now primarily built and maintained by Runtime Verification.
|
| https://kframework.org/
| cess11 wrote:
| Looks like a pretty neat reference to have when dabbling in J as
| well, which I prefer over Kona for several reasons, including
| that I can run it on Android.
|
| https://www.jsoftware.com/
| zX41ZdbW wrote:
| I have a somewhat negative experience with Kona and its
| derivatives Kerf and Kerf2.
|
| For example, among Kerf and Kerf2: - there is no explanation
| about why two versions exist; - the code does not build; - it
| has memory leaks; - both are abandoned; - there are dubious
| performance claims, but when I asked the author to clarify, he
| closed issues without answering.
|
| The same experience with the K community:
| https://github.com/kparc They maintain a cult-like impression
| of their software, and the examples are typically represented
| by a few code dumps with no clear way of using them.
|
| That's not to dismiss the overall idea of array programming
| languages, which I admire.
| 1024core wrote:
| > For total water we can use +/ ("sum over"), resulting in
| +/{((|\x)&||\|x)-x}.
|
| And they say Perl is bad.
| RodgerTheGreat wrote:
| Perhaps you could grace us with your clearest alternative in a
| language you approve of?
| mgaunard wrote:
| My experience when trying to give such tools to data scientists
| is that they can't use them effectively and will attempt to
| circumvent the idea of vector programming whenever they can get
| away with it.
|
| They will also often write code that doesn't do what they really
| want but has the appearance of doing so.
___________________________________________________________________
(page generated 2024-05-12 23:00 UTC)