Hacker News new | ask | show | jobs
by ah- 4258 days ago
k/q really doesn't have to be this unreadable, that's just Arthurs style. Here's some code in C by him for comparison: http://kx.com/q/cs107/a.c
5 comments

I tried cleaning it up a bit: https://gist.github.com/lukechampine/f54fce8fd756254cefb2

But the actual meaning of the program is still lost on me. I can only guess it has something to do with parsing files (note the checks for curly braces). Feeding it its own source code produces some output, but I have no idea what it actually modified.

It's a solution to CS107 assignment 1 : http://web.stanford.edu/class/cs107/assign1.html
Guess I could have just looked at the URL, huh. Well, it was fun trying to reverse Whitney's code anyhow.

Humorously, it looks like this code would have received a poor grade. It meets just about every standard for low quality outlined here: http://web.stanford.edu/class/cs107/landmarks.html, particularly "Fast code which doesn't work quite right." (Due to an off-by-one error, this code fails to properly reconstruct the example text.)

> Due to an off-by-one error, this code fails to properly reconstruct the example text

What's your example? It seems to work fine to me on "{all is well}{ell that en}{hat end}{t ends well}"

In case anybody is still interested, it's now up on http://kparc.com/cs107/readme
The original is 404ing, do you have a mirror?
That's the original C file, where did your "cleaned-up" version go?
Here is a style for K (http://nsl.com/papers/style.pdf) 1995. Interestingly, most of the concepts still apply.

I believe the audience is developers using K in a commercial/production environment.

The biggest differences, compared to Arthur's style of writing, are: * Less code on each line * A separate comment column on each line * Nominal use of spaces for readability

Q isn't unreadable. Its implemented in standard English words.http://code.kx.com/wiki/Reference K is considered unreadable by many.
I was more referring to the almost exclusive use of single letter variable names. If one would use at least short words to name things, the implementation would be a whole lot more understandable.
Good lord, I need a drink now.
If that's true, why aren't there DSLs that compile to k?