7 ms·
I laughed when I saw the source: "just" 30 lines, to be sure, but 30 lines of dense, alien glyphs! This is probably 300 (or 3000?) in a less expressive language
by andai 3y ago
I laughed when I saw the source: "just" 30 lines, to be sure, but 30 lines of dense, alien glyphs! This is probably 300 (or 3000?) in a less expressive language, right?
What's a good place to start for languages like this? k is proprietary, isn't it? I found unrelated languages with the same name on GitHub.
- RodgerTheGreat 3y agothere are at least three reasonably comprehensive open-source k implementations: https://github.com/kevinlawler/kona https://github.com/kevinlawler/kona (k3) https://github.com/JohnEarnest/ok https://github.com/JohnEarnest/ok (k6, js-based) https://codeberg.org/ngn/k https://codeberg.org/ngn/k (k6, c-based) even today, many k programmers learn from the k2 reference manual. k2/k3 are extremely similar: http://web.archive.org/web/20050504070651/http://www.kx.com/technical/documents/kreflite.pdf http://web.archive.org/web/20050504070651/http://www.kx.com/... oK has a briefer manual which describes k5/k6: https://github.com/JohnEarnest/ok/blob/gh-pages/docs/Manual.md https://github.com/JohnEarnest/ok/blob/gh-pages/docs/Manual....
- mhuffman 3y ago>What's a good place to start for languages like this? I recommend: https://xpqz.github.io/learnapl/intro.html#but-it-s-unreadable https://xpqz.github.io/learnapl/intro.html#but-it-s-unreadab... (for apl) and https://xpqz.github.io/kbook/Introduction.html https://xpqz.github.io/kbook/Introduction.html (for k) ... the author admits they are not an expert in either, but the pace and tone are very beginner friendly, which I have found is necessary if you do not have any experience in array languages.
- skruger 3y agoI’m happy to have contributed in some small way to growing the APL community. Thanks for the shoutout.
- ithkuil 3y agoyou may also enjoy uiua (https://www.uiua.org/ https://www.uiua.org/) which uses these alien glyphs but is even more alien because it's a concatenative language (stack oriented), like forth or postscript, but to make it even more alien it's written right to left. For example 1+2 is written "+ 1 2" (in forth it would be "1 2 +") The language and the site are brilliant and I think worth 30m of your time skimming through and trying out the examples in the online editor / tutorial.
- uticus 3y agoThe only reason stack-based languages don't seem like alien tech to me was because of the HP48G+ graphing calculator I had in high school. > Uiua can be embedded in Rust programs as a library. Cool! I was wondering if there was any viability beyond short scripts.
- ithkuil 3y agoI still use reverse polish calculator (on my phone) but I'm not used typing it left to right but executed right to left. For example in uiua: * + 1 2 5 Pushes 5 on the stack, then pushed 2, then pushes 1. Then pops 1 and 2 adds them together and pushes 3, then pops 3 and 5 and multiplies then together Reverse polish: 5 2 1 + * EDIT: it does makes sense in the context of an array language
- plagiarist 3y agoThe uiua version makes more sense to me than the other even without arrays. It's closer to how my brain wants to understand what is happening: "multiply (the result of...) and 5" instead of "5 (2 and 1 added) multiplied." The latter is kinda like "the old man the boat" where information occurring later in time changes the meaning of what comes prior. I'm sure once things get complicated enough I would understand neither RtL or LtR with equal confusion, but the smaller cases seem very readable.
- ithkuil 3y ago
- jd3 3y agoFrom experience, my take is that most laymen devs are unwilling and/or uninterested in taking the dive into apl/k/array langs due to the, in their own words, deliberately abstruse and obscurantist syntax/glyphs/typing; it's just too theoretical and/or cognitively/neurologically daunting for average engineers that just want to get paid.
- 7thaccount 3y agoI think it's a combination of that and being taught for so long the "right way" to do things with languages like APL appearing "too clever".
- jd3 3y agoAfaik most undergrad education is still explicitly procedural/imperative/OOO with a dash of lisp/scheme in theory of comp. Barring the exceptionally driven and programs that are unusually theoretical and/or historically based (i.e., SICP), many new grads enter industry having only ever used js/python/java/c++ it seems.
- uticus 3y ago> abstruse and obscurantist syntax/glyphs/typing I've often wondered what are the real blocks to having it both ways? Have the source saved as some lowest common denominator - IL, tagged AST, or somesuch - and then read and written in whatever pleases the individual. It would be hard to make it work between languages with drastically different semantics that don't map to anything in another language, I suppose would be the real reason... but I always think about the fact that it makes it down to machine code eventually, so it seems intuitive that the process could be reversed. Or less drastically, an IDE for APL beginners: symbols have human language helpers or UI overlays, but the source is still APL.
- RodgerTheGreat 3y agoThe concise notation of vector languages is not just an affectation; it's a crucial property. Obscuring the notation with long names and "more familiar" syntax diminishes its value. Translating it into something "easier" leaves beginners unable to communicate clearly with APL experts or engage with resources from the broader community. Imagine suggesting to a Prolog programmer that they make the language more accessible to beginners with tools that dynamically translate it into the equivalent Fortran, which is, after all, a Turing-complete language...
- xelxebar 3y agoYou're absolutely right that the kind of APL in my parser looks alien. And you're right that there would be a 100X blowup in code size for an equivalent C implementation. Part of the issue is that you're seeing the entire application architecture on a single page. Zero libraries, to boot. I'd expect a similar feeling from looking at a detailed architectural diagram for some business application in a domain that you're only partially familiar with. The code is written specifically for the domain expert, trading off ease of onboarding everywhere it would incur a cognitive cost. The reason I do this is specifically to eliminate any incidental complexity and force myself to only cognate directly about the problem domain. It's a funny feeling. Almost every character in the code reifies a concrete feature of the parsing architecture. Said another way, I can't go in and change anything _without_ having to think about deep and relevant questions in YAML itself or the way I'm choosing to decompose the parsing problem. One could argue that something similar is true about spaghetti code, since changing one piece of code affects every other, but I've really worked hard to orthogonalize out and compose salient features of YAML. Implicitly, every line of code is a parser pass that defines a type transformation on the AST. Each pass introduces specific invariants that later passes can rely on to express higher-level ideas. Anyway, I set out on the parser project specifically to verify whether such a development experience is possible. Aaron Hsu has videos on youtube expounding similar ideas, but it's hard to believe unless you directly feel it yourself. > What's a good place to start for languages like this? Come over to the APL Orchard (https://apl.chat https://apl.chat). It's pretty active, and the main Dyalog member there, Adám, is both incredibly knowledgeable as well as very available for helping interested beginners.
- 7thaccount 3y agoI was about to ask if Aaron had inspired you considering how similar your comments are as well as the type of problem your solving. Neat to see others doing the same!