[HN Gopher] K: We need to talk about group
___________________________________________________________________
K: We need to talk about group
Author : chrispsn
Score : 60 points
Date : 2023-03-30 23:48 UTC (23 hours ago)
(HTM) web link (gist.github.com)
(TXT) w3m dump (gist.github.com)
| KrugerDunnings wrote:
| is there any way i can try this out?
| chrispsn wrote:
| Yep - added a link to some simple examples in the article
| (below). Throughout the article there are also a few links to
| executable versions of the code examples.
|
| https://ngn.codeberg.page/k/#eJxdjssKwjAQRffzFddVFyLFoiiFQD8...
| maximus-decimus wrote:
| ngn k : https://codeberg.org/ngn/k
|
| kona : https://github.com/kevinlawler/kona
|
| alto a javascript implementation even with a graphics library :
| https://github.com/JohnEarnest/ok
|
| edit : assuming you were talking about k and not freq
| semi-extrinsic wrote:
| Ah, look at that ngn k link. They even golf the file names of
| the source code of the interpreter itself :D
| yakubin wrote:
| OMG: <https://codeberg.org/ngn/k/src/branch/master/a.c>
|
| My maths notebook from high school looked like that. I'm
| having flashbacks. (At least in text files you can't cram 4
| lines of text into 1.)
| eggy wrote:
| Or you could try J. Another terse array language that uses
| ASCII symbols.
|
| https://www.jsoftware.com/#/
| nextaccountic wrote:
| What is group?
| geoah wrote:
| Some context would be really nice indeed.
| Jtsummers wrote:
| https://gist.github.com/chrispsn/3450fe6172a7cc441d0819379ed.
| .. <- Here you go, some context about what group is and does
| (or was and did, in this case) in the K language.
| chrispsn wrote:
| Good point - added a simple explanation in the article:
|
| Group tells you the places each element occurs in a list. It
| generates lists of indices.
| [deleted]
| ape4 wrote:
| The Linux /etc/group file was my first and incorrect thought.
| gdprrrr wrote:
| A group is a non-empty set and an operation that combines any
| two elements of the set to produce a third element of the set,
| in such a way that the operation is associative, an identity
| element exists and every element has an inverse. /s
| jpf0 wrote:
| Group is (was) a function in various array languages, including
| K, APL, BQN, J, and Shakti.
| msla wrote:
| Imagine what APL could do with a Haskell-style type system and
| enforced referential transparency.
|
| APL programmers want to say their language is mathematical
| notation, well, _make it_ mathematical notation.
| Gys wrote:
| https://en.wikipedia.org/wiki/K_(programming_language)
| sergiotapia wrote:
| That has to be the tersest language I have ever seen in my
| life. Code golf but it's actually a real language used heavily
| in finance.
| dan-robertson wrote:
| I think 'used heavily' is a bit of an overstatement.
|
| I think the right intuition for APL-family languages is that
| they mostly do numpy-like operations except their set of
| operations tend to compose very nicely. So the idea is that
| one can quickly and interactively figure out a composition of
| the operations which will do the calculation you want, but
| you don't have a complicated compiler and spend most of your
| time in the operators rather than the interpreted language,
| and the operators tend to make the cpu happy - they work on
| contiguous memory, tend to be vectorized, don't branch
| unpredictably, etc - so even if you have to compose many
| steps, you win on the time to write and the time to execute
| can be hard to beat because the constant factors of each
| individual operation are good.
|
| For obvious reasons, things like numpy, pandas, dplyr, etc
| are more popular as their syntax is a bit more readable and
| it is easier to get data in/out. I think they do lose a bit
| by not having lots of the useful compostable APL-style
| operators because those things don't have comprehensible
| names.
| idle_zealot wrote:
| These line-noise programming languages read like a cruel joke on
| engineers in the finance world.
| co_dh wrote:
| I am happily programming in a for 6 years now, and will not
| give it up
| pavlov wrote:
| It's awe-inspiring to see a K program where the comments are in
| another APL variant (I can't pretend to know which):
| {d:~1=':s:^x / s_e-1[?]>>[?](>[?]<)' '=x
| c:^"aeiou"?_x@&d&~s / c-!(s/x)[?]"aeiou"
| x,:,/$`pig`dog c / ins-c[?]["pig","dog"]
| x@<(+\d),{3}#c+2*!#c} / ((+`s+e)[?]3/c+2x|[?]c) [?][?][?]
| x[?]ins
|
| This program implements a Pigdog Latin translator, _bien sur_.
| tempaway45722 wrote:
| k
| semi-extrinsic wrote:
| Isn't the original APL the only lang that uses actual Unicode
| symbols for operators?
| pavlov wrote:
| There's also at least BQN, which I suspect is the language
| used in those comments:
|
| https://mlochbaum.github.io/BQN/
| chrispsn wrote:
| Yep, the comments are the BQN version.
| remexre wrote:
| Agda does too! https://plfa.github.io/ for examples
| thechao wrote:
| Fortress.
| Jasper_ wrote:
| APL _predates_ Unicode! You used to have to use special APL
| keyboards to write it. The symbols were included in Unicode
| as a way to try and make APL more palatable.
| dan-robertson wrote:
| Raku (fka perl6) has some, eg you can use <atom emoji>+= to
| atomically increment a value.
| jlg23 wrote:
| APL predates the first documented thoughts (not
| specification/implementation) of unicode by roughly 20 years.
| mostlylurks wrote:
| Haskell allows defining unicode operators, and has an
| extension that allows you to use unicode symbols instead of
| ascii sequences in various parts of the syntax.
| ksherlock wrote:
| There are esoteric code golf languages that use unicode. MPW
| (shell, assembler) used extended characters (MacRoman, not
| unicode but then again, APL also predates unicode) for some
| operations.
|
| eg, instead of "echo yo >> file" you would "echo yo >= file"
| warent wrote:
| this looks like some compiled program's binary viewed as
| unicode WTF
| krick wrote:
| Amazingly, APL is more readable. Actually, it's even pretty
| intuitive. Which proves again, that restricting code to ASCII
| when every competent programmer (and PC-user in general) can
| enter almost any unicode symbols just fine is simply stupid.
| qsort wrote:
| I... just can't. I work a lot with data, so it sounds like it
| should be a good fit for what I do, but I find that writing the
| damn code in a normal language is much more productive. Maybe
| it's my brain that's wired wrong, but I fail to see how the
| entire construction is supposed to help.
| mandevil wrote:
| A friend worked on a project in 2005 that had lots of K code
| in production. They had a contract with Kx Systems and Arthur
| Whitney in particular because, in my friend's opinion, only
| Whitney could really understand K code well enough to debug
| it. Friend's description was it took my friend two days just
| to comment the code into something grokkable by a normal
| developer, whereas AW didn't need to do that. Of course, it
| took Whitney those same two days of staring at the code
| before he said "Oh, of course, how silly of me." and found
| the bug and all resolved.
|
| Part of those two days of commenting was that since K is
| interpreted all of the developers would hand-obfuscate all of
| the code so that the variables were a, b, c, etc. so that
| they would be slightly faster to parse than a multi-character
| string. This sort of thing is done all the time now, with JS
| to make it load faster, but his team at least didn't have any
| scripts to automatically turn developer-friendly code into
| interpreter-friendly code, they worked with the interpreter-
| friendly code version.
| ldayley wrote:
| For context: This is regarding the function of "group" as it is
| implemented in the K array-oriented programming language (dialect
| of APL).
___________________________________________________________________
(page generated 2023-03-31 23:01 UTC)