Skip to content

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:

GeneralArray Language SpecificArray Library Specific
Rosetta CodeBQN-Dyalog DictionaryArrayFire-MATLAB-NumPy
Programming-IdiomsBQN-Dyalog DictionaryArrayFire-Eigen
J-Dyalog APL RosettaArrayFire-Numpy
Q-APL DictionaryMatX-MATALB-NumPy

Language / Library Websites

Language💲Main WebsiteHelp / DocsOnline REPL
💚Dyalog APLdyalog.comDyalog HelpTryAPL
💛Kapkapdemo.dhsdevelopments.comKap RefKap Interpreter
💛TinyAPLtinyapl.rubenverg.comTinAPL PrimitivesOnline REPL
💚Jjsoftware.comJ NuVocJ Playground
💚BQNmlochbaum.github.io/BQNBQN DocsBQNPAD
💚Uiuauiua.orgUiua DocsUiuaPAD
💚Q💲code.kx.com/qQ Ref
💙Juliajulialang.orgJulia DocsReplit
💙MATLAB💲mathworks.com/products/matlab.htmlMATLAB Help💲
💙NumPy*numpy.orgNumPy DocsReplit
💙Rr-project.orgR DocsJDoodle
💜Nialnial-array-language.orgNial DictionaryTIO
💜Futharkfuthark-lang.orgFuthark Docs
💜Dexgithub.com/google-research/dex-langInDex
💜Ivypkg.go.dev/robpike.io/ivyIvy Docs
💜💗SaCsac-home.orgSaC Docs
💗ArrayFire*arrayfire.comArrayFire Docs
💗MatX*nvidia.github.io/MatXMatX API Ref
💗ATen*-ATen Docs
💗Eigen*eigen.tuxfamily.orgEigen DoxGodbolt

* 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
12345
APL💚1 (or ⎕IO)LA/TARLRow
Kap💚0LA/TARLRow
TinyAPL💚0LARLRow
J💚0LARLRow
BQN💚0LARLRow
Uiua💚0LARLRow
Q💛0RLRow
Julia💚1AA()Column
MATLAB💚1LA()Column
NumPy💚0AA()Row
R💚1AA()Column
Nial💛1AALRRow
Futhark💛0LRRow
Dex💛0()
Ivy💛1 (or origin)RLRow
SaC0LA()Row
ArrayFire0LA()Column
MatX0LA()Row
  1. Length of Array (Leading Axis)
  2. Shape of Array
  3. Rank of Array
  4. Number of Elements in Array
6789
APL⍴⍴×/⍴
Kap⍴⍴×/⍴
TinyAPLϼ×⍆⍴
J#$$$*/@$
BQN=×´≢
Uiua⧻△⧻♭
Qcountcount raze
Juliasize(a, 1)size(a)ndims(a)length(a)
MATLABlength(a)size(a)rank(a)numel(a)
NumPylen(a)a.shapenp.ndim(a)a.size
Rdim(a)[1]dim(a)length(dim(a))length(a)
Nialfirst shapeshapevalencetally
Futharklengthflatten |> length
Dexsize*
Ivy1 take rhorhorho rhorho ,
SaCshape(a)[0]shape(a)shape(shape(a))prod(shape(a))
ArrayFirea.dims()[0]a.dims()*a.numdims()*a.elements()
MatXa.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 NegativesYouTube Solution
3💛P1614 - Maximum Nesting Depth of the ParenthesesYouTube Solution | II
4💚P1672 - Richest Customer WealthYouTube Solution
5💚P1822 - Sign of the Product of ArrayYouTube Solution
6💛P2319 - Check if Matrix Is X-MatrixYouTube 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

Language1a1b23456789
APL💚💚💚💚💚💚💚💚💚
Kap💚💚💚💚💚💚💚💚💚💚
TinyAPL💚💚💚💚💚💚💚💚💚💚
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

Stars

232 stars

Watchers

3 watching

Forks

Contributors

Languages