Readit News logoReadit News
why218 commented on Klong: A Simple Array Language   t3x.org/klong/... · Posted by u/tosh
fuzztester · 2 months ago
I wonder what the relative performance of the two snippets (Klong and Python) is.

Not at a computer now, can't check.

why218 · 2 months ago
im 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.
why218 commented on Klong: A Simple Array Language   t3x.org/klong/... · Posted by u/tosh
marssaxman · 2 months ago
> Imagine having to do math with no symbols.

I would probably prefer this, because then I could actually look up the unfamiliar terms and have some hope of eventually figuring out what the equation meant, instead of being brought up short and stumped by inscrutable notation.

why218 · 2 months ago
even for actual calculations? if so then touche. But (and I may be wrong) I feel like this comment is coming from a place of I need to look up some formula which for some other task. Like say im making a video game and I want some geometry formula. In such a case what you care about is not how easy a notation is to use but simply getting info as fast as possible in which case learning new symbols just gets in the way rather than actually writing correcting algebraically manipulating and extending (keep in mind im using math as an analogy for programming in not actually speaking about array languages being used _for_ math necessarily). This is a fair criticism of array langauges you do need to learn something which is quite different from the usual english based languages and they are not great for black boxing i.e you have to know the domain of your problem because relying on libraries is impossible at worst and not any better than python or java at best. That being said I find them more scrutable than most langauges partly because of the tersity. And partly because of the limited vocabulary. You can look up unfamiliar operators very easily in array languages because they all come with multiple (some more for reference some more for learning) easy to go to places to do so. But more importantly there really are only so many so you can learn them all (in the same way you already learned your numbers + - 3 %, and so on) once you do you dont feel the need to look up 6 or & or + mean you just know them. In contrast in a language like python or javascript im constantly looking up how things work because there are just infinitely more things the source code of which is often hard to get to and when you find it it is very long (and therefore (for me) hard to read). When I see an array function I actually can scrutinize them when I see a python function I need to hope that its simple and named in a way that makes automatic sense to me or give up and look it up somewhere else (in docs say).
why218 commented on Klong: A Simple Array Language   t3x.org/klong/... · Posted by u/tosh
andoando · 2 months ago
Most programmers don't do any math at all, so maybe this is just a niche thats not relevant to most of us, but to answer your question:

If I am thinking about any problem, its outside the scope of any programming language in the first place. My point is, modern functions already make array manipulations simple enough. Even if you're doing something like coding LLMs from scratch, numpy, list concatenations, list comprehension, lambdas, stream/map/reduce all exist and its not nearly an issue to implement them, as is the case for writing assembly vs python.

The prime example in python for example looks like this: all(x % i != 0 for i in range(2, x)) This pretty much does the same operations in the same order on the same fundamental data structure, so I just don't see what's fundmenetally different about the Klong way of thinking.

Anyway, I don't mean to argue, if it works for you great, I wish I had something new

why218 · 2 months ago
one of the biggest differences between the k way and the python way too is actually limitation. in practice python has a bunch of stuff that doesnt fit too well together necessarily but that you can put together to make whatever you want often without much knowledge underlying what youre using (like how one can make a neural network with no linear algebra knoweldge) in the array languages you have a set vocablary and only a few ways of putting them together such that you become fluent with the whole languages and you brain starts to just put whole correct functions or programs together in the way one might do with a natural language you know well. Its a great exprience and it changes how you think. HOWEVER, I wont pretend for a second this does not come at a cost. The real power comes from fluent use of a small vocabulary meaning you dont get the immediacy of libraries, IO has to be dealt with by the programmer more so than in languages where you have alot of help form libarires and frankly non algorithmic code in these languages can be really funky and rarely as good. Unless you are writing very algorithmically intense stuff imo array langagues are best suited to embedded use in another language or not at all. For you and for most people I think things like the python you've shown there works plenty well enough.
why218 commented on Klong: A Simple Array Language   t3x.org/klong/... · Posted by u/tosh
andoando · 2 months ago
Most programmers don't do any math at all, so maybe this is just a niche thats not relevant to most of us, but to answer your question:

If I am thinking about any problem, its outside the scope of any programming language in the first place. My point is, modern functions already make array manipulations simple enough. Even if you're doing something like coding LLMs from scratch, numpy, list concatenations, list comprehension, lambdas, stream/map/reduce all exist and its not nearly an issue to implement them, as is the case for writing assembly vs python.

The prime example in python for example looks like this: all(x % i != 0 for i in range(2, x)) This pretty much does the same operations in the same order on the same fundamental data structure, so I just don't see what's fundmenetally different about the Klong way of thinking.

Anyway, I don't mean to argue, if it works for you great, I wish I had something new

why218 · 2 months ago
My point with math is not that this only applies to fundamentally math like things but that these languages do for programming what the math notation does for math problems for me. "if i am thinking about any problem, its outside the scope of any programming language in the first place" yes I felt this way too before I learned an array language. Sorry that was a rude way to put that but I do genuinely mean that. Array languages help me solve problems I wouldn't know how to solve otherwise. that python code looks suspiciously full of symbols and one character variable names :). Maybe it would be easier like this: all(exes modulo index not equal zero for index in range(two, ex)).
why218 commented on Klong: A Simple Array Language   t3x.org/klong/... · Posted by u/tosh
sundarurfriend · 2 months ago
> 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.

That's a good way to put it. It's pretty hard to convey this to someone who hasn't actively tried and solved real problems in such languages though. You don't realize how much the "words get in the way" (as Granny Weatherwax would say) until you give an array language a good chance.

Another pop-culture quote that resonated in this regard is from The Matrix:

> Your brain does the translating. I don't even see the code. All I see is blonde, brunette, redhead.

All I see is range, sum-over, divide. The symbols turn into the concepts directly in your head - not as conscious translation, but in the way I imagine Chinese or Japanese kanji characters translate directly in the head of a native speaker.

why218 · 2 months ago
Yes as someone who was exposed to kanji as a child I can say that at least for me the experience is nearly identical
why218 commented on Klong: A Simple Array Language   t3x.org/klong/... · Posted by u/tosh
nine_k · 2 months ago
Mathematical notation actually pays quite a bit of attention to readability, to visual separation of things to make the whole easier to parse. Multi-story fractions, subscripts and superscripts, oversized or miniature symbols, parens, etc, etc. This is why math in a textbook very often looks much more readable than the same math in typical Python or Fortran code.

I wish APL derivatives embraced some of these ideas, and made their magic spells easier to parse visually, and to format for readability. I don't know how to achieve that easily. Mathematical notation took centuries to develop. It took quarter of a century for programming languages to normalize indentation. Maybe APLesque languages will eventually come up with a notation that's less impenetrable than APL / K / Q, but less verbose than Pandas.

why218 · 2 months ago
Well some of what you mentioned has been implemented in array languages and some like superscript and sub script was part of the original apl book (the book on the notation pre the implentation). Its somewhat ironic, orignally apl was supposed to make math notation more readable (it was originally just a math notation) but many people dont see it that way. if you are interested in super scripts and the like you might check out bqn and uiua which both are doing interesting things with the symbols. although uiua in particular suffers from having to choose from a set of symbols that comes from unicode and therefore sometimes look a little off to me
why218 commented on Klong: A Simple Array Language   t3x.org/klong/... · Posted by u/tosh
andoando · 2 months ago
I 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.

why218 · 2 months ago
I think there is literally nothing I could say that would change your mind. You've already decided what you think. There are a number of benefits but none that I could write out and have you someone who is uninterested immediately take my word for it and go home a fan. But I'll try to answer your (probably rhetorical) direct question. "How does the programming language limit your ability or speed of thinking". Again tell me how it is you do difficult math? Do you write out english or do you work with notation that makes it easier to feel and calculate your way through a problem. if you wanted to write a program in a new domain do you honestly think you would come to the same level of understanding of the topic at the same speed if you use assembly vs python. Yes the hard work is knowing what to implement; arrays languages help its users know what to implement. Ultimately, these are all just claims I can't prove to you what experiences you will or wont have if you learn the languages. You wont just believe and you shouldn't just believe me. If you are interested, learn more and try it out! (theres the apl and k wikis, a discord called the aplfarm a podcast called the arraycast etc.) If not just write array languages off and move on.
why218 commented on Klong: A Simple Array Language   t3x.org/klong/... · Posted by u/tosh
why218 · 2 months 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.

u/why218

KarmaCake day28June 20, 2025View Original