Skip to content

codereport/array-language-comparisons

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Array Language & Library Comparisons

image

This is a collection of idioms and small programs in APL, J, BQN, Julia, R, NumPy, Nial, Futhark & SaC.

There are several sites that do these kinds of comparisons:

General Array Language Specific Array Library Specific
Rosetta Code BQN-Dyalog Dictionary ArrayFire-MATLAB-NumPy
Programming-Idioms BQN-Dyalog Dictionary ArrayFire-Eigen
J-Dyalog APL Rosetta ArrayFire-Numpy
Q-APL Dictionary MatX-MATALB-NumPy

Language / Library Websites

Language πŸ’² Main Website Help / Docs Online REPL
πŸ’š Dyalog APL dyalog.com Dyalog Help TryAPL
πŸ’› Kap kapdemo.dhsdevelopments.com Kap Ref Kap Interpreter
πŸ’š J jsoftware.com J NuVoc J Playground
πŸ’š BQN mlochbaum.github.io/BQN BQN Docs BQNPAD
πŸ’š Uiua uiua.org Uiua Docs UiuaPAD
πŸ’š Q πŸ’² code.kx.com/q Q Ref 🚫
πŸ’™ Julia julialang.org Julia Docs Replit
πŸ’™ MATLAB πŸ’² mathworks.com/products/matlab.html MATLAB Help πŸ’²
πŸ’™ NumPy* numpy.org NumPy Docs Replit
πŸ’™ R r-project.org R Docs JDoodle
πŸ’œ Nial nial-array-language.org Nial Dictionary TIO
πŸ’œ Futhark futhark-lang.org Futhark Docs 🚫
πŸ’œ Dex github.com/google-research/dex-lang InDex 🚫
πŸ’œ Ivy pkg.go.dev/robpike.io/ivy Ivy Docs 🚫
πŸ’œπŸ’— SaC sac-home.org SaC Docs 🚫
πŸ’— ArrayFire* arrayfire.com ArrayFire Docs 🚫
πŸ’— MatX* nvidia.github.io/MatX MatX API Ref 🚫
πŸ’— ATen* - ATen Docs 🚫
πŸ’— Eigen* eigen.tuxfamily.org Eigen Dox Godbolt

* Library, not an actual language

  • πŸ’š Main (APL-Family) Array Languages
  • πŸ’› Fringe (APL-Family) Array Languages
  • πŸ’™ Main (Non-APL-Family) Array Languages
  • πŸ’œ Fringe / Research Array Languages
  • πŸ’— Array Compiler Backends / Array Libraries

Comparisons

  1. REPL
  2. Index Base
  3. Axis/Rank Model
    1. LA = Leading Axis
    2. TA = Trailing Axis
    3. AA = Axis Agnostic
  4. Application Model
    1. () = Parentheses
    2. LR = Left to Right
    3. RL = Right to Left
  5. Row-major or Column-Major
1 2 3 4 5
APL πŸ’š 1 (or βŽ•IO) LA/TA RL Row
Kap πŸ’š 0 LA/TA RL Row
J πŸ’š 0 LA RL Row
BQN πŸ’š 0 LA RL Row
Uiua πŸ’š 0 LA RL Row
Q πŸ’› 0 🚫 RL Row
Julia πŸ’š 1 AA () Column
MATLAB πŸ’š 1 LA () Column
NumPy πŸ’š 0 AA () Row
R πŸ’š 1 AA () Column
Nial πŸ’› 1 AA LR Row
Futhark πŸ’› 0 🚫 LR Row
Dex πŸ’› 0 ()
Ivy πŸ’› 1 (or origin) 🚫 RL Row
SaC 🚫 0 LA () Row
ArrayFire 🚫 0 LA () Column
MatX 🚫 0 LA () Row
  1. Length of Array (Leading Axis)
  2. Shape of Array
  3. Rank of Array
  4. Number of Elements in Array
6 7 8 9
APL β‰’ ⍴ ⍴⍴ Γ—/⍴
Kap β‰’ ⍴ ⍴⍴ Γ—/⍴
J # $ $$ */@$
BQN β‰  β‰’ β‰’β‰’ Γ—Β΄β‰’
Uiua ⧻ β–³ ⧻△ ⧻♭
Q count 🚫 🚫 count raze
Julia size(a, 1) size(a) ndims(a) length(a)
MATLAB length(a) size(a) rank(a) numel(a)
NumPy len(a) a.shape np.ndim(a) a.size
R dim(a)[1] dim(a) length(dim(a)) length(a)
Nial first shape shape valence tally
Futhark length 🚫 🚫 flatten |> length
Dex size* 🚫 🚫
Ivy 1 take rho rho rho rho rho ,
SaC shape(a)[0] shape(a) shape(shape(a)) prod(shape(a))
ArrayFire a.dims()[0] a.dims()* a.numdims()* a.elements()
MatX a.Shape()[0] a.Shape() a.Rank() TotalSize(a)

πŸ’› Means the REPL has certain limitations

  • Q REPL has no HOME, END, or any arrows (CTRL or not)
  • Nial REPL has no CTRL left or right arrow
  • Futhark REPL has no HOME, END, or DEL
  • Dex REPL as no UP, DOWN and does not work with rlwrap

If you are using Q, Nial, Futhark or other languages with REPL limitations, you can get around this by invoking with rlwrap. On Linux using the Q REPL:

sudo apt install rlwrap
rlwrap taskset -c 2 ./q

Note that even when using rlwrap, some of the limitations will remain (such as CTRL + arrows).

Other Comparisons

  1. Creating an Identity Matrix
  2. Creating an Iota Matrix
  3. Reversing a Matrix Row-wise, Column-wise and in Memory
  4. Summing a Matrix Row-wise, Column-wise and Down to a Scalar

Leetcode / PWC Problems

# Problem πŸ“Ή
1 πŸ’› P0485 - MCO (Max Consecutive Ones) -
2 πŸ’š P1351 - Count Negatives YouTube Solution
3 πŸ’› P1614 - Maximum Nesting Depth of the Parentheses YouTube Solution | II
4 πŸ’š P1672 - Richest Customer Wealth YouTube Solution
5 πŸ’š P1822 - Sign of the Product of Array YouTube Solution
6 πŸ’› P2319 - Check if Matrix Is X-Matrix YouTube Solution
7 πŸ’› P0674 - LCIS (Longest Continuous Increasing Subsequence) -
8 πŸ’› P00064 - Maixmum Gap -
9 πŸ’› PWC198 P1 - Maximum Gap Count -
  • πŸ’š = All solutions complete
  • πŸ’› = Some solutions missing

Progress

Language 1a 1b 2 3 4 5 6 7 8 9
APL πŸ’š 🚫 πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š
Kap πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š
J πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š
BQN πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š
Uiua πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š
Q πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š
Julia 🚫 πŸ’š πŸ’š 🚫 πŸ’š πŸ’š πŸ’š πŸ”œ πŸ”œ πŸ”œ
MATLAB πŸ”œ 🚫 πŸ’š 🚫 πŸ’š πŸ’š πŸ’š πŸ”œ πŸ”œ πŸ”œ
NumPy πŸ’š πŸ’š πŸ’š 🚫 πŸ’š πŸ’š πŸ’š πŸ”œ πŸ”œ πŸ”œ
R πŸ”œ πŸ’š πŸ’š πŸ”œ πŸ’š πŸ’š πŸ’š πŸ”œ πŸ”œ πŸ”œ
Nial πŸ’š 🚫 πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š πŸ”œ πŸ”œ πŸ”œ
Futhark πŸ”œ πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š πŸ”œ πŸ”œ πŸ”œ
Dex 🚫 🚫 πŸ’š 🚫 πŸ’š πŸ’š πŸ”œ 🚫
Ivy 🚫 🚫 πŸ’š πŸ’š πŸ’š πŸ’š πŸ’š πŸ”œ πŸ”œ πŸ”œ
SaC πŸ”œ πŸ”œ πŸ’š πŸ”œ πŸ’š πŸ’š πŸ’š πŸ”œ πŸ”œ πŸ”œ
ArrayFire πŸ”œ πŸ”œ πŸ’š πŸ”œ πŸ’š πŸ’š πŸ’š πŸ”œ πŸ”œ πŸ”œ
MatX πŸ”œ πŸ”œ πŸ’š πŸ”œ πŸ’š πŸ’š πŸ”œ πŸ”œ πŸ”œ πŸ”œ

About

A comparison of array languages & libraries: APL, J, BQN, Uiua, Q, Julia, R, NumPy, Nial, Futhark, Dex, Ivy, SaC & ArrayFire.

Resources

License

Stars

Watchers

Forks