Live data from Hacker News

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

github.com

51–60 of 93 posts

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

#51

[flagged]

Might not, since for this kind of thing most likely either you give up in couple minutes (which it is not a heinous since it does not waste your time anyway) or you just read it.

The distinction between “seeing” code and “reading” it is right on point.

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

#52

Earlier quoted context omitted.

I don't know about Golang but there are languages where this sort of highly domain-optimized, super terse syntax could be embedded as a domain-specific sublanguage, in a significantly less hackish way than what C allows.

I'm not that knowledgeable, and def not a C apologist, but what language are you thinking of? To my eyes, that is some heavy abuse of the preprocessor in a way that I don't think almost any modern "safe" language could possibly countenance. I read that code like he got the expressivity benefits of a lisp macro system with close-to-the-metal C speeds in like 100 lines of code. I'm curious what else could do this.

Rust’s macro system is safe and hygienic, people have implemented lisps in it. I just did a google search to find an example, so I have no idea how well supported this is, https://github.com/JunSuzukiJapan/macro-lisp

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

#53
post #47
post #43

Earlier quoted context omitted.

my fascination with Q/kdb/K/... disappeared once I had to debug it in production you want a stack trace? tough luck, you'll get back: `type and that's it

backtrace has been supported for some time. the debug facilities are nice https://code.kx.com/q/basics/debug/#stack-frames

2020? their main customers are banks!

at some point we might upgrade to java 8!

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

#54

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?

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

#55

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…

…fits his brain perfectly.

This is super accurate, and interesting in the context of the repo. It’s clearly not the most accessible language or style - I wonder if someone who has hyper optimized for themselves in the way Arthur has can write an effective teaching language. It requires a theory of mind for minds that are probably quite different in the general case.

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

#56
post #22

This looks like a cult I would happily dive into. Does anyone care to ELI5? I tried to read the code but did not understand a single line

Arthur Whitney is showing how to build an array language using C in array language form. AW is known for kdb+ which is often used in finance due to its extreme performance properties and ability for quants to quickly explore ideas. Personally, to get a better handle on how array languages worked, I implemented KlongPy which is a python implementation of Klong, which descends from K (which AW wrote). You have to play…

FWIW, kdb+ is not that extremely performant - there's a lot of things that could be faster, and a lot of limitations that mean that you often would be better of not using a DB at all (or to use another DB and just pull everything you might need into memory). There is/was a tradeoff in that many things that would make it faster would require more code, and a cool thing about q/kdb+ is that it takes so little code you don't have I$ issues, but I think that's a tradeoff that doesn't make as much sense anymore in 2023.

What it's really great for is that it's really neatly integrated into the q language, which is great for exploratory programming, and it's fast enough not to get in the way.

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

#57
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…

> 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?

They're more readable and less buggy that way. But unfortunately most programmers would rather spend 10 days reading 100,000 lines than 4 days reading 1,000 lines.

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

#58

[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

A program written in Unix dc(1) would look as weird as that.

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

#59
post #22

Earlier quoted context omitted.

Arthur Whitney is showing how to build an array language using C in array language form. AW is known for kdb+ which is often used in finance due to its extreme performance properties and ability for quants to quickly explore ideas. Personally, to get a better handle on how array languages worked, I implemented KlongPy which is a python implementation of Klong, which descends from K (which AW wrote). You have to play…

FWIW, kdb+ is not that extremely performant - there's a lot of things that could be faster, and a lot of limitations that mean that you often would be better of not using a DB at all (or to use another DB and just pull everything you might need into memory). There is/was a tradeoff in that many things that would make it faster would require more code, and a cool thing about q/kdb+ is that it takes so little code you…

Thanks the insights. Not to over do self promotion, but aside from learning, the main reason I made KlongPy was to allow for optionality with the ecosystem. Use Klong for array operations and other libraries for standard stuff.
Post reply on HN