APL & Array programming

Not gonna lie, I was hoping we’d see some demo of a toy neural network but it’s all the same, I love obscure programming languages and looking forward to learning a little bit more. Plus I don’t think APL can talk to CUDA natively, but I could be wrong.

Nope, but there is a GPU dialect: GitHub - Co-dfns/Co-dfns: High-performance, Reliable, and Parallel APL

There’s also a J binding to Arrayfire, although no docs I can see (other than some rather concise tutorials): GitHub - jsoftware/math_arrayfire: Arrayfire addon

4 Likes

I think I assumed that somehow, given that J is sometimes sold as “APL, but without all the need to learn dozens of extra symbols”.

In J you just have to learn dozens of digraphs instead. The APL symbols actually have pretty good mnemonics – so far on the whole I haven’t found remembering them particularly challenging (not that I know many yet!)

2 Likes

Yeah I imagine it’s probably the same as learning a new (human) language where often a new alphabet is a huge hump for people.

Installing Dyalog on Debian 11

I’ve logged my steps installing it; hope this helps.

Short story

You may need to install the packages libtinfo5 and dotnet-runtime-3.1 via apt

Log

Downloading the .DEB package file from https://www.dyalog.com/download-zone.htm

sudo dpkg -i linux_64_18.2.45405_unicode.x86_64.deb

If I do dyalog --help however:

/opt/mdyalog/18.2/64/unicode/dyalog: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory

ldd /opt/mdyalog/18.2/64/unicode/dyalog indeed confirms: libtinfo.so.5 => not found

locate libtinfo.so.5 returns nothing, but locate libtinfo.so.6 does.

apt search libtinfo shows that major version 5 (legacy) is available. Should be fine to install side by side with 6. Let’s try

libtinfo-dev/stable 6.2+20201114-2 amd64
  transitional package for libncurses-dev

libtinfo5/stable 6.2+20201114-2 amd64
  shared low-level terminfo library (legacy version)

libtinfo6/stable,now 6.2+20201114-2 amd64 [installed]
  shared low-level terminfo library for terminal handling

If I do dyalog --help however:

CLEAR WSIt was not possible to find any compatible framework version                                                                                                                                                      
The framework 'Microsoft.NETCore.App', version '3.1.0' (x64) was not found.
  - The following frameworks were found:
      6.0.6 at [/usr/share/dotnet/shared/Microsoft.NETCore.App]

You can resolve the problem by installing the specified framework and/or SDK.

The specified framework can be found at:
  - https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=3.1.0&arch=x64&rid=debian.11-x64
Init failed: 0x80008096

If you do not have dotnet already installed https://dotnet.microsoft.com/en-us/download explains how to set up .NET on various platforms including Linux. after that:

sudo apt install dotnet-runtime-3.1

dyalog then starts OK (in TTY mode).

3 Likes

I have only watched a few of tutorials so far, but honestly, I love the symbols and they’re kind of self explanatory once you know the background. I find J’s symbols to be rather distracting and not so aesthetic. From the background on APL that I’ve gleaned, it seems this is a “tool for thought” for experts and it seems to me that Physicists and Mathematicians already either know the greek symbols or they’re quite comfortable with the idea of symbols denoting abstract concepts (to manipulate larger abstractions.)

The only thing that throws me off so far is that I feel there aren’t enough spaces in what I think is referred to as “trains” or string of symbols that build up a given expression. Having everything all together throws me off. As a beginner, I would break down parts of a larger expression into smaller digestible chunks assigned to intermediate names, and then build the larger expression at the end.

2 Likes

Using Dyalog APL in Debian Linux and its Derivatives

by Rito Ghosh

I use Pop OS 22.04 LTS edition. But this tutorial should work with all Debian-based Linux distributions.

Using Dyalog APL in Windows is trivial, but with Linux, there are one or two extra steps.

NOTE: Dyalog APL runs on Linux only on the Terminal (TTY mode).


Step-1: Download the Dyalog APL Set-up File

  • Navigate to the official download page. Then you will have to accept their terms.

  • Then you can either choose to register yourself with Dyalog or download the product unregistered.

  • The free license is good for everything outside of commercial use.

  • Download the .DEB file from the page.


Step-2: Install

  • Install the downloaded DEB file. Either let your package manager handle this via GUI by double clicking or use dpkg. You might need elevated permissions.

Step-3: Install Missing Libraries

It is very likely that you will miss one or two libraries that are required.

You will most likely miss libtinfo.so.5. You can installing it using apt.

sudo apt update && sudo apt install -y libtinfo5

(source)

This will install the missing library.

You might have another missing library dotnet-runtime-3.1. I did not face it. If you do, just installing it via apt will solve this problem. See more: jmp’s post on fast.ai forums.


Step-4: Installing Keyboard Support

APL uses a lot of special characters, "glyph"s. And you need to type them to be able to use APL.

This is trivially easy.

Before you start Dyalog APL, you need to run the following on terminal:

setxkbmap -layout us,apl -variant ,dyalog -option grp:switch

(see explanation here on aplwiki)

This command sets the Right Alt for typing glyphs rather than the Control key.


Now, you are ready to work with APL.

asciicast


I will add new sections if needed. Let me now if you face any problems.

6 Likes

I tried some basic operations in Dyalog APL. However, my results started from 0 instead of 1. Any idea to fix it? (I am using the Windows version) :thinking:

Example: per tips
image

My result:
image

In Learning APL they set it to start from 0 with this command:

⎕IO ← 0

2 Likes

To start from 1:
⎕IO ← 1

1 Like

For all those on Linux, I highly recommend installing RIDE, as it gives a much better (and GUI) IDE than the TTY version, with hover-for-info/click-to-insert language bar, and out-of-the-box keybindings (e.g. `i for ). On macOS, this installs as part of the package.

7 Likes

Just wanted to point out, this is the magical bit! :slight_smile: If you want to get the jupyter kernel running you need this installed!

I was trying to get the kernel to run on WSL, but not a whole lot of luck. I installed dyalog and followed the installation instructions in the apl kernel repo, but was getting weird errors.

Once I installed libtinfo5 it all started to work :slight_smile:

Thx for sharing this @rghosh!

6 Likes

For those using the APL language bar: backtick followed by space gets me an actual backtick on MacOS

5 Likes

Super easy install of APL Kernel on windows with miniconda following apl kernel repo instructions.

APL, C/C++, CUDA, R, Julia, <your_language_here>…python libraries with nbdev, blogs with fastpages, the list goes on.

Jupyter Notebooks is the gift that keeps on giving!

3 Likes

I’ve just published my notes from today’s session in case its helpful for anyone else :slight_smile:

5 Likes

Very nice. I’ve just created a wiki topic for the lesson - wanna put it there?

1 Like

I’ve created a GitHub repo for the study group and put today’s notebook there:

I plan to keep updating this notebook as we go.

3 Likes

Handful of APL dyadic functins (plus/minus/times/divid/power) can be replicated in Excel when using Name Manager (a form of variable assignment). No wonder it looks natural to me. :star_struck:

image

image

3 Likes

I wonder if monadic and dyadic are the same as unary and binary operators?

1 Like