[HN Gopher] Zoo of array languages
___________________________________________________________________
Zoo of array languages
Author : mpweiher
Score : 138 points
Date : 2025-10-14 11:01 UTC (11 hours ago)
(HTM) web link (ktye.github.io)
(TXT) w3m dump (ktye.github.io)
| feraloink wrote:
| This is wonderful: APL is there! And a visual APL keyboard too.
| srean wrote:
| It's missing Nial I think.
| ludsan wrote:
| no uiua :(
| etatoby wrote:
| Came here to say the same thing. Uiua is my favorite language
| by far. BQN is also a cool "Nu-APL" but Uiua is just a full
| generation ahead.
| ofalkaed wrote:
| What makes Uiua a full generation ahead of BQN?
| evnu wrote:
| Uiua is the first one that made array languages "click" for me
| due to the formatter.
| gcanyon wrote:
| Array languages are such a mind twist and so fun. I dabbled in J
| at one point, and I love explaining
|
| +/%#
|
| to people. But the real expressive power comes when you start to
| get into tacit expressions yourself, understand function
| exponents, and "get" under.
|
| Hmmm... maybe I need a refresher...
| cess11 wrote:
| There's an APK, for dabbling on the phone at times when there's
| no larger computer available but still time to spend.
|
| https://code.jsoftware.com/wiki/Guides/JAndroid
| 1-more wrote:
| > I love explaining +/%#
|
| Based on the one thing I remember in APL I'm guessing the first
| two characters are "sum over some data structure" and the data
| structure is what the next two mean. What does it mean
| entirely?
| Romario77 wrote:
| avg=: +/ % #
|
| +/ sums the items of the array.
|
| # counts the number of items in the array.
|
| % divides the sum by the number of items.
| 1-more wrote:
| delightful, ty. How does it handle empty arrays? Throw?
| Average is zero? Average is infinity?
| bear8642 wrote:
| Average is zero empty =. 0$0 NB. zero
| length array +/empty 0 #empty
| 0 0%0 0
| 1-more wrote:
| Further validation for n / 0 = 0 in Elm and Pony and a
| couple other places! TYSM
| deepsun wrote:
| I'd call that code obfuscation. a.sum() /
| a.count()
|
| you would not need an explanation.
| JoshGG wrote:
| MATLAB is an array language.
| radiator wrote:
| it is one of their cousins
| ljosifov wrote:
| Yeah - IDK why it never makes it to these lists. R too. Matlab
| being 2D matrix first/default gets it right for me there. IK
| matrices trivially translate to arrays, still: find 2D to be
| extra expressive on human level, for zero price paid. I get it
| it's all the same to the cpu. 2D rows-columns rectangle of data
| being the simplest data structure both necessary and sufficient
| covering a 1) matrix 2) spreadsheet 3) SQL table 4) directed
| graph of nodes and edges. (in the past I've read someplace that
| lists are for pie eaters, but wouldn't know myself
| RodgerTheGreat wrote:
| MATLAB doesn't have a FOSS implementation that runs in a
| browser.
| bee_rider wrote:
| Octave covers all the Matlab functionality I need, not sure
| if it runs in a browser. I mean if you have the source code
| for something there must be _some_ way to get it to run in a
| browser these days, right?
| cobbal wrote:
| MATLAB doesn't even have 1-d arrays, it really is missing the
| principled and composable operations that make array languages
| useful
| OneDeuxTriSeiGo wrote:
| I believe the ArrayCast had this debate on whether it's
| considered an arraylang when they had some of the MATLAB devs
| on.
|
| The determination they came to was that MATLAB is an array
| lang but not an iversonian array lang.
| marcentusch wrote:
| This is cool. Wish there was more examples for jtye/k so I would
| have a better chance of learning to use it.
|
| Also missing Uiua.
| nathell wrote:
| Is this written by Arthur Whitney himself?
| thristian wrote:
| APL and K are still pretty daunting, but I've recently been
| dabbling in Lil[1], which is something like a cross between K and
| Lua. I can fall back on regular procedural code when I need to,
| but I appreciate being able to do things like:
| 127 * sin (range sample_rate)*2*pi*freq_hz/sample_rate
|
| This produces one second audio-clip of a "freq_hz" sine-wave, at
| the given sample-rate. The "range sample_rate" produces a list of
| integers from 0 to sample_rate, and all the other multiplications
| and divisions vectorise to apply to every item in the list. Even
| the "sin" operator transparently works on a list.
|
| It also took me a little while to get used to the operator
| precedence (always right-to-left, no matter what), but it does
| indeed make expressions (and the compiler) simpler. The other
| thing that impresses me is being able to say:
| maximum:if x > y x else y end
|
| ...without grouping symbols around the condition _or_ the
| statements. Well, I guess "end" is kind of a grouping symbol,
| but the language feels very clean and concise and fluent.
|
| [1]: https://beyondloom.com/decker/lil.html
| fainpul wrote:
| I assume this is the same as this? # python
| [127 * sin(x * tau * freq / samplerate) for x in
| range(samplerate)]
| thristian wrote:
| Pretty much, yeah! The difference is that in Python the
| function that calculates a single value looks like:
| foo(x)
|
| ...while the function that calculates a batch of values looks
| like: [foo(x) for x in somelist]
|
| Meanwhile in Lil (and I'd guess APL and K), the one function
| works in both situations.
|
| You can get some nice speed-ups in Python by pushing
| iteration into a list comprehension, because it's more
| specialised in the byte-code than a for loop. It's a lot
| easier in Lil, since it often Just Works.
| RodgerTheGreat wrote:
| A few more examples in K and Lil where pervasive implicit
| iteration is useful, and why their conforming behavior is
| not equivalent to a simple .map() or a flat comprehension:
| http://beyondloom.com/blog/conforming.html
| leephillips wrote:
| And in Julia it's foo.(x).
| zahlman wrote:
| For that matter, # python from numpy
| import sin, arange, pi 127 * sin(arange(samplerate) * 2
| * pi * freq / samplerate)
| Pompidou wrote:
| R is also an array language, but a non-iversonian one. Another
| good ressource for array languages is https://aplwiki.com/.
|
| r/apljk on reddit is also active.
| countrymile wrote:
| That's my understanding too. R never seems to make these lists.
| seanhunter wrote:
| At one time I briefly spent a bunch of time learning kdb/q. I
| remember one particular day when I wrote a non-trivial program
| and it worked first time. I was so shocked I thought I must have
| suffered some kind of brain aneurism or something.
| veridianCrest wrote:
| Array languages: where your first working program feels like a
| happy accident.
| OneDeuxTriSeiGo wrote:
| Programming in an array lang "should" generally feel like using
| a calculator.
|
| You are working in a REPL, starting with small expressions to
| verify they are roughly doing what you want and then composing
| them to build up until you can plug it all together and now
| have a formula you can plug into the calculator to plug and
| chug all the rest of your data.
|
| So in that sense yeah it does kind of replicate the magic of
| the first time you got a complex equation or BASIC program to
| run on your TI back in your school days.
| bee_rider wrote:
| Dumb question from an outsider: are array languages competitive
| with something like C or Fortran in their niche performance-wise?
| gopalv wrote:
| > are array languages competitive with something like C or
| Fortran
|
| The REPL is what matters - also while being performant.
|
| Someone asks you a question, you write something, you run it
| and say an answer, the next question is asked etc.
|
| I've seen these tools be invaluable in that model, over "write
| software, compile and run a thousand times" problems which
| C/Fortran lives in.
| graboid wrote:
| I assume that in most array languages, you also create "words" or
| however you want to call functions, to reuse code. I wonder about
| a purely aesthetic issue: how does it look to interleave those
| symbols with user-defined words that by nature will be much, much
| longer, i.e. "create-log-entry" or "calculate-estimated-revenue".
| tailrecursion wrote:
| I never did any real programming in APL, but I studied it over
| about 2 months. When you get used to the symbols, reading
| spelled-out words feels like reading in slow motion, or being
| stuck in molasses.
|
| Most (not all) APL code I've seen uses very short names, often
| one letter names, for function names. And APL programmers are
| famous for cataloging "idiom" which are short phrases for
| common subroutines. In other words, it's best practice to
| repeat 3- or 4- symbol phrases instead of defining a
| subroutine.
|
| Of course, there's nothing about an array language that
| requires using symbols; but for some reason most do.
| ofalkaed wrote:
| >Of course, there's nothing about an array language that
| requires using symbols; but for some reason most do.
|
| The idioms become words and you read them like words, you
| don't step through each letter of a word when you read it,
| you recognize the shape. The same thing happens in APL and
| its ilk, any commonly used sequence is instantly understood
| as its function without having to parse each individual
| symbol and what it does.
| tailrecursion wrote:
| Yes the symbols in a way are the letters of APL, and the
| phrases are the words.
| ofalkaed wrote:
| It depends on the language and the programmer.
|
| https://github.com/mlochbaum/BQN/blob/master/vm.bqn
___________________________________________________________________
(page generated 2025-10-14 23:00 UTC)