An open API service indexing awesome lists of open source software.

https://github.com/codereport/array-language-comparisons

A comparison of array languages & libraries: APL, J, BQN, Uiua, Q, Julia, R, NumPy, Nial, Futhark, Dex, Ivy, SaC & ArrayFire.
https://github.com/codereport/array-language-comparisons

Last synced: 4 months ago
JSON representation

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

Awesome Lists containing this project

README

          

#

Array Language & Library Comparisons












![image](https://github.com/codereport/array-language-comparisons/assets/36027403/13f7164e-d9ea-4c7c-a211-bd437d51949c)

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](http://www.rosettacode.org/wiki/Rosetta_Code) | [BQN-Dyalog Dictionary](https://mlochbaum.github.io/BQN/doc/fromDyalog.html) | [ArrayFire-MATLAB-NumPy](https://github.com/arrayfire/arrayfire-api-cheat-sheet/blob/master/api_equiv_matlab_python.md) |
| [Programming-Idioms](https://programming-idioms.org/) | [BQN-Dyalog Dictionary](https://mlochbaum.github.io/BQN/doc/fromDyalog.html) | [ArrayFire-Eigen](https://github.com/arrayfire/arrayfire-api-cheat-sheet/blob/master/api_equiv_eigen.md) |
| | [J-Dyalog APL Rosetta](http://sigapl.org/_J-Dyalog_APL_Rosetta.html) | [ArrayFire-Numpy](https://arrayfire.com/wp-content/uploads/2012/05/Matrix_WP_ArrayFire_2017.pdf) |
| | [Q-APL Dictionary](https://github.com/codereport/The_Q_Programming_Language/blob/master/Q-Built-in-Functions.md) | [MatX-MATALB-NumPy](https://nvidia.github.io/MatX/matlabpython.html) |

### Language / Library Websites

| | Language | πŸ’² | Main Website | Help / Docs | Online REPL |
| :---: | :--------: | :---: | :----------------------------------------------------------------------------------: | :-------------------------------------------------------------------------: | :------------------------------------------------------------------: |
| πŸ’š | Dyalog APL | | [dyalog.com](https://www.dyalog.com/) | [Dyalog Help](https://help.dyalog.com/18.2/) | [TryAPL](https://tryapl.org/) |
| πŸ’› | Kap | | [kapdemo.dhsdevelopments.com](https://kapdemo.dhsdevelopments.com/) | [Kap Ref](https://kapdemo.dhsdevelopments.com/reference.html) | [Kap Interpreter](https://kapdemo.dhsdevelopments.com/clientweb2/) |
| πŸ’› | TinyAPL | | [tinyapl.rubenverg.com](https://tinyapl.rubenverg.com/) | [TinAPL Primitives](https://tinyapl.rubenverg.com/docs/primitive) | [Online REPL](https://tinyapl.rubenverg.com/run/latest/) |
| πŸ’š | J | | [jsoftware.com](https://www.jsoftware.com/) | [J NuVoc](https://code.jsoftware.com/wiki/NuVoc) | [J Playground](https://jsoftware.github.io/j-playground/bin/html2/#) |
| πŸ’š | BQN | | [mlochbaum.github.io/BQN](https://mlochbaum.github.io/BQN/) | [BQN Docs](https://mlochbaum.github.io/BQN/doc/index.html) | [BQNPAD](https://bqnpad.mechanize.systems/) |
| πŸ’š | Uiua | | [uiua.org](https://www.uiua.org/) | [Uiua Docs](https://www.uiua.org/docs) | [UiuaPAD](https://www.uiua.org/pad) |
| πŸ’š | Q | πŸ’² | [code.kx.com/q](https://code.kx.com/q/) | [Q Ref](https://code.kx.com/q4m3/A_Built-in_Functions/) | β›” |
| πŸ’™ | Julia | | [julialang.org](https://julialang.org/) | [Julia Docs](https://docs.julialang.org/en/v1/) | [Replit](https://julialang.org/learning/tryjulia/) |
| πŸ’™ | MATLAB | πŸ’² | [mathworks.com/products/matlab.html](https://www.mathworks.com/products/matlab.html) | [MATLAB Help](https://www.mathworks.com/help/matlab/) | πŸ’² |
| πŸ’™ | NumPy* | | [numpy.org](https://numpy.org/) | [NumPy Docs](https://numpy.org/doc/stable/) | [Replit](https://replit.com/languages/python3) |
| πŸ’™ | R | | [r-project.org](https://www.r-project.org/) | [R Docs](https://www.rdocumentation.org/) | [JDoodle](https://www.jdoodle.com/execute-r-online/) |
| πŸ’œ | Nial | | [nial-array-language.org](https://www.nial-array-language.org/) | [Nial Dictionary](https://www.nial-array-language.org/ndocs/NialDict2.html) | [TIO](https://tio.run/#Nial) |
| πŸ’œ | Futhark | | [futhark-lang.org](https://futhark-lang.org/) | [Futhark Docs](https://futhark-lang.org/docs.html) | β›” |
| πŸ’œ | Dex | | [github.com/google-research/dex-lang](https://github.com/google-research/dex-lang) | [InDex](https://google-research.github.io/dex-lang/index.html) | β›” |
| πŸ’œ | Ivy | | [pkg.go.dev/robpike.io/ivy](https://pkg.go.dev/robpike.io/ivy) | [Ivy Docs](https://pkg.go.dev/robpike.io/ivy#section-documentation) | β›” |
| πŸ’œπŸ’— | SaC | | [sac-home.org](https://www.sac-home.org/) | [SaC Docs](https://www.sac-home.org/docs:main) | β›” |
| πŸ’— | ArrayFire* | | [arrayfire.com](https://arrayfire.com/) | [ArrayFire Docs](https://arrayfire.org/docs/) | β›” |
| πŸ’— | MatX* | | [nvidia.github.io/MatX](https://nvidia.github.io/MatX/index.html) | [MatX API Ref](nvidia.github.io/MatX) | β›” |
| πŸ’— | ATen* | | - | [ATen Docs](https://pytorch.org/cppdocs/#aten) | β›” |
| πŸ’— | Eigen* | | [eigen.tuxfamily.org](https://eigen.tuxfamily.org/) | [Eigen Dox](https://eigen.tuxfamily.org/dox/) | [Godbolt](https://godbolt.org/) |

\* 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](https://aplwiki.com/wiki/Leading_axis_theory)
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 |
| TinyAPL | πŸ’š | 0 | `LA` | `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 |

6. Length of Array (Leading Axis)
7. Shape of Array
8. Rank of Array
9. Number of Elements in Array

| | 6 | 7 | 8 | 9 |
| :-------: | :------------: | :----------: | :---------------: | :------------------: |
| APL | `β‰’` | `⍴` | `⍴⍴` | `Γ—/⍴` |
| Kap | `β‰’` | `⍴` | `⍴⍴` | `Γ—/⍴` |
| TinyAPL | `β‰’` | `⍴` | `ΟΌ` | `×⍆⍴` |
| 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](https://github.com/codereport/array-language-comparisons/blob/main/comparisons/matrix_identity.md)
2. [Creating an Iota Matrix](https://github.com/codereport/array-language-comparisons/blob/main/comparisons/matrix_iota.md)
3. [Reversing a Matrix Row-wise, Column-wise and in Memory](https://github.com/codereport/array-language-comparisons/blob/main/comparisons/matrix_reversing.md)
4. [Summing a Matrix Row-wise, Column-wise and Down to a Scalar](https://github.com/codereport/array-language-comparisons/blob/main/comparisons/matrix_summing.md)

### Leetcode / PWC Problems

| # | | Problem | :video_camera: |
| :---: | :---: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------: |
| 1 | πŸ’› | [P0485 - MCO (Max Consecutive Ones)](https://github.com/codereport/array-language-comparisons/blob/main/comparisons/leetcode/P0485_MCO.md) | - |
| 2 | πŸ’š | [P1351 - Count Negatives](https://github.com/codereport/array-language-comparisons/blob/main/comparisons/leetcode/P1351_Count_Negatives.md) | [YouTube Solution](https://www.youtube.com/watch?v=MKb4WD6mioE) |
| 3 | πŸ’› | [P1614 - Maximum Nesting Depth of the Parentheses](https://github.com/codereport/array-language-comparisons/blob/main/comparisons/leetcode/P1614_Max_Paren_Depth.md) | [YouTube Solution](https://www.youtube.com/watch?v=zrOIQEN3Wkk) \| [II](https://www.youtube.com/watch?v=6-mk6OpcUdM) |
| 4 | πŸ’š | [P1672 - Richest Customer Wealth](https://github.com/codereport/array-language-comparisons/blob/main/comparisons/leetcode/P1672_Richest_Customer_Wealth.md) | [YouTube Solution](https://www.youtube.com/watch?v=MKb4WD6mioE) |
| 5 | πŸ’š | [P1822 - Sign of the Product of Array](https://github.com/codereport/array-language-comparisons/blob/main/comparisons/leetcode/P1822_Sign_Product_Array.md) | [YouTube Solution](https://www.youtube.com/watch?v=a7CSK7HNEWQ) |
| 6 | πŸ’› | [P2319 - Check if Matrix Is X-Matrix](https://github.com/codereport/array-language-comparisons/blob/main/comparisons/leetcode/P2319_Check_Matrix.md) | [YouTube Solution](https://www.youtube.com/watch?v=8ynsN4nJxzU) |
| 7 | πŸ’› | [P0674 - LCIS (Longest Continuous Increasing Subsequence)](https://github.com/codereport/array-language-comparisons/blob/main/comparisons/leetcode/P0674_LCIS.md) | - |
| 8 | πŸ’› | [P00064 - Maixmum Gap](https://github.com/codereport/array-language-comparisons/blob/main/comparisons/leetcode/P0064_Max_Gap.md) | - |
| 9 | πŸ’› | [PWC198 P1 - Maximum Gap Count](https://github.com/codereport/array-language-comparisons/blob/main/comparisons/pwc/PWC198_P1_Max_Gap_Count.md) | - |

* πŸ’š = All solutions complete
* πŸ’› = Some solutions missing

#### Progress

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