7 ms·
Klong: A Simple Array Language
- thomasmg 1y 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 1y agoSo the sentence served its purpose and saved you the frustration :)
- thomasmg 1y agoI 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.
- nlitened 1y agoI guess you could say the same about Chinese language, but many people who learned it understand it
- skruger 1y agoHere is a gentle start: https://xpqz.github.io/kbook/Introduction.html https://xpqz.github.io/kbook/Introduction.html
- thomasmg 1y agoThanks! So here is an explanation: > The same baseless accusations of “unreadable”, “write-only” and “impossible to learn” are leveled at all Iversonian languages, k included. I argue that these accusations are far from baseless. Sure, I can not cite a study, but neither does he. So I assume it's word against word. > Readability is a property of the reader, not the language. In my view this is an oversimplification. Having a steep learning curve clearly prevents adoption. The language design actively contributes to the problem. I'm just not sure on why. Could it be that the authors of these languages do not _want_ them to be used by others?
- mlochbaum 1y agoSearch for "teaching" at https://aplwiki.com/wiki/APL_conference https://aplwiki.com/wiki/APL_conference. I count at least five papers about teaching non-APL topics using APL. The language is not only possible to read, it's designed for it.
- skruger 1y agoThe learning curve isn’t steep. I’d argue the opposite. K is a tiny, tiny language. Put your mind to it, and you’ll be reading it just fine in a weekend. It’s just different. It’s optimised for its wheelhouse.
- gitonthescene 1y agoYou could say you enjoy toodling on the piano but don’t understand why reading music has to be so hard. It doesn’t _stay_ hard and it opens up new avenues.
- cosmic_quanta 1y agoThere'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/ https://futhark-lang.org/ [1]: https://hackage.haskell.org/package/accelerate https://hackage.haskell.org/package/accelerate
- tosh 1y agothe 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
- kazinator 1y agoI can't read anything that is too far out of my fovea. If I look at a word in the middle of a sentence, I can read it, and the two immediately adjacent words. After that, the ability rapidly declines. If the next words after those two are simple like "and" and "the", I can still read them while staring at the middle word. Beyond that, I am aware that there are letters and words, but no decoding takes place. If something fits on the screen, it's nice that I don't have to scroll around, but I certainly cannot see it all at once in a semantic way, only as a picture.
- t-3 1y agoIt's more a matter of comfort for me than anything to fit a program in a single screen or a function with a single line - large programs and functions are significantly more anxiety-inducing for me to read and work on. I have to keep scrolling and scanning back-and-forth and easily lose my train of thought and get the feeling that I've forgotten something important.
- 1y ago
- haolez 1y agoI 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 1y 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.
- emorning3 1y agoGoogle 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?...
- etbebl 1y agoI 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 1y 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 https://github.com/briangu/klongpy.
- etbebl 1y agoI understand that these languages are older; I meant that in the sense that they are nonetheless still trying to recruit new users, but these potential users may already be using something that does something similar.
- mlochbaum 1y agoOddly enough, the biggest mistake in how I presented BQN early on was thinking only APL insiders would be interested, when in fact the APLers went back to APL and people who hadn't tried other array languages or hadn't gotten far with them were were most successful with BQN. Plenty of people coming to BQN have worked with Numpy or whatever, but I don't think this has the same deterrent effect; they see BQN as different enough to be worth learning. Julia in particular is very different: I don't find that it culturally emphasizes array programming at all.
- TimorousBestie 1y agoThe 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).
- ljouhet 1y agoFirst line of https://t3x.org/klong/prime.html 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.
- kragen 1y agoA monadic function in APL-family languages is not related to monads from category theory, which are the ones you see in Haskell, nor to Leibniz's monads.
- kazinator 1y agoIn this context it just means "one parameter function". It looks like every apparently free variable in a Klong brace expression is actually bound as a function parameter. This is so in basic algebra in that we can think of, say, x^2 + y^2 as a two parameter function, even without writing out the full f(x, y) = x^2 + y^2 notation with the f(x, y) head. A two parameter function would be called "dyadic" in the jargon which calls one argument functions "monadic".
- nils-m-holm 1y agoNo 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 1y ago> No idea why emorning3's comment is marked [dead]. https://news.ycombinator.com/item?id=44231847 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.
- Aken 1y 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)
- andoando 1y agoI mean its not that bad. You just go right to left. 1/2 applied to x^ so x^(0.5), _ is floor so floor of x^0.5. ! creates an array of numbers up until floor of x^0.5. 2+ just adds 2 to every number, and then I lost interest in learning the rest lol. Yeah I like the python equivalent def is_prime(x): return x > 1 and all(x % i != 0 for i in range(2, x))
- fuzztester 1y agoI wonder what the relative performance of the two snippets (Klong and Python) is. Not at a computer now, can't check.
- why218 1y agoim not sure about about klong as it is a hobby project but official veriants of k and q(the wordified k that is somewhat popular in finance) are supposedly quite fast. In the world of industry that is actually these languages main claim to the niche fame they do have.
- fuzztester 1y agothanks. i had tried out q for a few days, some years ago. yes, I had read that they are supposed to be fast.
- why218 1y agoI 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.
- andoando 1y agoI just fail to see the point. I could see the use for some convenient functions for array manipulation, but why not just implement these as a library in any existing language? >This allows one to think faster and further than they could encumbered but a heavier syntax. How does the programming language limit your ability or speed of thinking, lest when the fundamental data types and operations are the same? The hard work is always knowing what to implement. Saving some keystrokes for reversing an array or whatever other array manipulation is hardly a game changer.
- sundarurfriend 1y ago> library in any existing language An example of this is APL.jl [1][2] It seems more of a proof-of-concept than a real implementation though - at least, the APL wiki calls it a "toy dialect of APL" and says that it "works on a minor subset of APL". [3] [1] demo: https://nbviewer.org/gist/shashi/9ad9de91d1aa12f006c4 https://nbviewer.org/gist/shashi/9ad9de91d1aa12f006c4 [2] repo: https://github.com/shashi/APL.jl https://github.com/shashi/APL.jl [3] https://aplwiki.com/wiki/APL.jl https://aplwiki.com/wiki/APL.jl
- deleted 1y ago[deleted]
- Duanemclemore 1y agoKlong was among the languages I looked at when I was trying to pick a language for a project (ongoing but back-burnered at the moment). Ultimately I went for Dyalog APL, but looking at the documentation - and the great website - for Klong I found it quite... charming? If you're familiar with the array paradigm it's pretty straightforward. Unrelated editorializing - Klong has come up in passing on the Array Cast [0] before, but I'm surprised they haven't interviewed Holm. They seem to be doing less of the "forbears tell awesome stories" episodes lately. Which is a shame because that's probably the single best sub-set of Array Cast episode types... [0] https://www.arraycast.com/ https://www.arraycast.com/