Subject: Re: [bug#65935] [PATCH] gnu: Add ngn-k.

From: Ludovic Courtès <[email-masked]>
Date: Mon, 20 Nov 2023 12:28:56 +0100

Hi!

"B. Wilson" <[email-masked]> skribis:

>> This package cannot be included in Guix because what we have above is
>> not source code: it’s deliberately obfuscated code, it’s not “the
>> preferred form of the work for making modifications to it” (as the GPL
>> puts it) in any way.
>> 
>> I hope that makes sense.
>
> I agree that it's super weird, but it's not obfuscated code. Rather, it's the
> famously terse Arthur Whitney style. The APL/J/K family of array-oriented
> languages all famously have implementations strongly influenced by Whitney, and
> ngn-k is just following in that tradition. Those with the relevant domain
> knowledge tend to agree that the code is pretty readable.

Not being familiar with APL & co., I lack domain knowledge.  However I
do know C, and things like this (from <https://codeberg.org/ngn/k.git>):

--8<---------------cut here---------------start------------->8---
#include"a.h" // ngn/k, (c) 2019-2023 ngn, GNU AGPLv3 - https://codeberg.org/ngn/k/raw/branch/master/LICENSE
I rnk(Ax/*0*/){X(RA(Iv=rnk(xx);P(v<0,v)i(xn,P(v-rnk(xa),-1))v+1)RmM(rnk(xy))RT_A(1)R_(0))}//-1 for mixed rank
I urnk(Ax/*0*/){X(RA(urnk(xx)+1)RmM(urnk(xy))RT_A(1)R_(0))}//assuming unirank
S L fG(OV*p,Nn,Lv)_(O G*a=p,q=v;P(v-q,NL)Ii=0,g=HD/SZ(*a),f=0;W(i<n&&!f,j(g,f|=a[i++]==q))i-=g;j(g,B(a[i]==q)i++)i<n?i:NL)
S L fH(OV*p,Nn,Lv)_(O H*a=p,q=v;P(v-q,NL)Ii=0,g=HD/SZ(*a),f=0;W(i<n&&!f,j(g,f|=a[i++]==q))i-=g;j(g,B(a[i]==q)i++)i<n?i:NL)
  L fI(OV*p,Nn,Lv)_(O I*a=p,q=v;P(v-q,NL)Ii=0,g=HD/SZ(*a),f=0;W(i<n&&!f,j(g,f|=a[i++]==q))i-=g;j(g,B(a[i]==q)i++)i<n?i:NL)
  L fL(OV*p,Nn,Lv)_(O L*a=p,q=v;P(v-q,NL)Ii=0,g=HD/SZ(*a),f=0;W(i<n&&!f,j(g,f|=a[i++]==q))i-=g;j(g,B(a[i]==q)i++)i<n?i:NL)
S A1(fN,Ay=_R(cn[tl]);x(xtt?y:rsz(xN,y)))
//S A1(fBN,Q(xtG)Gv=0;i(xn,v|=xg)P(!(v>> 7&1),x)Ay=aL(xn);Mx(i(xn,yl=xg<0?NL:xg))y)
//S A1(fHN,Q(xtH)Hv=0;i(xn,v|=xg)P(!(v>>15&1),x)Ay=aL(xn);Mx(i(xn,yl=xh<0?NL:xh))y)
//S A1(fIN,Q(xtI)Iv=0;i(xn,v|=xg)P(!(v>>31&1),x)Ay=aL(xn);Mx(i(xn,yl=xi<0?NL:xi))y)
S L t[256];
S X1(fndGx,RmMA(e1f(fndGx,x))Rzc(Lv=gl(x);az(v==(C)v?t[(UC)v]:NL))RE(fndGx(gZ(x)))R_(fN(x))
 RZC_E(Nm=xn;Ay=aL(m);Mx(S4(xw,i(m,yl=t[(UC)xc]),i(m,Hv=xh;yl=v==(C)v?t[(UC)v]:NL),i(m,Iv=xi;yl=v==(C)v?t[(UC)v]:NL),i(m,Lv=xl;yl=v==(C)v?t[(UC)v]:NL)))sqzZ(y)))
[...]
--8<---------------cut here---------------end--------------->8---

… I find it hard to believe they’re “readable” to anyone in the sense of
being the “preferred form” for modifications or even just studying it.
(Heck, even the Makefile has optional whitespace removed, as if trying
hard to make it unreadable!)

I don’t think we have a precedent here; I wouldn’t want to make a
decision based on a personal judgment, and I understand I know nothing
about the APL language family, but someone will have to clarify how
those 1.2K lines of C were written/generated.

I’d love to hear what others think!

Thanks,
Ludo’.