by comex · 13y ago · 0 comments
static F1(jtthn){A d,t,z;C*tv,*x,*y,*zv;I c,*dv,k,m,n,p,r,*s,wd;VF fmt;
n=AN(w); r=AR(w); s=AS(w);
thcase(AT(w),&wd,&fmt);
GA(t,LIT,wd*(1+n),1,0); tv=CAV(t);
if(1>=r){p=thv(w,AN(t),tv); ASSERTSYS(p,"thn"); AN(t)=*AS(t)=p; z=t;}
else{
c=s[r-1]; m=n/c; k=bp(AT(w));
y=tv-wd; x=CAV(w)-k;
The function is in a file conveniently called "f.c", and I cannot find any explanation for the abbreviation "jtthn" nearby. It seems to be a prefix to "thn". "thn" does not appear to be defined anywhere in the J documentation. Maybe it's a combination of letters that would make sense to a J expert?Now, if the reason for this is to save typing, fine. If it's the best way for the people who are working on the compiler to work (no pesky time spent writing comments), and they don't care whether anyone else understands, fine. I don't think that code authors have any particular responsibility to make their work understandable or modifiable by others, if they don't want to.
But the idea that this provides a reasonable barrier to entry, as suggested in the article, that learning how the code works is a reasonable rite of initiation because only the initiated need bother modifying the code, is simply arrogant. Yes, once code gets very verbose, adding further verbosity and explanation is putting lipstick on a pig - it won't help someone who doesn't understand understand, and it's no use to someone who does. But this code is nowhere near that point, I suspect even for someone who knows J. I am capable of understanding how a compiler works, but if I were ever called upon to debug this one, the code would make me waste my time understanding its idiosyncrasies before I could get to the meat of things.
The format is at best a necessary (useful?) evil, not something to celebrate. A few longer names or comments would go a long way.
The real question is whether there is enough discipline and regularity in the structure and idioms for someone to pick them up quickly. To me, that is the ultimate measure of comprehensibility. There are plenty of codebases with good naming that remain incomprehensible because they randomly violate the reader's expectations. I really think that internal consistency around a small number of concepts is ultimately more important to ease of learning than anything else.
Look at this C code as a DSL, but one that you just don't have a crib sheet for. And, yes, that is a problem but it is definitely not the worst problem you can have.
But maybe I'm just saying that because I'm better at code than mathematics?
That said, I do remember seeing mathematicians calling for a better math notation that emphasises readability and longer variable names. I'm not so sure it'll happen though. I prefer to simply avoid having them write code others have to maintain.
It's not better or worse, it's just different.
Or correctness, sadly.