4 ms·
I have want to chime in. Agree, it is great that ideas from APL have made it into the language... But there is, fortunately, a long and fruitful path still to e
by ggrrhh_ta 6y ago
I have want to chime in. Agree, it is great that ideas from APL have made it into the language... But there is, fortunately, a long and fruitful path still to explore... I love that J is like an alternative path to functional approaches like Haskell and how it plays in terms of providing expressive power. Still, I will not create code in J that is maintained jointly with other users from other domains (which is the case usually when you are using numpy, for example)
- TeMPOraL 6y agoI like how APL made it into Common Lisp wholesale. There's a library that compiles APL to Common Lisp, allowing you to mix APL and Lisp code, working on the same data structures with both languages. https://github.com/phantomics/april https://github.com/phantomics/april Example session I just did, copying APL code from https://aplwiki.com/wiki/John_Scholes%27_Conway%27s_Game_of_Life https://aplwiki.com/wiki/John_Scholes%27_Conway%27s_Game_of_...: CL-USER> (april:with-april-context ((:space *lifespace*)) (april:april "Show←{'·⌺'[⎕IO+⍵]}") (april:april "glider←3 3⍴1 1 1 1 0 0 0 1 0") (april:april-f "Show glider") (print (april:april "glider")) ; to prove it's a Lisp array (terpri) (april:april "grid←¯10 ¯10↑glider") (april:april-f "Show grid") (terpri) (april:april "life ← {⊃1 ⍵ ∨.∧ 3 4 = +/ +⌿ ¯1 0 1 ∘.⊖ ¯1 0 1 ⌽¨ ⊂⍵}") (terpri) (april:april-f "Show¨{life⍣⍵⊢grid}¨0,⍳3") (terpri)) ⌺⌺⌺ ⌺·· ·⌺· #2A((1 1 1) (1 0 0) (0 1 0)) ·········· ·········· ·········· ·········· ·········· ·········· ·········· ·······⌺⌺⌺ ·······⌺·· ········⌺· ·········· ·········· ·········· ·········· ·········· ·········· ·········· ·········· ·········· ·········· ·········· ·········· ·········· ·········· ·········· ·········· ·········· ·········· ·········· ·········· ·········· ·········· ·········· ·········· ·········· ········⌺· ·······⌺⌺· ·······⌺⌺· ·······⌺⌺⌺ ·······⌺⌺· ·······⌺·⌺ ······⌺⌺·· ·······⌺·· ·······⌺·⌺ ·······⌺·· ········⌺· ········⌺· ·········· ·········· ·········· (APL being compiled to Lisp is important, not just because it gives you proper interoperability out of the box, but also because on implementations like SBCL this means APL code will get compiled, through Lisp, to native code. And you can do that at runtime too.) Now I wish I could find something that does the same for J, because I'm sure as hell not going to buy an APL-friendly keyboard.
- icen 6y agoEmacs has an excellent APL keyboard implementation (via gnu-apl-mode) which uses . as a prefix for the apl keys.
- moonchild 6y ago> APL being compiled to Lisp is important, not just because it gives you proper interoperability out of the box, but also because on implementations like SBCL this means APL code will get compiled, through Lisp, to native code Except that simd in lisp isn't great and needs to be done mostly by hand[1]; and simd is super important for making apl performant. Also because gc attributes that are good for lisp aren't great for apl. Also because compiling to native code doesn't actually really affect performance of apl, and might actually harm it for larger programs. To be clear, april is a super-cool project, but not because of any of its performance characteristics. > Now I wish I could find something that does the same for J, because I'm sure as hell not going to buy an APL-friendly keyboard. You don't need a special keyboard, just a layout. I don't know how it works on windows (there's an 'IME', I think?) or macos, but x comes with a keyboard layout. I use this: setxkbmap -layout us,apl -variant dyalog -option grp:rwin_switch Which makes it so that holding down the right super key and pressing any key produces an appropriate apl symbol. You may want to use a different key to switch; check 'man xkeyboard-config' and then search for 'Switching to another layout' for other options. Try: modifier key (whatever it is)+r, for ⍴ (rho). 1. https://www.reddit.com/r/lisp/comments/fkfgjn/sbcl_with_simd_how_to_optimize_sseavx2_to_pointer/ https://www.reddit.com/r/lisp/comments/fkfgjn/sbcl_with_simd...
- ggrrhh_ta 6y agoRegarding the keyboard, I use something like this https://unix.stackexchange.com/questions/547705/finding-apl-symbols-on-the-keyboard https://unix.stackexchange.com/questions/547705/finding-apl-... and well, a picture of the mappings, but somehow they kind of end sticking in your head...
- ggrrhh_ta 6y agoBeautiful that it can get actually compiled... I dreamt of that, but in particular, with J, it'd be very hard as the actual implementation is data driven, i.e., lexical analysis alone would require building a kind of interpreter for chained operations to work efficiently under all circumstances or compile all possible variants of execution.