Live data from Hacker News

Origins of J

github.com

71–76 of 76 posts

Re: Origins of J

#71
post #31
post #28

Earlier quoted context omitted.

> 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 :)

How do we pick up that writing style.

> How do we pick up that writing style.

since the discussion here revolves around "intentionally obfuscated c", i'd like to recommend three sources which elucidate what obfuscated c is:

1. this is not how you want to write c. this is very bad news:

  #include 
  #include 

  int main() {
     int *p = (int*)malloc(sizeof(int));
     int *q = (int*)realloc(p,sizeof(int));
     *p = 1;
     *q = 2;
     if (p == q)
       printf("%d %d\n", *p, *q);
  }
2. what follows is five trivial questions about c. correct answer to all five is "i don't know". you don't even need to understand why that is, what you want instead is keep it simple. "Origins of J" from 1989 is infinitely more sane and approachable than any of these five:

https://wordsandbuttons.online/so_you_think_you_know_c.html

3. what amazes me is that no single person in this thread yet illuminated us with a staple wisecrack piece of general form "preprocessor is evil". so, let me do it: preprocessor and fancy macros are EVIL, and they are not your friends. if you don't know when to stop producing them, they will turn on you, and will become deadly.

this effect can be described in less sinister language, sunny side up. if you understand at least 30% of untold sorrow which happens below, you are 100% qualified to use preprocessor:

  //!\file adios.h

  //! first things first
  #define struct union
  #define if while
  #define else
  #define break        //!

Re: Origins of J

#73
post #68

Earlier quoted context omitted.

> inequality x!=y is not used at all, because it is two chars. instead, we test with x-y, which holds true when operands differ I think this is the line in the document that represents his coding style the most. Sacrificing legibility for plebs to save one character per comparison.

> represents his coding style the most i agree that atw’s inequality test is a bit cheeky, but like everything else it is a matter of habit. a convention. eventually you just begin to see what is subtraction and what is comparison. here’s another classic example of the same effect: x=x+1 makes perfect sense to everyone, right? wrong. to some, the right answer is “no, they are not”.

I am not saying it's bad. I kinda understand the motivation behind atw style in general. Modern code is written like prose:

    if (IsValidFile(fileName)) {
        var rawRecords = ReadFileAsRawRecordIterator(PreprocessFile(fileName), config);
        foreach (var rawRecord in rawRecords) {
            var record = ParseRawRecord(rawRecord, config);
            //and so on
        }
    }
But you have to trust the prose. At one point or another, you find a bug in some free software you haven't written yourself, open its source code and are met with ravioli code written in prose. And you cannot trust this prose because there is a bug in it. So you open this tiny method, the you open PreprocessFile, ReadFileAsRawRecordIterator, ParseRawRecord, the implementation of IRawRecordIterator, then a few more methods that these methods call themselves and try to thread the control flow through these methods, jumping from file to file. I can see how atw style code can help with that, especially after you retrain yourself to read it like math.

Re: Origins of J

#74
post #66

Earlier quoted context omitted.

As with a lot of things, some people may enjoy arduous and very low-yield process for all sorts of reasons. I, for example, like baking sourdough bread. As with the bread, which comes out more or less comparable quality to what I can buy from the local grocery in exchange for much less effort, I get certain satisfaction from doing it myself. But, if I had to do this on an industrial scale (and I worked in a bakery, a…

My impression has always been that it is mathematical notation that is indeed high-yield and low-effort. That’s why Fortran was/is successful.

Low-effort may be if you are writing with a pen on paper, or chalk on the board. It's anything but even with systems like LaTeX.

Just to put this in perspective: in the days of me being a student, I got a gig at the state hotel for official guests. They had a guest book and the honored guests would usually leave an autograph in it. They hired me to use calligraphy to write the name and the title of the guest. Usually, that meant two, sometimes one line with just two or three words each. So, let's say four words per page. I would do about ten pages per day (they had couple years of backlog).

My typical workload in the newspaper for a day was somewhere between 16 and 24 A3 pages (this includes everything from inputting the text into the system, editor editing it, proof-readers reading it and me running back and forth between the editor and proof-readers to convince the editor to find a different image / add or remove a paragraph etc. If memory serves, that's about under 1K words per page. So, 16K-24K words per day (compared to 40 words per day of calligraphy).

With the math textbook, we did about a page a day, and it was closer to A4, so, under 500 words. Also, of course, the formulas are just a small fraction of the algebra textbook: most of it is prose: proofs or some general discussion about the subject. Of course some diagrams (but that's comparable to the newspaper).

So, while not as bad as calligraphy, math textbook was at least two orders of magnitude harder than newspaper, and only an order of magnitude easier than calligraphy.

NB. Newspapers aren't the easiest job in terms of putting text on paper. It's actually quite involved and paginators are under quite a lot of pressure to finish things on time, especially for the daily papers. If you are looking for the lowest effort / highest yield, something like the War and People (or is the traditional English translation the War and Peace?) would be your best bet. You can do hundreds of pages per day, even with moderate amount of illustrations.

Re: Origins of J

#75
post #58

Earlier quoted context omitted.

> 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 rec…

I’m in the same boat. Outside of a professional setting atw style is the only way I write code. I find code easier to manage when I can see more of it at once. I like to use this style in JavaScript as well.

> I find code easier to manage when I can see more of it at once. I like to use this style in JavaScript as well.

How do you write with this style in JS?

Re: Origins of J

#76
post #58

Earlier quoted context omitted.

I’m in the same boat. Outside of a professional setting atw style is the only way I write code. I find code easier to manage when I can see more of it at once. I like to use this style in JavaScript as well.

> I find code easier to manage when I can see more of it at once. I like to use this style in JavaScript as well. How do you write with this style in JS?

D=document;E=“getElementById”; D[E](“myId”)
Post reply on HN