[HN Gopher] Origins of J
       ___________________________________________________________________
        
       Origins of J
        
       Author : tosh
       Score  : 104 points
       Date   : 2024-01-04 13:15 UTC (9 hours ago)
        
 (HTM) web link (github.com)
 (TXT) w3m dump (github.com)
        
       | kstrauser wrote:
       | "...and that's why we have code formatters."
       | 
       | That's neat and impressive. I'm glad I'm not required to read or
       | understand it.
        
         | rbonvall wrote:
         | Once I put the effort to understand code like this and it
         | turned out it's straightforward once you learn the conventions:
         | 
         | https://news.ycombinator.com/item?id=19421524
        
         | gfv wrote:
         | It really doesn't help that it's written in ancient K&R C, but
         | if you spend ten or so minutes just staring at it, familiar
         | shapes and patterns start to appear. (Give it a try!)
         | 
         | Incidentally, it's in line with how APL code looks like an
         | alien artifact at first, but you get used to it fast if you
         | have spatial reasoning to wrap your head around reshaping and
         | transposing.
        
           | hackernoteng wrote:
           | If you focus on the middle and move your head back and forth
           | eventually you see a 3D image of Dykstra pop out and he
           | doesn't look happy at all.
        
           | kelas wrote:
           | porting from k&r to iso is super easy. fun, too.
        
       | JaumeGreen wrote:
       | Talked about this in other times (through other links):
       | 
       | * https://news.ycombinator.com/item?id=8533843 [2014]
       | 
       | * https://news.ycombinator.com/item?id=28491562 [2021]
       | 
       | * https://news.ycombinator.com/item?id=25902615 [2021]
       | 
       | * https://news.ycombinator.com/item?id=34050715 [2022]
       | 
       | A commentary about the code
       | https://news.ycombinator.com/item?id=22831931 [2020]
        
       | mihaic wrote:
       | I was expecting the story of the letter J, that Indiana Jones and
       | the Holy Grail has taught me had appeared only in the 15th
       | century as a letter separate than "I".
        
         | olestr wrote:
         | And I was expecting the Outlook J smiley. Been a while since
         | I've seen it in the wild now.
         | 
         | https://superuser.com/questions/1181497/text-smiley-faces-sh...
        
         | kingwill101 wrote:
         | I had the same thought . Maybe the title should be updated to
         | better reflect this
        
       | zengid wrote:
       | Obligatory posting of Bryan Cantrill's interview with Arthur
       | Whitney https://queue.acm.org/detail.cfm?id=1531242
        
         | bcantrill wrote:
         | The full audio of that was recorded but was never released --
         | this is reminding me that I should loop back with ACM to see if
         | they still have it and can release it. In particular, I want to
         | see how long the pause when Arthur responded to my question
         | "What do you think the analog for software is?": I won't give
         | away his answer, but it more or less detonated my brain -- and
         | it took me what felt like minutes (but was surely only
         | seconds?) to put myself back together and ask a follow-up.
        
           | 082349872349872 wrote:
           | I agree with Arthur's answer, but unfortunately it runs afoul
           | of Conway's Law: auteurs have a voice* and are capable of
           | producing software in that style, but large organisations? By
           | necessity, they must produce something qualitatively
           | different, that anyone can slot anything into anywhere,
           | optimised for superficial comprehensibility over elegance.
           | 
           | * sometimes small groups? Doug McIlroy said he was lucky to
           | have managed a software group whose members would sit around
           | in the lunch room and brainstorm (reminiscent of the Little
           | Prince?) not what they could add, but what they could remove.
           | 
           | << Par ma foi, il y a plus de quarante ans que je dis de la
           | prose sans que j'en susse rien, et je vous suis le plus
           | oblige du monde de m'avoir appris cela. >> --JBP
        
       | hackernoteng wrote:
       | Arthur Whitney is a mad genius. We were an early customer of KX
       | systems and I programmed with KDB for a few years. Arthur Whitney
       | once sat at my desk and helped me debug my code. Very nice guy.
       | Super smart and hilariously knowledgeable about the low level
       | performance of chips, caches, etc. Ask him how many nanoseconds
       | it takes to divide an array of doubles by an array of ints, and
       | he knows. He just knows.
        
         | 7thaccount wrote:
         | This kind of story is what I enjoy so much about HN. I wish
         | Kdb+ or Shakti had dramatically lower costs for those
         | industries that don't have access to banking cash. I know open
         | source versions exist, but I understand them to mostly be toys
         | and not really production worthy.
        
           | DrDroop wrote:
           | K is at the end of the day a fancy calculator, I think for
           | most workloads you can use the open source version called
           | ngn/k
        
             | avmich wrote:
             | This - https://github.com/JohnEarnest/ok - can also be used
             | sometimes...
        
             | anotherjhacker wrote:
             | Sure, a fancy calculator that supports rather efficient
             | execution on ridiculously large machine farms. What some
             | people might call the implementation language for a
             | database engine.
        
             | kelas wrote:
             | > k is a fancy calculator
             | 
             | [put your favorite Java here] is also a fancy calculator by
             | the virtue of Turing completeness. what's your point?
        
           | eismcc wrote:
           | KlongPy sits on NumPy so gets pretty far. For some features,
           | it's still early days.
           | 
           | Http://klongpy.org
        
           | RyanHamilton wrote:
           | As the author of an open source version
           | (https://www.timestored.com/jq/) I wish the same but I fear
           | the time has passed. Two factors:
           | 
           | 1. The other technologies are evolving to take parts of kdb+
           | that made it special quicker than kdb+ is evolving. See arrow
           | / parquet / numpy / kafka, they each solve parts but kdb+ had
           | them all 10 years ago in <2MB.
           | 
           | 2. The ratio of learners to advanced programmers has
           | increased every year for the last 20 years. The languages
           | that have gained popularity in that time range are those with
           | the easiest learning curve. Most beginners no longer want to
           | sit with a book frustrated on 2 characters for half a day.
        
             | tangentstorm wrote:
             | Oh, interesting! I heard other array programmers talking
             | about jq, and (having not seen your website) went off to
             | study the json transformation language, which is also kind
             | of cool, but nothing to do with kdb or q. :)
        
             | bigbillheck wrote:
             | > Most beginners no longer want
             | 
             | Most beginners never wanted that.
        
         | kelas wrote:
         | (author of the modern port here)
         | 
         | > Arthur Whitney is a mad genius
         | 
         | atw is atw :) our old man is awesome. a bit grumpy at times,
         | but then who isn't :)
        
       | countWSS wrote:
       | The code in C that suppose to be written like this is usually
       | never written first like that, its like pretending writing
       | minified js by hand from scratch. Usually the code is contracted
       | and "minified" from large program to fit entire program into 1-3
       | screens, the person who manually "minified" it to that state will
       | know its expansion but other people will dismiss it as obfuscated
       | C, its an old technique to fit lots of code into 80x25 type
       | terminal. Not surprising since J is optimized for code density
       | per screen.
        
         | clausecker wrote:
         | Nope, Whitney just codes like this.
        
         | colonwqbang wrote:
         | > Not surprising since J is optimized for code density per
         | screen.
         | 
         | I don't think that's the whole story. J is dense like
         | traditional mathematical notation, but can be executed by
         | machine. Experienced J programmers use it to convey
         | mathematical ideas. See for instance:
         | 
         | https://www.jsoftware.com/jwiki/Puzzles/Unit_Fraction_Sum
         | 
         | Although I can't read the notation, I appreciate the role it
         | can play. Plain C (or whatever) code isn't an efficient vehicle
         | for ideas like that. Numpy/matlab comes closer but J is a
         | stronger approximation of traditional maths notation.
        
           | crabbone wrote:
           | I like J. Especially because it has a saner way to write it
           | (it doesn't have to look like as if you accidentally forgot a
           | null terminator in C strings, all the traditionally short
           | identifiers have a long and understandable form).
           | 
           | I feel like it's very regrettable that the superficial aspect
           | of J (the very hard to read syntax) is standing in the way of
           | some very nice ideas.
           | 
           | To comment on mathematical notation. Before I was a
           | programmer, I was a typographer. During my study in art
           | academy, I invented a bunch of fonts, one of my long time
           | projects was to make Hebrew look more like Latin fonts for
           | example (this is a long-standing issue in Hebrew typography,
           | with several historical attempts, but still not quite
           | resolved). Afterwards I worked in a printing house, paginated
           | a newspaper, typeset a bunch of books etc.
           | 
           | Among my coworkers (esp. in the newspaper) I was sort of
           | known for trying to automate stuff, so, I was often suggested
           | as a candidate for "difficult" typographical tasks, like
           | setting sports tables, chess diagrams, music sheets and the
           | most damned and hated kind of typographical work: math
           | formulas.
           | 
           | I've helped publish a course book on linear algebra for a
           | university. It was a multi-year project which I joined in the
           | middle. I have never seen so much pain, struggle and
           | reluctance as I've encountered while working on this thing.
           | People tasked with proofreading demanded extra pay for proof-
           | reading this stuff, and still wouldn't do it. Just put it
           | away and later explain that they had other things to do. The
           | lady who had to translate the mostly hand-written, or
           | sometimes typed on a typewriter manuscript would just skip
           | work on the days she was supposed to input the manuscript
           | into our digital system.
           | 
           | Everyone passionately wanted this project to burn in hell.
           | And the reason for this was the mathematical notation.
           | Typical proofreading techniques don't work on math formulas.
           | The text is impenetrable to anyone, often even to the people
           | who wrote it, including both the author and the editor.
           | Parenthesis are a curse, because in the manuscript they are
           | one of the elements that is most commonly forgotten or
           | misplaced. Single-letter variables are the other one.
           | Overloading the same symbols with different meaning is yet
           | another one. It gets worse when the same symbol is used in
           | its normal size, subscript and superscript.
           | 
           | ----
           | 
           | When I talked about my experiences to people with degrees in
           | math, they way they tend to respond to this is by saying that
           | "math is overall so hard, that mathematicians don't typically
           | notice the extra struggle they incur on themselves by the bad
           | language choices, it pales in comparison to the difficulty of
           | the main problem they need to solve".
           | 
           | And, I kind of can see it... on the other hand, I see no
           | reason _the students_ have to endure the same torture. They
           | aren't solving any novel mathematical problems. Their task is
           | usually reading-comprehension combined with memorization.
           | 
           | And then I saw Sussman book where he uses Scheme to write
           | math formulas (I think it was about physics, but it still
           | used a lot of math). Dear lord, it was so immeasurably better
           | than the traditional mathematical notation. I really wish
           | more people joined this movement of ditching the mathematical
           | notation in favor of something more regular and typography-
           | friendly as Scheme...
        
         | andrewla wrote:
         | While there are people that do this, I do not think that
         | Whitney is one of them. This code is not obfuscated; it uses
         | macros and strategically defined functions to allow writing
         | code in a style similar to APL that appears natural (-ish?) to
         | someone fluent in that programming style.
        
           | kelas wrote:
           | > not obfuscated
           | 
           | absolutely not. porting it to ISO C was a very fun and smooth
           | ride, also added two adverbs atw forgot to add in 1989 (see
           | over/scan) and a header file with some handy accesssors (atw
           | usually does that, but he was lazy that day)
           | 
           | > to someone fluent in that programming style
           | 
           | what people often don't realize is just how fast one can pick
           | up atwc style, and how hard it is to ever go back :)
        
             | max_ wrote:
             | How do we pick up that writing style.
        
               | kelas wrote:
               | One possible way is to look at a header file i once gave
               | to a 13yo girl. ever since she says she has no idea why
               | people write tall c:
               | 
               | https://github.com/aaalt/altc
        
               | moonchild wrote:
               | learn apl (k and j count)
        
             | bytelane wrote:
             | > what people often don't realize is just how fast one can
             | pick up atwc style, and how hard it is to ever go back :)
             | 
             | For my own amusement I tried this a couple months ago and I
             | 100% agree. I found my code to be more engaging to develop
             | and understand (function names encoded into 3 chars,
             | structure names encoded into 4 chars, primitive types are a
             | capital letter, etc).
             | 
             | It is like a game you play with your brain to recall how
             | your code works. And, it reminded me about studying 6809
             | assembly in college, where it was easy to memorize every
             | instruction mnemonic and what it meant.
             | 
             | I just don't know if I would show it to someone at work,
             | but for my own prototypes and experiments, I like it.
        
         | kelas wrote:
         | > The code in C that suppose to be written like this is usually
         | never written first like that
         | 
         | usually not. but we prefer to write it first this exact way,
         | and there are good reasons for rhat.
         | 
         | > obfuscated c
         | 
         | it is not. this style is extremely regular, very readable and
         | writable, and escapes a whole galaxy of typical C blunders. i
         | can expand on that if you wish.
        
           | hnfong wrote:
           | Please do. Although I'll probably never write C in that
           | style, most of us here will probably learn a few things that
           | will eventually prove useful. (And it probably will also
           | serve as a historical document of a "skill"(?) that is
           | apparently soon to be lost to obscurity...)
        
             | kelas wrote:
             | > please do
             | 
             | now that i think of it, i already did just that once, only
             | forgot. getting old sucks, and also forgetting things is a
             | great skill i learned from atw. as he likes to say, "kelas,
             | ignorance is bliss". Here you go - all you ever need to
             | know about how to read and write atwc:
             | 
             | https://github.com/kparc/bcc/blob/master/d/sidenotes.md#sty
             | l...
        
             | kelas wrote:
             | > soon to be lost to obscurity
             | 
             | well, about that i'm just not so sure.
             | 
             | as we like to say, "skill", for whatever reason you chose
             | to use quotes, cannot be easily bought on a Turkish fish
             | market.
             | 
             | there are people out there who write atwc, and they are not
             | atw. the following 40 lines of c are written strictly
             | arthur-style, and are occasionally very useful. in the faq
             | section of the readme there is an answer to a popular
             | question "why is it written this way, and how to learn to
             | write software this way".
             | 
             | https://github.com/kparc/pf
        
           | n0pa1n wrote:
           | > it is not. this style is extremely regular, very readable
           | and writable, and escapes a whole galaxy of typical C
           | blunders. i can expand on that if you wish.
           | 
           | Please do! I'd like to learn. If you can expand on this in
           | the README section as well that would be great.
        
             | kelas wrote:
             | > README
             | 
             | good idea, why not
             | 
             | for a more throw-me-in-the-water introduction, here are my
             | notes on another famous public domain release from atw.
             | some remarks are specific to the codebase, but essentially
             | it is a general introduction to atwc:
             | 
             | https://github.com/kparc/bcc/blob/master/d/sidenotes.md
             | 
             | and here's a less involved way to get lit:
             | 
             | https://github.com/aaalt/altc
        
       | tangentstorm wrote:
       | Nice to see this getting some attention again. I hope some people
       | venture out to learn about the actual J language:
       | 
       | https://code.jsoftware.com/wiki/Guides/GettingStarted
       | 
       | For what it's worth, I've also studied this code a bit. This repo
       | has an annotated and (somewhat) reformatted version of the code:
       | 
       | https://github.com/tangentstorm/j-incunabulum
        
       ___________________________________________________________________
       (page generated 2024-01-04 23:00 UTC)