4 ms·
To contrast with most of the "write your own small text editor" articles out there, I feel compelled to post this: http://kparc.com/$/edit.k http://kparc.com/$
by userbinator 7y ago
To contrast with most of the "write your own small text editor" articles out there, I feel compelled to post this:
http://kparc.com/$/edit.k http://kparc.com/$/edit.k
This is a text editor written in K, an APL-family language. Determining how it works is left as an exercise to the reader. I wonder whether an explanation would be longer or shorter than the tutorial in the article...
- max_ 7y agoWow! a text editor in 3 lines of code? It would be nice if a short write up accompanied this?
- aidos 7y agoObligatory clip: Game of Life in APL https://youtu.be/a9xAKttWgP4 https://youtu.be/a9xAKttWgP4
- geocar 7y agoMaybe this will help? I wrote the following up a few years ago now: https://news.ycombinator.com/item?id=8476633 https://news.ycombinator.com/item?id=8476633
- drudru11 7y agoThanks for that write up. Is there a decent reference or tutorial for ‘k’ online that you would recommend? I would like to learn more about it’s semantics. For example, the views concept and how old versions of a view/var? Are available.
- geocar 7y agoNot to my knowledge. There are a fair number of documents[1] describing the language to be sure, but it is difficult to divorce K from its implementation(s), so k2, k3, k4, k5 (etc) are all different languages. Your best bet is to download some implementations and try it out. k4 is built-in to kx's q which has a free download[3], just enter a line with a backslash on it to get into k. Views are just a convenient syntax for memoization. Old versions of the value aren't available. [1]: http://web.archive.org/web/20041022042401/http://www.kx.com/technical/documents/kusrlite.pdf http://web.archive.org/web/20041022042401/http://www.kx.com/... [2]: https://web.archive.org/web/20130801233812/http://www.kuro5hin.org/story/2002/11/14/22741/791 https://web.archive.org/web/20130801233812/http://www.kuro5h... [3]: https://kx.com/ https://kx.com/
- icen 7y agoThere's a decent tutorial now at shakti.com: https://shakti.com/tutorial/ https://shakti.com/tutorial/
- ksherlock 7y agooK is an implementation of K6 in Javascript. No views, but you can play with it in your browser and the documentation is pretty good. http://johnearnest.github.io/ok/index.html http://johnearnest.github.io/ok/index.html https://github.com/JohnEarnest/ok/blob/gh-pages/docs/Manual.md https://github.com/JohnEarnest/ok/blob/gh-pages/docs/Manual.... https://github.com/JohnEarnest/ok/blob/gh-pages/docs/Programming.md https://github.com/JohnEarnest/ok/blob/gh-pages/docs/Program...
- LfLxfxxLxfxx 7y agoProbably most of the work is hidden in the underlying "framework" or "language". Here's a text editor in 1 line of html: <textarea></textarea>
- Sir_Cmpwn 7y agoAPL is an extraordinarily concise programming language, even without taking its environment into account. This is a well known implementation of Conway's Game of Life in APL: ↑1 ⍵∨.∧3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵
- forgotpwd16 7y agoThe first line loads http://kparc.com/$/view.k http://kparc.com/$/view.k, where the first lines are multiple variable definitions per line. A non obfuscated version is at http://kparc.com/edit.k http://kparc.com/edit.k where some stuff are explained.
- SifJar 7y agoUnfortunately I believe this is written in k5, for which there is no public implementation, hence it's not possible to run this editor. (I'd be delighted to be wrong here, would be very interested to see this running)
- Razengan 7y agoThese sorts of languages make me wonder, can this be reversed? As in: sdj8340u2u$@(:@#P+_A:@L@#!@)_ZL?> M OW {E)@( Can a language be invented where this random string I hammered out would be a valid program?
- icen 7y agoYes of course. If you balanced the parentheses it would be syntactically valid k. It assumes a bunch of names, and would be unlikely to do anything useful, but it would be legal. The k7/shakti tutorial playfully notes that running one's finger along the shifted top row of the keyboard is syntactically valid.
- setr 7y ago>Can a language be invented where this random string I hammered out would be a valid program? perl :-)
- MadWombat 7y agopretty sure that is a valid vi command