Earlier quoted context omitted.
It doesn't do much for you, true - but after using K for awhile I came to the conclusion that the vast majority of what other languages give you is not required. Sort of like realizing that a lot of lawyers, finance people and even doctors do not actually provide society at large and even their direct customers any benefit (though having nontrivial cost), and the world would be a better place if there were fewer of t…
I came to a similar conclusion when programming using a hex editor and the x86 instruction set manual. Without having to clutter my mind with the abstractions other languages introduce I found I had a ton of free memory to reason about my code and handle much larger portions of code than I usually do. Also, by typing in data directly I avoided having to do the mental translation of thinking about what a compiler or i…
K, by Arthur Whitney (2005)
21–30 of 31 posts
Re: K, by Arthur Whitney (2005)
#22NumPy is an array oriented library/language too. Idiomatic NumPy usage is quite terse too. I can see how you can start with NumPy like syntax and then want something still more terse, but starting from K/Q seems quite hard.
K has 3 types: atoms, lists, and dictionaries. (atoms can be int, char, float, symbol, time or function). No objects, no strings, not even files. And yet, it is enough to express many algorithms concisely and efficiently, with bugs largely reduced to the class of off-by-one family.
The syntax is not just a superficial aspect of the language - it is fundamental to its evolution.
Re: K, by Arthur Whitney (2005)
#23I had to write a lot of K at university (thus disclosing where I went to, and confusing people that have written any K with the idea you could possibly write a lot of it). Get by the symbolic confusion (Arthur himself used to respond to confused students on the mailing list about such things) and it's really quite inspired. I can appreciate how an APL with proper symbols would be properly productive. Your code ends u…
Is Kona good enough for dabbling with do you think? https://github.com/kevinlawler/kona
(J is a different language; both J and K can be traced back to the origin of A, a 20 C line implementation of an APL dialect)
Re: K, by Arthur Whitney (2005)
#24I have a fear that the problem with these APL family languages is that they ruin coding in any other language for you.
But would you rather remain blissfully unaware?
Re: K, by Arthur Whitney (2005)
#25Earlier quoted context omitted.
I came to a similar conclusion when programming using a hex editor and the x86 instruction set manual. Without having to clutter my mind with the abstractions other languages introduce I found I had a ton of free memory to reason about my code and handle much larger portions of code than I usually do. Also, by typing in data directly I avoided having to do the mental translation of thinking about what a compiler or i…
I'm sure this was supposed to be funny. But unlike x86 hex coding, people actually get stuff done in k/q - in fact stuff that runs faster and better than equivalent systems in C++ and Java. So the reduction ad absurdum does not, in fact, add to the discussion.
Re: K, by Arthur Whitney (2005)
#26I have a fear that the problem with these APL family languages is that they ruin coding in any other language for you.
That, in fact, sort of happened to me. But would you rather remain blissfully unaware?
⍝
Re: K, by Arthur Whitney (2005)
#27Then there are great tutorials on the code k website. It's a beautiful language full of unique original ideas.
Re: K, by Arthur Whitney (2005)
#28http://queue.acm.org/detail.cfm?id=1531242
It turns out he rewrites the whole compiler from scratch in C every four years.
This is a snapshot from the source code of 'J' also by Arthur Whitney - the precursor to 'K'.
http://keiapl.org/rhui/remember.htm#incunabulum
This is it described by Ken Iverson:
"The final impetus that got J started was the one-page interpreter fragment that Arthur wrote, recorded in Appendix A of An Implementation of J [29] and also reproduced in Appendix A below. My immediate reaction on seeing the page was recoil and puzzlement: it looked nothing like any C code I had ever seen. (“Is it even C?”) However, Ken counselled that I should reserve judgment. "
Re: K, by Arthur Whitney (2005)
#29For a real eye opener compare the length of these K versions of the Alioth benchmarks to their more verbose brethren http://kparc.com/$/z/comp.k . I found these on the K OS project page - http://kparc.com/os.htm . There's a great description of Arthur Whitney building a Notepad like text editor (1K) in 30 minutes or so using this system here - http://coding-is-like-cooking.info/2013/09/an-introduction-t... . Personal…
http://coding-is-like-cooking.info/2013/09/an-introduction-t... . Thanks, I enjoyed that article. It gives a vivid picture of the gap between the array languages niche and mainstream programming culture.
I found this too, when I tried them both, first J then APL, perhaps because:
* APL uses () [] and {} in their pairs to parenthesize things, just like other languages, while J uses the 6 symbols as standalones, harder to read the code.
* All verbs in APL are single characters, whereas J symbols might be more than one.
* J, unlike APL, uses the concepts of rank, and forks and hooks, which are both difficult to grasp and don't seem to add much to the array processing idea.
Re: K, by Arthur Whitney (2005)
#30For a real eye opener compare the length of these K versions of the Alioth benchmarks to their more verbose brethren http://kparc.com/$/z/comp.k . I found these on the K OS project page - http://kparc.com/os.htm . There's a great description of Arthur Whitney building a Notepad like text editor (1K) in 30 minutes or so using this system here - http://coding-is-like-cooking.info/2013/09/an-introduction-t... . Personal…
a quick Internet also reveals: life:{3=a-x*4=a:2{+(0+':x)+1_x,0}/x}
0+':x -> "sum each element with one to the left
(0 left of the first)"
1_x,0 -> "drop first, add zero at the end"
(0+':x)+1_x,0 -> "sum each element with the one
to the left and the one to the
right (sum of previous expressions)"
a:2{+...}/x -> "do that; transpose; do that;
transpose again, and assign to a.
2{}/ means 'do twice'"
At this point, "a" has the same shape of "x", but in every element is the sum of the elements of x from that location, one above, one below, one left, and one right. 4=a -> "1 where a=4, 0 otherwise"
x*4=a -> "1 where x is 1 and a=4, 0 otherwise"
a-x*4=a -> "decrease a from 4 to 3 if x=1 in the
that place"
3=a-x*4=a -> "1 where one has 3 neighbours"
So, if x is a 1/0 matrix "life x" does one iteration of Conway's game of life. And "1000 life/ x" would seek convergence or return to first state (but no more than 1000 iterations).There is code golfing here; It would have been purely readable K code if it wasn't golfed. But it would also have been two to three times as long.