Live data from Hacker News

Arthur Whitney releases an open-source subset of K with MIT license

shakti.com

51–60 of 234 posts

Re: Arthur Whitney releases an open-source subset of K with MIT license

#51
post #9

Earlier quoted context omitted.

Does writing in this way has any advantage in practical terms (not aesthetically reasons)?

The only possible advantage I can think of is that you can fit more code on one screen so I guess in theory you can see your context more easily. But that seems pretty minor compared to... well, look at it! I read a couple of other threads and some people try to claim less code = fewer bugs, but that's pretty clearly nonsense otherwise minifiers would magically fix bugs. As for why people actually use this (it seems…

It's not that any method of reducing code length fixes bugs, it's just happens that optimizing code to be read and worked on by domain experts leads one toward patterns that secondarily end up manifesting as terse expressions. The terseness is certainly shocking if you're not accustomed to it, but it's really not a terminal goal, just a necessary outcome.

The disbelief on first encounter is totally reasonable, but from personal experience, once you've gotten past that and invested the time to really grok the array language paradigms, code like this Whitney style actually ends up feeling more readable than whatever features our current SE culture deems Good and Proper.

There are a whole lot of moving parts to the why and how of these ergonomics, so I don't expect to be able to convince anyone in a simple, short comment, but if you're at all interested and able to suspend disbelief a little bit, it's worth watching some of Aaron Hsu's talks to get more of a taste.

Re: Arthur Whitney releases an open-source subset of K with MIT license

#52

The website reads like an edgy script-kiddy blog. Is K actually a useful project, or is it just a passion project of someone who happens to be sort of famous?

> The website reads like an edgy script-kiddy blog.

The code does, as well. Either Mr. Whitney's brain is not wired like a regular homo sapiens sapiens, or the entire thing smells of "I am smarted than you and I don't need to lower myself to your level."

I do not buy for a single second that for Mr. Whitney debugging IOCCC-level obfuscated code is easier than plain C code. One writes "normal code" because one will have to read it later, and they don't want to spend ages doing so, unless they have to keep an air of superiority about their abilities to their peers.

I get that APL is obtuse and dense. But writing obtuse and dense C doesn't turn it into APL.

Re: Arthur Whitney releases an open-source subset of K with MIT license

#53
post #35

Is this line in a.c enough for MIT license? //k(c)2024 arthur whitney(l)MIT

nice to see an exuberantly verbose arthur

The loquaciousness brings two Calvin Coolidge anecdotes to mind, the punchlines to which are: "you lose" and "with the same hen?"

Re: Arthur Whitney releases an open-source subset of K with MIT license

#54
Interesting things in here.

  #define _(e) ({e;})
  //!
I didn't know that corner of C. Removing the () from the macro does change what you can pass as e, and assigning the result of a block does work as one would expect.

edit:

-Wpedantic on gcc will tell me ISO C doesn't like the construct but it still compiles it happily.

Clang offers -Wgnu-statement-expression-from-macro-expansion

So it looks likely that this is the GNU statement expression extension after all and not a part of C. Shame.

Re: Arthur Whitney releases an open-source subset of K with MIT license

#55
post #21
post #15

Earlier quoted context omitted.

That's the "Whitney style". See: https://code.jsoftware.com/wiki/Essays/Incunabulum It's writing C in array-language style rather than intentional obfuscation.

Thanks. I'm now reading this where people are trying to explain what happened in the ref/ directory. https://github.com/kparc/ksimple/blob/main/a.c

Thanks for that link. The comments there help a lot. If I understand them, this is a minimal implementation of K with a lot of limitations, such as:

"the only supported atom/vector type is 8bit integer, so beware of overflows"

Still, it's fascinating how an interpreter can be written with such a small amount of code.

Re: Arthur Whitney releases an open-source subset of K with MIT license

#56
post #9

Earlier quoted context omitted.

Does writing in this way has any advantage in practical terms (not aesthetically reasons)?

I've heard it said that it becomes easy to spot common patterns and structures in this style. Without knowing the idioms it's difficult to read but apparently once you know the idioms, you can scan it and understand it well.

It is for APL/k/j; you see patterns popping up in very dense code which does a lot, which does make it readable really once used to it. But most people never get to that point (or even ever look at APL of course).

Re: Arthur Whitney releases an open-source subset of K with MIT license

#57
post #41
post #36

Earlier quoted context omitted.

I recommend checking out more of the APL family language family and the history of the notation, highly interesting. Almost like a parallel universe of computing, when you look past the syntax.

Yes, but C isn't APL. I don't buy it that this how it was written from day 1. Occam's razor and all, this is obfuscated C, not code written by an alien superintelligence.

haven't you ever written code with single letter variable names and it makes sense to you? and then been forced to read somebody else's code with single character variable names and found it completely inscrutable? this is just that on (a lot of) steroids

Re: Arthur Whitney releases an open-source subset of K with MIT license

#58
post #48

Can someone explain how it can be "faster" than anything else?

My money is on "it's not, and the benchmarks are cherry picked" I mean faster at filtering data than a python script? Sure. Faster than a database or hand-rolled C code? Only if your benchmarks are misleading.

Not for all cases, but he (and his team) take the time to squeeze performance out of things where others just say 'it's fast enough'. There was a monh+ long conversation why all most used json parsers are so terribly slow etc. Not many people take the time to try to optimise the last drop of blood out of everything, especially if you have shareholders or deadlines; you settle for 'good enough'.

Re: Arthur Whitney releases an open-source subset of K with MIT license

#59

He showed K @ Royal Society & bunch of apl & aplus guys were there. Someone asked , where are the comments? AW said comments get out of date with all the changes, if you can’t read the code you Shldnt be working on it. We then all looked at each other..

> if you can’t read the code you Shldnt be working on it

I don't know this AW guy, but to me that's a huge red flag and a sign that a programmer hasn't worked on anything substantial. Ie non-trivial stuff that's maintained by a team over time.

Being able to read the code is irrelevant, as the comments should tell you why the code is doing what it's doing.

For example, yeah I trivially can see the code is doing a retry loop trying to create a file with the same name.

That looks like a bug, if you can't create the file with that name, you change the name in the retry loop.

But the comment will tell me this is due to certain virus scanners doing dumb stuff, so we might have to try the same name a few times.

Sure, good code will have few comments as most of it should be self-documenting through good structure and names of classes and variables. But in non-trivial code there will always be places where it is not obvious why the code does what it does.

Re: Arthur Whitney releases an open-source subset of K with MIT license

#60
Is there some application that demonstrates the utility of this language?

E.g. it's tempting to dismiss Haskell as something invented by mathematicians more concerned with the elegance of their abstractions than actually getting things done, but Pandoc is so undeniably good and useful that you're forced to admit Haskell can be a good choice. What's the Pandoc of K?

Post reply on HN