The APL Challenge

87 points
1/21/1970
12 days ago
by bjarteaarmolund

Comments


bbwbsb

The past challenges are available too: https://dyalog.com/apl-challenge.htm

I found working through them was helpful when learning K, and comparing the solutions to other languages can be illuminating.

12 days ago

natas

Man I wish I could use APL at work instead of python & nodejs.

12 days ago

upghost

You can embed GNU APL. I did it once with Clojure[1], tho it wasn't too popular. If they hired you to do Python should probably do that instead of embedding APL into Python. (I don't follow my own advice)

I would love to embed Dyalog but last time I tried I wasn't smart enough. If anyone from Dyalog feels like throwing cycles at it let me know!

[1] https://github.com/jjtolton/libapl-clj

12 days ago

jodrellblank

Dyalog is a .Net language do you can write classes in APL and export DLLs that you can use from C# or F# from something like ASP.Net web servers.

11 days ago

upghost

Very cool! I don't quite know how I would use that to fully embed Dyalog. Very large class..?

11 days ago

jodrellblank

What do you mean by "fully embed"? The integration is a 'bridge', the Dyalog engine stays involved. The simplest way is to make a class and method that takes a string and ⍎ evals it as APL code and returns the result, and call that from C#. From there, you could write more and more APL code and make wrapper methods to expose an API of methods that C# can call.

They have a .NET Interface document: https://docs.dyalog.com/latest/dotNET%20Interface%20Guide.pd...

And more general documentation: https://www.dyalog.com/documentation_190.htm including one for classic Windows .NET (instead of .NET Core) and one "APL As A Shared Library" which is about integrating with other systems using C (making a C .DLL) instead of .NET.

11 days ago

upghost

Ahhh this is fantastic. Exactly what I was looking for. As I said before not that smart, but hopefully a little smarter than I was before. The shared library documents, if I can figure them out, would allow for a libdyalog-clj, which would be extremely exciting. To me, anyway, and maybe like six other people haha.

Thank you, jodrellblank, for being patient with me and for this information.

11 days ago

Qem

Well, there's KlongPy[1]. While not APL, it is built on top of Python and manages to turn NumPy from "Iverson Ghost"[2] status into Klong[3], a proper array language.

[1] https://github.com/briangu/klongpy

[2] https://analyzethedatanotthedrivel.org/2018/03/31/NumPy-anot...

[3] https://t3x.org/klong/

11 days ago

whitten

What aspects of APL do you want to use at your job ?

12 days ago

adrian_b

I do not know about the previous poster, but anyone who knows about APL finds annoying to write tons of superfluous lines of code imposed by the syntax of most popular programming languages in order to express loops, instead of using only high-level array operations, which say only what must be done, without repeating the details well known by any programmer or compiler, about how to do that.

11 days ago

lieks

Just finished it (APL beginner). It's really fun as a game.

12 days ago

abrudz

https://apl.quest might be of interest.

12 days ago

xelxebar

APL Discord is quite active: https://aplwiki.com/wiki/Chat_rooms_and_forums

Dyalog actually allocates respectable resources to helping beginners. In particular, Adám is crazy knowledgeable about APL and extremely available for answering questions.

12 days ago

upghost

Adám is awesome. I'm an avid follower of his criminally underviewed YouTube channel[1].

[1]: https://youtube.com/@abrudz

11 days ago

ydj

I think the facilities for building larger applications are lacking in APL. It would be great as something embedded into other languages. Consider something like numpy’s einsum, but using apl expressions instead. Use APL to express what it’s good at, and use the facilities of the host language to put together bigger systems.

12 days ago

xelxebar

Large parts of Sweden's health system run on APL; Deutsche Bank also uses lots of APL; Denkmark has an appreciable number of companies using APL. IMHO, the problem isn't the scalability of APL (Dyalog, specifically) but more that good, maintainable, solid APL violates what the industry holds up as Best Practices etc. Trying to apply typical software architecture methodologies to APL definitely evokes the feeling you describe.

However, APL in my experience enables radical simplicity for building large applications. Learning to leverage that means that you need to first unlearn lots of ingrained problem-solving habits and ways of thinking as a software engineer. It's admittedly a steep hill to climb.

12 days ago

whitten

Has anyone tried to recreate LLMs in APL ? Matrix multiplication is common in both of them. If LLAMA.C is only a few hundred lines then I would be surprised if the APL is more than a page of code.

12 days ago

xelxebar

A page? I sure hope not. The whole training and inference code for a U-Net architecture in APL is only about 30 lines, with inference direction only taking up 4 or so lines. Assuming you know APL, the code is actually really straightforward and readable, too! Not to mention that it's only ~2.5x slower than a comparable PyTorch implementation.

[0]:https://www.dyalog.com/uploads/conference/dyalog22/presentat...

12 days ago

ChanderG

People have done it. For eg, https://github.com/BobMcDear/trap and few others that I can't find the links of right now.

When I got into BQN recently, I had the same thought and tried my hand at recreating LLM building blocks and saw the compactness APL-likes afford first-hand: https://www.chandergovind.org/blog/5126/aipasi/Array-program...

12 days ago

upghost

Conversely, after many years of dabbling I still consider myself a complete novice at APL and array programming. However, my studying of array langs made learning LLMs fairly trivial. In particular, studying APL's inner product from the Mastering Dyalog book was the key to understanding the self-attention mechanism from Attention is All You Need and how it communicates semantic information across the positionally encoded tokens.

I'd still probably struggle to do anything mildly complex in APL, though, sadly. It hasn't fully clicked yet, but maybe one day!

11 days ago

seafoamteal

I knew APL only by name until today (because of seeing people do Advent of Code in APL) and I'm still not sure how I feel about it, but the challenge was quite fun.

11 days ago