Live data from Hacker News

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

github.com

61–70 of 93 posts

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

#62

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…

One analogy I like to tell people who are overcome with shock and horror at APL-family languages is to compare it to someone used to Latin-family human languages looking at something like Chinese for the first time --- it's likewise totally "unreadable" at first glance, but then you realise that over a billion people can read and write that language fluently every day, many of which may also struggle with a Latin-family language as they've never seen one before.

I'm not convinced that APL is "incredibly hard to scan" for someone who is familiar with it; it's just a matter of experience. While I'm by no means experienced in APL either, a visually similar thing I did frequently in my younger days was reading x86 instructions not in a disassembler nor hexdump, but displayed as CP437. It was not hard, and I can still remember ┤, PQRS, ═!, and ├ as "MOV AH", "PUSH AX; PUSH CX; PUSH DX; PUSH BX", "INT 21", and "RET" respectively. Here's an example:

    ò║•═!├Hello world!$
Edit: looks like HN swallowed a byte, but you can sort of see what I mean.

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

#63

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…

Awesome comment. In your opinion, what would be a language that comes closer to K’s functionality but at the same time be understandable to mere mortals?

I recommend checking out uiua.org for fun. The docs are well written and the concepts, while foreign to most, are ultimately accessible and interesting.

k and uiua are in different branches of the APL family.

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

#65

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…

One analogy I like to tell people who are overcome with shock and horror at APL-family languages is to compare it to someone used to Latin-family human languages looking at something like Chinese for the first time --- it's likewise totally "unreadable" at first glance, but then you realise that over a billion people can read and write that language fluently every day, many of which may also struggle with a Latin-fam…

As a moderately experienced K programmer, I find K easy enough to "scan". Common idioms immediately stand out as recognizable "words" that are suggestive of what a routine does before you fully parse it:

@& (filtering)

@ (sorting)

@\: (folding)

,/ (flattening)

+\ (a running total)

etc.

It's also easy to notice, e.g. in K3, a reserved name like "_f" and immediately know you're looking at a recursive procedure.

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

#66

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…

Awesome comment. In your opinion, what would be a language that comes closer to K’s functionality but at the same time be understandable to mere mortals?

I'm extremely biased in recommending it, but Lil is semantically very similar to Q, entirely free, and intended to be beginner-friendly: https://beyondloom.com/tools/trylil.html

It's not as powerful or concise as K, but it gives you some of the flavor of an array language tucked inside what resembles an ordinary imperative/functional scripting language.

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

#67
J, the predecessor to K, also by the same author, is written in nearly the same style, but shorter:

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

(Discussed previously: https://news.ycombinator.com/item?id=25902615 )

There's something very satisfying about how this style seems to "climb the abstraction ladder" very quickly, but all of those abstractions he creates are not wasted and immediately put to use. I think much of the amazement and beauty is that there isn't much code at all, and yet it does so much. It's the complete opposite of the bloated, lazy, lowest-common-denominator trend that's been spreading in many other languages's communities.

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

#68

Earlier quoted context omitted.

Awesome comment. In your opinion, what would be a language that comes closer to K’s functionality but at the same time be understandable to mere mortals?

I'm extremely biased in recommending it, but Lil is semantically very similar to Q, entirely free, and intended to be beginner-friendly: https://beyondloom.com/tools/trylil.html It's not as powerful or concise as K, but it gives you some of the flavor of an array language tucked inside what resembles an ordinary imperative/functional scripting language.

Awesome, thanks

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

#69

Earlier quoted context omitted.

Awesome comment. In your opinion, what would be a language that comes closer to K’s functionality but at the same time be understandable to mere mortals?

I recommend checking out uiua.org for fun. The docs are well written and the concepts, while foreign to most, are ultimately accessible and interesting. k and uiua are in different branches of the APL family.

Will do, thanks!
Post reply on HN