Conway's Game of Life in APL in Forth
github.com
github.com
Native port of SectorLISP (https://justine.lol/sectorlisp/) to the Quest for Tetris processor (https://codegolf.stackexchange.com/questions/11880/build-a-w...), anybody?
SectorLISP is x86-specific, so this wouldn't just be neatly mushing existing things together, but I think the result could be very interesting nonetheless. I'm tempted to note that SectorLISP's tiny size could make this a reasonable one-shot/nerdsnipe-sized weekend project :D
But yes, highly recommend learning members of this family. It will help your C for sure as well, though possibly not in ways you'd expect.
After using APL and K for a while, I realized 95% of "abstraction" features in C++ / C# and friends are useless; I now avoid C++; My C code became way shorter, way more efficient, way simpler -- but also much less orthodox.
Here's their example:
The following expression sorts a list of strings by their lengths:
x@>#:'x
Ooooooookay. Personally, I recommend a lot of alcohol. This will be a very wild and geeky ride. Bring extra pizza.
Pronounced, this would be "x at grade-down of count of each x" - and indeed, in "q" (a syntactic sugar for K that uses words instead of symbols), this is almost how you would write it (rather: "x at downgrade count each x". It's basically algorithmic math notation: In math you say "b^2-4ac" rather than "b squared minus 4 times a times c". In K you say "x@>#:'x".
It's not just a matter of symbol/syntax familiarity - there's also idioms, etc. But the "scariness" is similar to the "scariness" of a language like Japanese or Arabic, which uses different graphic elements, syntax, vocabulary, and idioms. You might not like it, but it's not because there's something weird or wrong about it -- it's just foreign.
As for K, Stefan Kruger's text seems like a good introduction https://xpqz.github.io/kbook/Introduction.html
Disclaimer: I’m the author
In his weekly column the famous IT philosopher explains issues in computation in a very thoughtful manner.
Recently, Conway's Game of Life was implemented as a one-liner in APL executed in FORTH. APL is another weird-looking programming language. Implementing Conway's game of Life yet again is important because it is a fundamental example of a computation. In this case, the one-liner is important because it is an example of how to concisely express a computation.
Conway's Game of Life is a cellular automaton. A cellular automaton is a discrete model of computation. It consists of a grid of cells, each of which can be in one of a finite number of states. The state of the automaton is updated in discrete time steps, according to a fixed rule. In Conway's Game of Life, the rule is that a cell is alive in the next time step if and only if it was alive in the previous time step and exactly two or three of its eight neighbors were also alive. If a cell is not alive in the previous time step, then it is alive in the next time step if and only if exactly three of its neighbors were alive.
The one-liner in APL executes the Game of Life rule on a two-dimensional grid of cells. The input to the one-liner is the state of the grid at some time step, and the output is the state of the grid at the next time step. The one-liner is able to do this because it uses a clever trick. It treats the input grid as a one-dimensional array of cells, and it uses the fact that the Game of Life rule can be expressed as a matrix operation.
The one-liner is:
life←{↑1 ⍵∨.↑1 3 4⍵}
This one-liner is an example of how to concisely express a computation. It is also an example of how to use a powerful programming language to express a computation in a simple and elegant way.
Which is kind of cool to be able to look at and observe that it made that from just those specific 48 input words. Huh.
life ← {⊃1 ⍵ ∨.∧ 3 4 = +/ +⌿ ¯1 0 1 ∘.⊖ ¯1 0 1 ⌽¨ ⊂⍵}
as shown at https://aplwiki.com/wiki/Conway%27s_Game_of_Life