Klong: A Simple Array Language

83 tosh 16 6/20/2025, 12:44:09 PM t3x.org ↗

Comments (16)

why218 · 7m ago
I think that the vast majority of people who complain that these languages are unreadable and who insinuate that people who use and like them are basically just showing off are fundamentally uninterested in the possibility that there are possible positive trade offs to this style but for those who are genuinely interested in why some people like to program this way: Imagine having to do math with no symbols. that means 1+1 is now one plus one. Now imagine having to do that in the context of graduate levels mathematics. I am quite sure nobody calls a2+b2=c2 unreadable as compared to a squared plus b squared equals c squared and I dont know any one who wants to do algebra that way. Well the same principle is why array programmers like this style. I dont expect you to take my word for it im just letting you know what these other weird crazy people see in array languages that you dont. This allows one to think faster and further than they could encumbered but a heavier syntax. Is this way of programming the best no. Should everyone learn it no. Are there trade offs yes. Is it worth your time, quite possibly not. But thats true about literally everything in programming.
Aken · 23m ago
> If you don't know any array languages, it might explode your brain. Use at your own risk!

I've been around the block, don't think it'll be a problem picking up something new

> Here is a program that checks whether a number x is prime (for x>2): {&/x!:\2+!_x^1%2}

(closes laptop and goes outside)

nils-m-holm · 34m ago
No idea why emorning3's comment is marked [dead]. It's a good question and in fact Klong arrays are very much like S-expressions. In fact their implementation is pretty much the same, down to using CAR and CDR to manipulate them. Klong could easily be implemented as a bunch of LISP functions and macros.
Jtsummers · 24m ago
> No idea why emorning3's comment is marked [dead].

https://news.ycombinator.com/item?id=44231847

It's [dead] because they were banned, not because of the comment itself. It can still be vouched for.

etbebl · 50m ago
I wonder how much overlap there is between users of array languages and of scientific programming languages/dialects like MATLAB, Numpy, and Julia, which are also optimized to operate over arrays. In other words, do K/Klong/whatever proponents realize that there is already a huge community of people who appreciate and utilize powerful operations on arrays to do real work, but just prefer to write something like "max(diff(x))" instead of "|/--:'x"? It's almost the same number of characters and it doesn't require learning a new writing system.
mlochbaum · 31m ago
"already": APL dates back to about 1966, and even K from 1993 predates Numpy and Julia. But yes, we do not live in caves and are familiar with these languages. Klong has even been implemented in Numpy, see https://github.com/briangu/klongpy.
TimorousBestie · 19m ago
The world is big enough for people to safely experiment with programming languages. I don’t think there’s any risk to Matlab/Python/Julia (and indeed, many people did and still argue that Julia is excess baggage).
haolez · 1h ago
I wonder if these extremely terse languages might see a rise in popularity with LLMs, since they save a lot of tokens. The hard part would be training on them, since training data is not as comprehensive as JavaScript, for example.

Fun times! :)

Qem · 1h ago
> The hard part would be training on them, since training data is not as comprehensive as JavaScript, for example

From terse languages surely there is a lot of training data for Perl. Not nearly as terse as J, K or Klong, although.

ljouhet · 35m ago
First line of https://t3x.org/klong/prime.html

"The braces around an expression denote a function. Because this function contains a single variable, x, it is a monadic function or a monad."

I never understood that about monads, even if it's litterally their name.

cosmic_quanta · 1h ago
There's a niche out there where this kind of technology is appreciated. I can even appreciate the technical challenges in making an array language interpreter run fast!

However, unfortunately, the notation is so terse that I can't imagine spending the time to learn this. This looks write-only.

Is there an obvious reason to prefer a k-like language like Klong, over e.g. Futhark[0] or Accelerate[1]?

[0]: https://futhark-lang.org/

[1]: https://hackage.haskell.org/package/accelerate

tosh · 50m ago
the terseness is magical when you are in the repl and it just takes typing 1, 2 or a hand-full of characters to try an idea you have

edit: and when you want to understand a larger program the terseness means you might be able to actually see it as a whole, in one page or screen

emorning3 · 1h ago
Google tells me that Klong and Lisp are not the same thing.

But can someone tell me why an array in Klong is NOT like an s-expression in Lisp?...

thomasmg · 2h ago
> If you try to use it like your favorite functional/procedural/OO programming language, you will only get frustrated.

For me personally, the sentence could be shortened to just: "If you try to use it, you will only get frustrated."

nils-m-holm · 45m ago
So the sentence served its purpose and saved you the frustration :)
thomasmg · 20m ago
I appreciate the features of these languages (J, K, and Klong), but I do not understand the reason why they have such a hard to read syntax. I think it is a pity; I could see myself using it otherwise. Maybe it is by design, but I do not understand it.