Live data from Hacker News

K/simple: a tiny K interpreter for educational purposes by Arthur Whitney

github.com

11–20 of 93 posts

Re: K/simple: a tiny K interpreter for educational purposes by Arthur Whitney

#11
post #7

Earlier quoted context omitted.

I'm guessing it's his initials; Arthur T. Whitney or perhaps ArThur Whitney, and possibly his account name.

Sounds right. Additional examples at https://github.com/louyx/aplus/blob/master/src/a/k.h https://code.jsoftware.com/wiki/Essays/Incunabulum How would you characterize that? Heavy use of the C preprocessor and C defaults to embed a functional programming language. Language with a small number of core functions and ability to apply functions to lists of atoms. Aesthetically favoring short identifiers and minimal white…

You know how when you first start learning to code, the kids who really "get it" right away start off thinking shorter code = smarter code = better code?

k always seemed like a bunch of those kids managed to become highly accomplished and brilliant engineers without ever breaking that terrible habit. Is there actually a reason to write these array languages (and interpreters for them, apparently) this way, or is it just a cultural difference?

Re: K/simple: a tiny K interpreter for educational purposes by Arthur Whitney

#13
post #2

I was surprised at how verbose and commented the code was. Then I read the note saying that Whitney's original code was in `ref/` and the two files in the root were annotated by other kparc members.

Ah, thank you for clarifying this. I was confused why it said "by Arthur Whitney" when the contributors do not seem to be Arthur Whitney.

"contributors" is essentially me. what needs to be clarified?

it is by arthur whitney.

anything else?

Re: K/simple: a tiny K interpreter for educational purposes by Arthur Whitney

#15
post #2

I was surprised at how verbose and commented the code was. Then I read the note saying that Whitney's original code was in `ref/` and the two files in the root were annotated by other kparc members.

Whitney is an unrealized IOCCC champion.

> Whitney is an unrealized IOCCC champion.

no, that'd be fabrice bellard, who is actually a "realized" ioccc champ.

atw doesn't do obfuscated c. you are led astray.

Re: K/simple: a tiny K interpreter for educational purposes by Arthur Whitney

#16
post #11

Earlier quoted context omitted.

Sounds right. Additional examples at https://github.com/louyx/aplus/blob/master/src/a/k.h https://code.jsoftware.com/wiki/Essays/Incunabulum How would you characterize that? Heavy use of the C preprocessor and C defaults to embed a functional programming language. Language with a small number of core functions and ability to apply functions to lists of atoms. Aesthetically favoring short identifiers and minimal white…

You know how when you first start learning to code, the kids who really "get it" right away start off thinking shorter code = smarter code = better code? k always seemed like a bunch of those kids managed to become highly accomplished and brilliant engineers without ever breaking that terrible habit. Is there actually a reason to write these array languages (and interpreters for them, apparently) this way, or is it j…

less code less bug

Re: K/simple: a tiny K interpreter for educational purposes by Arthur Whitney

#18
I have a longstanding fascination with K and other "modern" APL derivatives.

There are a few intersecting truisms about coding that I believe: one is that people's working memory varies: some have an immense amount, some less. Humans definitely process spatially better than in time series (e.g. comparing side by side rather than turning over a page.)

This implies you should prefer succinct code and languages because they are less memory load for engineers working on them.

At the same time, a corollary is that a smaller standard library / language is generally better, in that less needs to be learned by an engineer for full coverage of the language.

Another truism is that some people's processing speed is higher than others, and in general I think of the combination of working memory + speed as roughly equivalent to "g", general intelligence.

K occupies this weirdo place though, because it's absolutely succinct, a very small language as counted by number of atoms supported by the interpreter, and also incredibly hard to scan.

One of the K intros I read mentioned that the language is designed to be something that takes down your thinking; essentially the idea is that the workflow is "drink coffee with fellow PhDs, annotate on the chalkboard, and then when ready, capture it directly." This seems about right to me with my own K/J/Q experiences -- the bulk of the time is spent thinking about structuring a problem solution.

I compare this to go, a language I love for its long-term readability and maintainability, where I spend a lot of time writing boilerplate and dealing with errors in-situ.

At any rate, somehow there's a sort of event horizon of terse solution making where you come out the other side and need a 170 IQ to feel comfortable, and Mr. Whitney lives where he lives, and I live where I live. :)

People complaining about how ugly the C code is here are definitely missing the point: he has bent C's preprocessor to his will in order to encapsulate how he thinks about coding: essentially functional, vectorized. It's using C to write a DSL for solving programming problems interesting to Arthur Whitney.

I think it's fascinating on those terms. In a world where you have to read 10,000 lines of code from 100 developers, the C is terrible, and hard to parse. In a world where you will mostly write code to a style you've honed over 40+ years, it's super expressive, minimal, pared down to what matters, and probably fits his brain perfectly.

Re: K/simple: a tiny K interpreter for educational purposes by Arthur Whitney

#20

[flagged]

Ha! The guy who wrote this is the same guy who invented ~~APL~~ a number of APL inspired languages (Edit: He did not invent APL. Thanks for the corrections!), so I suspect he may just be built different.

https://www.jsoftware.com/ioj/iojATW.htm

Have you seen anything written in K itself? Here's a program to calculate primes:

    2_&{&/x!/:2_!x}'!R
Post reply on HN