
April: An APL That Compiles to Common Lisp - kick
https://github.com/phantomics/april
======
kick
April is really neat for a few (in my opinion, obvious) reasons. Some
highlights:

Like most modern APLs created by "outsiders," April is k-influenced in some of
its additions to the language:

[https://github.com/phantomics/april#unique-language-
features...](https://github.com/phantomics/april#unique-language-features-in-
april)

It's probably the most portable non-ASCII/touchtype APL interpreter outside of
the Javascript ones:

[https://github.com/phantomics/april#automatic-
installation](https://github.com/phantomics/april#automatic-installation)

(That covers basically every modern system with an MMU, as far as I'm aware.)

I'm not sure if it has a possible audience of both Common Lisp programmers
_and_ APL users, or a maximum audience restricted to people who know them
both. In any case, it's really cool, even if the collective audience for it is
maybe two dozen people.

~~~
cosmojg
> In any case, it's really cool, even if the collective audience for it is
> maybe two dozen people.

Out of curiosity, are you part of that audience? And if so, what was your
experience playing with it? Is it a good place to get started with APLs or
should I look elsewhere?

~~~
kick
Great questions!

I wouldn't really say I _use_ Common Lisp (I wrote a few interpreters for a
few Lisp dialects as an adolescent, including for CL, but haven't really ever
casually used the language itself for anything outside of demonstrating
concepts to other programmers).

April is fun to play with, but I wouldn't really recommend it for getting
_started_ with APLs. It was missing a few things the last time I played around
with it.

The way I'd recommend you learn APL is through J's "Labs" feature, which is
effectively an interactive set of lessons inside of the J REPL, written by
some amazing people (including KEI himself).

Grab a copy of J (I'd recommend getting a copy from the website, because most
distributions I've used package it poorly if at all), then run:

    
    
        jx 0
    
    

After that, you can basically just go along with what it tells you. They're
all listed by number, so if you want to come back to the lesson you're on
later, just check what the number of it is. You can even search through them:

    
    
        jx ''
    

will list categories for them,

    
    
        jx 'categoryName'
    

will list the labs within the category.

From there, learning shouldn't be _that_ hard, though learning resources for
APL in general still aren't where I'd like them to be.

------
lbj
Ah the memories. I attempted to integrate J-lang into Clojure at one point.

Imagine doing

(defn average [coll] (j +/ %#))

And have it run at the speed of C :)

(I failed because I didnt have the patience to sort out all the type-casting)

~~~
earenndil
> And have it run at the speed of c

Unlikely; clojure runs on the jvm (or on top of js), and interop with c is
slow.

~~~
gmfawcett
If you're on the JVM, and if you're compiling J down to JVM bytecode (much as
April compiles APL -> CL -> machine code), and if your data is stored in
primitive Java arrays, then you'd get pretty close to C speeds. Or at least J
speeds (where J is implemented in C).

That's a lot of conditions, but it's not completely crazy. :)

~~~
earenndil
Maybe. Java is quite fast, but for very different reasons than APL; I don't
think it would transfer that easily. Part of the reason APLs are so fast is
because the interpreter and all the code fit in cache; my copy of k is 76kb. I
don't think there's a _chance_ you could get that with the jvm. APL also
relies heavily on SIMD, and I don't know how well-supported that is on the
JVM.

~~~
gmfawcett
Granted, those are fair points. My copy of J is 42KB, so I understand where
you're coming from. :)

There's some support for vectorization in the JVM, e.g. [1, 2], but I suspect
it's hit-or-miss.

[1]
[https://bugs.java.com/bugdatabase/view_bug.do?bug_id=6340864](https://bugs.java.com/bugdatabase/view_bug.do?bug_id=6340864)

[2]
[https://bugs.java.com/bugdatabase/view_bug.do?bug_id=7192383](https://bugs.java.com/bugdatabase/view_bug.do?bug_id=7192383)

------
natas
amazing work

