Where does this madness come from, and why does it infect proponents of array-based languages to the point where they start writing C code in this style!?
Where does this madness come from, and why does it infect proponents of array-based languages to the point where they start writing C code in this style!?
Some of my complaints: * true adherence to the source material requires one to dispense entirely with all but the tersest comments * it over-aggressively tunes away whitespace (if you code like this, it's quite beautiful when you align comparable values on the same column between adjacent rows) * many of the idioms rely on undefined behavior, which makes it very frustrating to maintain, port, and extend--to a lesser degree, it makes the code hard to follow, but usually (the most frustrating part of all!) is that the intent is _clear_, it's just that it doesn't work well with the C standard * it emphasizes the placement of as many statements as possible on a single line, which is jarring when those statements don't flow together; on the other hand, the style is quite nice when you allow yourself to place complete and related concepts together, since it's clear that you're "doing something else" on subsequent lines
I said this is "unfortunate" not because I have any problem with Arthur, but because I actually wish this was part of a richer tradition of C (which I've never been able to confirm and thus came to my conclusion about idol worship). Although I happily abide by them in my professional life, I am thoroughly frustrated with coding standards that dictate variable names be complete sentence and code limited to 80 lines. I would love to adopt a rigorous style _based on_ Arthur's, although I will concede that this will probably never happen because the aesthetic of this practice conflicts so completely with the contemporary zeitgeist.
Anyway--nobody has to like it, but some people really actually do like it and accomplish work with it.
Is that true?
Isn't this style just a natural place to arrive after agreeing with and understanding "Notation as a tool of thought"?
Also while learning J/K I didn't notice much of this worship.
I'm afraid of writing off a purposely chosen style as one that has no merits and is explained by idol worship.
I want to be clear that I think this style does indeed have merit, regardless of its origins. I like it--I prefer _reading_ and _comprehending_ code rather than superficially skimming code--I believe the style serves that goal wonderfully. I do not think that a thing adopted because of one's respect and adoration for an idol figure invalidates the value of the thing, _but_ I also think I spoke much too harshly and I recognize that people are allowed to like a thing and take it from another person without idolizing the creator.
However, I still believe the style originated with Arthur. Again, I don't think that's bad, and I agree with you that there is indeed some spirit of Iverson's work spread around different computing communities in the way they write C. Then again, _I_ did not have the presence of mind to spontaneously write Arthurian C without reading his code first and thinking really hard about it, so I am perhaps making the mistake that everyone else is similarly limited. I've tried to find independent exemplars of similar styles without success. Again, I write that down as a personal failing.
Some writings on this style:
One talk I saw by a proponent explained that the intention is that you often change just the trailing character (or 2 or 3) to "twiddle" a query until it does what you want.
That interactivity makes sense to me. I do similar things with query languages like KQL.
But... in C? It's compiled! You have to "run" it!
Not to mention that it makes no syntactical sense in C to be fiddling around with suffixes. It has nested brackets that need to be properly closed! It's procedural, not declarative, so even if you condense the syntax, you don't "win" that much in the end.
There is literally no way that anyone could ever justify using single character source file names. That's just absurd. Note that the author had to put a little table explaining what each single-character file does/contains.
WHY NOT JUST NAME THEM to match their function!?
So instead of this madness:
0.c syscalls and main()
m.c memory manager
p.c parser
k.h embedding api
a.h common header
g.h header generated by g.k
Just use words like a normal human: main.c
memory.c
parser.c
embedding.h
common.h
generated.hAre there people (other than the author) who look at this source code and read it fluently? There appear to be few clues as to the meaning, in terms of naming choices (of any identifiers), comments, formatting, etc.
ngn/k is certainly a lot of fun to use. I just wish it also worked on OS X (& plan9).
To start on MacOS, can apply this patch then run `make k-libc` on OSX 12.0.1 (M1 processor):
diff --git a/makefile b/makefile
index 5b08dde..1ba3c32 100644
--- a/makefile
+++ b/makefile
@@ -10,7 +10,7 @@ w:k o/w/fs.h o/w/k.wasm o/w/index.html $(patsubst w/x/%.k,o/w/x/%.k,$(wildcard w
h:w o/w/http;cd o/w;./http
k-dflt:; $(MAKE) a N=$@ R=k O='-O3 -march=native -nostdlib -ffreestanding' L=''
-k-libc:; $(MAKE) a N=$@ R=k O='-O3 -march=native -Dlibc' L='-lm' STRIP=true
+k-libc:; $(MAKE) a N=$@ R=k O='-O3 -Dlibc' L='-lm' STRIP=true
k-obsd:; $(MAKE) a N=$@ R=k O='-fPIC -Dlibc=1 -DSYS_getcwd=304 -Dstrchrnul=strchr' L='--static -fno-pie -lm -lc' STRIP=true
libk.so:;$(MAKE) a N=$@ R=$@ O='-O3 -march=native -nostdlib -ffreestanding -fPIC -Dshared' L='-shared' STRIP=true
o/$N/%.o:%.c *.h;$M;$(CC) @opts $O -o $@ -c $<
However, Apple platforms are not officially supported (or to put it more bluntly, "officially not supported"), and there are bugs such as this one[1]. I suspect it has to do with libc differences on Mac versus Linux. If you have experience with the libc differences between Linux and Mac, I'd welcome your input! I'm not an ngn/k developer, just interested in adding support for MacOS.This is how they roll in the k world. Imagine including k.h in an external application that wants to use some k functionality and the existing code uses the single char looping idiomatic code:
for (int k = 0; k < 100; k++) {}
'k' gets redefined and LOLs all around.