Array Language & Library Comparisons
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
- REPL
- Index Base
- Axis/Rank Model
LA
= Leading AxisTA
= Trailing AxisAA
= Axis Agnostic
- Application Model
()
= ParenthesesLR
= Left to RightRL
= Right to Left
- 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 |
- Length of Array (Leading Axis)
- Shape of Array
- Rank of Array
- 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
- Creating an Identity Matrix
- Creating an Iota Matrix
- Reversing a Matrix Row-wise, Column-wise and in Memory
- 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 | ๐ | ๐ | ๐ | ๐ | ๐ | ๐ | ๐ | ๐ | ๐ | ๐ |