K

I like programming languages. Especially those that catch me off balance.

Over past year or two I've been having an awful lot of fun coding in a programming language called K. It hails from the array programming tradition, introduced by APL in 1960s.

K is a commercial product. Binaries for personal and educational use are reportedly available online. I've ended up not using them thanks to alternative open-source implementations. The ones I've tried are, in a chronological order, Kona, oK, and ngn/k.

Documentation and tutorials aren't difficult to find online. Consuming them is more challenging though, since it's not obvious which version of K materials you find work with. Various versions of K, identified by natural numbers, are largely similar, but promise neither backward nor forward compatibility.

I appreciate how simple K's grammar is. The syntax, which at the first glance appears completely alien, doesn't take a lot of exposure to get familiar with. There's not much of a grammar to speak of. The main challenge for me was getting used to reading from the right-hand side, but that's my nurture, not nature.

The simplicity also applies to built-in operations, customarily called verbs and adverbs. Verbs are the main tool for working with data. The role of adverbs is to alter the behaviour of verbs. There's a total of maybe twenty verbs and half a dozen adverbs. Through means of composition, they form a comprehensive set of data processing tools.

To understand the role of adverbs, consider the verb add + and the adverb over /. Intuitively, 1+2 adds two numbers. Altered using over, +/1 2 3 sums up the entire array. It runs add over the array.

Another example pairing is first *: and each '. The expression *:("qwe"; "asd"; "zxc") returns the first string from the array of three strings. Inflected with the ' adverb, *:'("qwe"; "asd"; "zxc") returns the first character from each member of the array. It runs first for each element. That's, frankly, pretty elegant. I appreciate programming languages whose building blocks compose well with one another.

Community resources link to a healthy supply of open source tooling. I've found the plugin with Vim syntax highlighting to be quite useful. It has helped me a lot as I was getting used to the new grammar.

I appreciate K's conversational aspect. Just like in, say, Python or Clojure, I can work in a REPL to build my programmes one expression at a time and immediately see the results. Unlike, say, Python or Clojure, I need to type far less to express my intention. That speeds up the already short feedback loop even further.