182 points · by okaleniuk · 8y ago · 118 comments
APL will not be reborn. If that was going to happen, this century's embrace of analytics and linear-algebra-rich machine learning would have propelled the upswell. It didn't and it won't.
Why? It's not the symbols. Not the keyboard. Nor the learning curve. Nor the lack of standardization, libraries, or GPU support. These are collateral damage, not primary drivers.
APL will not flourish because it is effectively a DSL with archaic I/O capability. It is a nearly-pure functional programming language. It's primary domain is mathematics. Native GUIs, networking, the web -- all uncompetitive add-ons.
In this sense, APL and Haskell share some DNA.
For dynamic systems modeling for my thesis, I reached for APL and Matlab. I still code Dyalog APL for recreation. Love it. But I wouldn't build a web app with it and a wouldn't run my company on it.
Another sense in which i think APL is... un-competitive is that its strengths (terse, mathematical, matrix-centered) are the easy parts of programming, i.e. the parts that are the most objectively quantifiable and verifiable (you just use math).
Accounting for numbers is trivial, accounting for human factors is a proverb.
For fun I'm writing a "spreadsheet programming language" that borrows a little from array languages, and I think there's useful stuff to take away from them.
They make you focus on the data, and the transformations you want to effect on the data.
They make you think, "where there's one, there's probably many."
The implicit mapping over arrays for most functions and operators is a massive ergonomic win over "a formula for each row" in the spreadsheet model. (Excel "array formulas" but not shit.)
Some of the simple little abstractions are beautiful. Seriously, as someone who didn't know anything about array languages three weeks ago, I say go spend a day reading the first two parts of the J book (http://www.jsoftware.com/help/learning/contents.htm) up to "Rank". It's this humble little operator that makes the whole language sing and fit together masterfully, and I'm heartbroken my language's data model (and programming style) isn't a good fit for it.
Really, though, for me being able to have my (still hypothetical) non-programmer users type
organisations[users.orgId]
instead of users.map(({ orgId }) => organisations[orgId])
is a no-brainer. Ditto just about any place I might want to use an anonymous function in JS, really: sort(people, by: people.age)
vs sort(people, ({ age }) => age)
So simple. Pass an array of things to use as the sort key, not "a function to call on each item-to-sort".Forget the cryptic syntax, "operator ambivalence" and math/matrix-focus, there's a lot of useful stuff in there that should be better known in language circles.
As for the grandparent's complaint of being "nearly-pure functional", that's the zeitgeist now -- functional transformation of data, with big ugly explicit data-replacement as the mutation story. That's not an impediment to use, it's an encouragement to use responsibly while not being too much of an encumbrance if you want to walk off the beaten track.
Of course, a lens is really just a pair of functions in disguise, so it wouldn't prevent you from sorting my more complex functions if needed.
function by (key) {
return function (obj) {
return obj[key]
}
}
// sort(people, by('age'))This fact caused me to think: should stack also not be made of other languages? Is there a place for a completely pure functional language? I mean, Haskell is nice, but get a bit awkward with I/O. Same for APL. C# has nicely integrated data querying, but from a distance is actually at least somewhat awkward. C# seems to be optimized for mutable domain objects; everything else can be nicely done but falls somewhat outside it's "identity".
I would love to be able to express functions, functors and math using a terse math-y language. Whether that be APL or some sort of blend of Haskell and APL (Haspell? spelling pun intended), I don't care, but it would be great if we can have nice integrations of these languages in a full stack. Sort-of like how TypeScript and JavaScript have dialects to enable React syntax to express HTML within it.
The same thought experiment can be applied to SQL. Can we have a data-querying language integrated right into, say, C# or Java?
I tend to write raw SQL using Dapper these days, because hey, scalability and such, but for business apps and non-cloud apps, EF and other LINQ-based DB tools are great.
I am a fan of "Table Oriented Programming" and believe OOP forced an unfortunate shift from data-oriented programming to code-oriented programming. I hope the pendulum swings back. APL is intended for mostly scientific applications, but it has some nice lessons for other domains, and RDBMS may be a door into common data-oriented programming.
I also believe that "Dynamic Relational" is needed to improve data-oriented mock-ups, experiments, and small-scale projects. The existing RDBMS are too "stiff" for some needs. We have dynamic programming languages, so why not for databases? Yes, there are some dynamic query languages, but they require throwing out SQL and starting from scratch, which cranks up the re-learning curve. Dynamic Relational only requires minor changes to SQL. (SQL ain't perfect, but so far a decent replacement has yet to gain traction. I'm personally a SMEQL fan.)
Having a part of the program known to be pure at compile-time, but another part effectful is something you see in the language F* (http://fstar-lang.org) - here you get monads, dependent types, a proof system, and the ML module system neatly packed into a general-purpose programming language.
Not as widely popular as O'Caml, F# or Haskell, but both as practical as Ocaml and as researchy as Haskell.
Also there's a free tutorial/book on the website.
In the early 80's I experimented with Prolog. Simple ideas were simply coded into programs; it was really very interesting. However, the need to understand the compiler's inner workings to get programs that ran efficiently by manually inserting "cuts" to limit backtracking ruins Prolog's claim to being simple to translate requirements into programs.
An even more serious problem with Prolog is the simplicity of it's model for logic. It is very easy to end up with requirements in the real world that don't easily fit the model. See for example the SHOOT problem in [1], where the concluding sentence is:
> As such, the claim implicit in the development of nonmonotonic logics--that a simple extension to classical logic would result in the power to express an important class of human nondeductive reasoning--is certainly called into question by our result.
Don't get me wrong, I was the Chief Scientist at a company with one Prolog based product. I still thinks its an interesting language, but I predict that it will remain eclipsed by much more general purpose programming languages.
Where does this claim come from? Prolog is an automated theorem prover for first-order logic theories. There have certainly been various arguments about the pros and cons of it made by many different people (not all of whom were close to the development of the language), but the fact remains that its main characteristic is the automation of a proof process.
You can certainly find many flaws in Prolog if you look hard enough and choose your requirements carefully (for example- it has no functions! Why has it no functions? It should have functions! Therefore, it sucks).
I think a lot of the bad rep Prolog's got over the years is the result of promises by various sources that had nothing to do with its actual goal, which was to create a language with the syntax and semantics of FOL- which it achieves not perfectly, but way, way better than anything else out there.
>> I still thinks its an interesting language, but I predict that it will remain eclipsed by much more general purpose programming languages.
That's probably true, though :)
Once hardware keyboards standardized around ASCII in the '70s, it cramped the promise of APL's custom notation. On touchscreen it's trivial to render a software keyboard that contains the entire symbol set (perhaps even adapted to the user's experience level to make it less scary initially?). Increased resolution could be used to make the programs easier to parse visually by e.g. scaling symbols based on their context and nesting level, just like we do in math equations.
I'd like to work on an open source APL variant that runs on iPad and/or touchscreen Windows. It should be aimed at entry-level programmers because they don't have the imperative mindset strongly ingrained yet. It would be interesting to see if "touch APL as first language" could be a viable approach to teaching programming. Just need to find the time somehow... :/
(If there's one thing I've learned in my career, it's that you can't change developers' minds about anything fundamental. We are extremely stuck in our ways, myself included, and all too ready to pretend that tiny incremental changes in syntax or tooling are revolutions.)
That's a great idea. I can see it working in other languages as well, e.g., what Guy Steele and others were trying to do in Fortress.
APL programming on a touch screen sounds like it would be better than regular programing on a touch screen because the terseness in that context is much more appealing -- it's a lot nicer to enter a few symbols from a software keyboard than a few words on a touch screen, which isn't at all the case for programming on a regular keyboard.
(searching for 'apl iphone' is going to suck, though)
There is this:
https://github.com/Co-dfns/Co-dfns
But it's not quite it.
As for the word 'deserve': computer languages don't really deserve anything, they get adopted, or not. APL is a beautiful language and it gives me immense pleasure when I 'get' a program but the barrier between 'the problem' and 'the solution' hinges on libraries, eco systems and communities. I suspect that APL's window of opportunity has passed and even if Clojure became 'a modern lisp' and Elixir became 'a modern Erlang' I don't really see a big driver behind 'A modern APL'. What would it do that can't be done in other ways?
...however, it is not easy. Full APL has a lot of features (like nested arrays) that are incredibly difficult to map to GPU execution. And in general, APL is not easier to map to GPUs than your bog standard Numpy-style matrix library (in fact it's harder, since Numpy only has regular arrays and simple operations).
[0]: I was involved in a project that targeted only a small well-behaved subset of APL, which was hard enough: https://github.com/henrikurms/tail2futhark
It could not be compiled on 64-bit machines, because of some ancient programming practices that were used throughout the code.
I took some time to update apl\11 so that it compiles and runs on modern machines.
Did a few other things as well, such as replacing linear algorithms in the symbol table code with O(logN) algorithms.
I would refer to this project as "heirloom software". It is touchingly old-fashioned in some ways, a bit dusty, and still fully serviceable.
It is a bit like owning and flying an Ercoupe. A bit quirky, an ongoing effort of love, but a joy to fly.
Edit your apl with vim, run apl files like scripts from the shell, pipe inputs and outputs, copy an APL binary or build it anywhere with a C compiler, run it immediately and conveniently.
My take on the 'funny characters problem' was to go with touch typing, and stick with ASCII. If you can write APL with your eyes closed, you can use APL-touchtype. "rho" is "R", "iota" is "I", etc. Trig is "O". Log is "O@*". (APL-touchtype uses "@" instead of backspace, and with that trivial substitution, all of the APL overstrikes become APL-touchtype ascii.)
It is ABSOLUTELY a work-in-progress, but anyone who wants to is welcome to give it a try:
https://github.com/gregfjohnson/apletteIt looks like a bunch of matrix and vector functions with very terse names. Is it significantly different from just taking GLSL, say, and #define-ing one-character names for all the built-in functions? What is APL’s secret sauce?
This article suggests that a lot of the fun is just the cryptic symbols themselves. That’s absolutely fine, but it doesn’t seem like something that “deserves” a renaissance, compared to, say, Lisp, which really does have a uniquely productive idea at its core.
Is it just a set of well-chosen matrix operators? I would have thought that could be done in a library, rather than a language.
In a semantic sense, the key idea is that you compose operations on array indices. A good example of this is k's where operator, &, which converts an array of booleans into an array of indices where it is true. It's very common to take & of some predicate on your inputs, manipulate that for a while, and then index into something else at the end.
There are also ideas of rank/shape ambivalence, which naturally encompasses broadcasting (so scalar + vector broadcasts the scalar, vector + matrix broadcasts the vector row-wise, etc).
You certainly can implement something with APL's semantics as a library - Numpy does this. The magic of using APL comes from having all these features at once.
Some of the code CAN be quite terse (and cryptic) like
quicksort=: (($:@(<#[), (=#[), $:@(>#[)) ({~ ?@#)) ^: (1<#)
I spent a small amount of time learning the basics a while ago, but never really used it for anything. But it was interesting and I'd have to spend a lot more time with it to get into the mindset. Popular with some Code Golfers as well.
Please, no. Glyphs / characters are not a scarce or constrained resource in software development. The major resource constraint is developer time spent writing, reading and debugging code. APL (and its descendants) are specifically designed to make these challenges far more difficult than they need to be.
"Notation as a Tool of Thought": http://www.jsoftware.com/papers/tot.htm
It reminds me a bit of SQL Databases, in that the more indexes and constraints you add, the more the query execution can draw from to change the route a calc takes in order to try and do it more efficiently.
(One reason the MCM/70 wouldn't have had BASIC is that its development predates BASIC Computer Games https://en.wikipedia.org/wiki/BASIC_Computer_Games , apparently the original, 1973 publication of BASIC listings. Those were all games written on and for the Dartmouth BASIC system or other DEC microcomputers. I think (I am not an expert) it was probably this corpus, and its publication in a readily-available book, that originally drew microcomputer systems like the ALTAIR towards supporting BASIC.)
But the beam spring was awesomer ;-)
Also the Model F is a monstrous beast of a keyboard, that would make even a regular model M seem compact.
I just want an industrial (gray) Model M Space Saver. I'd get one but I still need to think of a good argument to use with my wife over a $600 keyboard...
The guys at Unicomp were musing around the Space Saver layout. Not sure if they have the machinery, or the funds, to do the tooling to build it.
Otherwise there's ipc clients, and a very nice native python integration now.
Thing is, when I was thinking about trying it, I never figured out a good toy project. Like, when I wanted to try anything else, most of the time I would know I would be able to cobble together a web-service. Haskell, Erlang, even Prolog.
I understand co-dnfs to be self-hosting, so maybe a toy programming language?
Writing a programming language in APL is not for the faint of heart - co-dfns is, alongside it's performance goals, to show that compilers aren't necessarily a bad fit for APL.
What I'm craving is APL for TensorFlow...
https://www.youtube.com/watch?v=XVv1GipR5yU
And since you can define your own operators, you could just go all of the way.
https://gist.github.com/ityonemo/6512f3b4fd02b9a9cc292cf0f88...
also string macros are cheating!
GNU APL also supports a library version (libapl.so) which allows APL2 to be incorporated into other applications via C ffi. This is my primary use case -- interactive development followed by delivery via libapl.so.
I have read before (sorry, I do not have the link) that Arthur Whitney does not really believe in open source. That is unfortunate (and a mistake, if you ask me). Even if he did not release a complete product, I would like to study his code. Reading and trying to understand kparc.com/b/ is a very enlightening experience. I wish k.c was there too.
However, the language did not stand the test of time for far more important issues than the inconvenience of the character set and the keyboard.
And, no, J is not a successor to APL, even though Iverson created it. J is an abomination. He made a mistake. He thought that abandoning notation --which is incredibly powerful-- would solve the APL popularity problem. What he ended-up creating was a royal mess of the first degree. It's garbage.
APL could be very useful today but someone with the time and context needs to organize an effort to evolve it into a modern language that retains the power of what got branded as a "tool for thought" while adding layers of functionality that are sorely missing. I wish I had the time to embark on this journey. I would love to do something like that, but I can't.
Again, the character set and keyboard are not the problem. I used to touch type APL. Didn't take that long to get there. People learn to drive vi/vim. It's a matter of having to have a reason to make the effort.
And the ecosystem. That's another huge issue.
This has two aspects:
Finding qualified programmers and having access to libraries so you don't reinvent the wheel.
Back in the day I used to do a lot of work with Forth as well. Great language for the right applications, but finding qualified Forth programmers was difficult when the language was popular and it became nearly impossible with the passage of time.
APL suffers from the same problem, a seriously limited talent pool.
I probably don't need to explain the value and power of having libraries to support a wide range of applications. Python is a good example of this today. You can find a library to do just about anything you might care to approach with Python, from desktop through embedded and web. In many ways the breath and depth of available libraries an be far more important than language capabilities and sophistication. After all, if you had to write OpenCV from scratch there's no amount of APL magic that is going to make you more efficient and effective than a 15 year old kid with Python and OpenCV.
I see APL mentioned on HN with some frequency. I feel that some here are in love with the idea of APL rather than understanding the reality of APL. Again, I love the language, but there's a reason I stopped using it about 25 years ago.
What's interesting is that C, which I started using way before APL, is still around and very solid language (with lots of libraries) for the right applications.
Lots of niche languages have the same problem, notably lisp, but it doesn't do to say they aren't popular for those reasons. It's circular reasoning. Languages get those things by being popular. They get popular by having those things.
Every current "popular" language with good libraries and a large userbase started with no popularity, no libraries, and no users. They built these things over time.
The problem is these languages can't create a robust community. They are powerful, so people don't need large teams to do what they want. They are different, so it is a bigger investment to understand them. The combination means they attract the kind of elitists who are not willing to help newcomers or write basic libraries, the kind of people who are perfectly capable of reinventing every wheel and doing it better than last time.
No one teaches these languages. How popular could they get if companies and universities spent millions of hours collectively drilling even the most marginal programmer on how to use them like they do for C++ and Java?
They would never do it though. Large companies don't want more powerful languages. They will take the productivity loss for fungible employees. It's part ego. Middle managers look much more important if they have 20 programmers write 1,000,000 lines of code over 5 years than two programmers write 10,000 over six months even if functionality is equivalent. It's part bargaining and risk. If you only have a few programmers, the individual programmer is worth a lot more. It is also riskier to employ one because she could leave or get hit by a bus at any time.
Maybe it is but it's reality. Also, there's the other kind of reality: Languages don't matter. Solving problems is what matters.
I've programmed in everything from Machine Language (note I did not say "Assembler") to APL, passing through languages like Forth, C, C++, FORTRAN, Objective-C, Lisp, PHP, JS, Python, etc. At the end of the day the ONLY thing that matters --if it isn't a hobby-- is solving problems computationally. I have no cult adherence to any language whatsoever. They are tools, that's all.
My best example of this was making tons of money solving a problem using Visual Basic for Applications, which allowed me to use Excel to automate a time consuming task in a CAD program. It just so happened that this CAD program could be automated using VB. Put the two together and several months of work and we had a tool worth quite a bit of money.
APL still has lots of value...in the right circles. I believe it still sees professional usage in the finance industry.
Schools and universities have been teaching Pascal/Lisp/Caml/Scheme for decades, yet (almost) nobody used those languages to produce actual software, neither as a job nor for free software side projects; and a majority of jobs implied the use of a member of the large C family (or VB at the time).
http://www.eecg.toronto.edu/~jzhu/csc326/readings/iverson.pd...
I remember watching Iverson deliver a presentation in person about this very topic.
Anyone familiar with fields such as mathematics or music understands the power of notation. The integral symbol conveys information and allows you to think about the problem rather than the mechanics.
APL in early times suffered from a unique problem: You had to physically modify your computer and printer to be able to do APL. You had to remove and replace the character generator ROM from you graphics card (who remembers those cards?). You had to get a new keyboard or put stickers all over your standard keyboard. And you had to change the print wheel or print ball (IBM printers) to be able to see, type and print APL characters.
It was a pain in the ass. Only the most interested cult members endured that level of pain for an extended period of time.
Years later Iverson decided to transliterate APL symbols into combinations of standard ASCII characters. This was a knee-jerk reaction to the above stated problem. What he did not have was the vision to recognize that technology would take care of this on its own. Not long after the introduction of J everyone could display and print graphics of any kind. The APL character set, the symbols, ceased to be a problem in that regard.
Iverson took the wrong road with J out of --conjecture on my part-- commercial interest rather than language interest. He violated something he personally talked about: The value of notation as a tool for thought.
J doesn't need to exist. If we are to evolve APL and move into a world where symbolic programming is a reality (something I think would be very powerful) we need to move away from typing ASCII characters into a keyboard and move into a paradigm where advanced software engineering has it's own notation that can be used to describe problems and create solutions with the kind of expressive power we have not seen in mainstream computing in years.
(Although truthfully I don't think that char set will ever fly in a broad commercial sense)
"As long as our hypothetical Blub programmer is looking down the power continuum, he knows he's looking down. Languages less powerful than Blub are obviously less powerful, because they're missing some feature he's used to. But when our hypothetical Blub programmer looks in the other direction, up the power continuum, he doesn't realize he's looking up. What he sees are merely weird languages. He probably considers them about equivalent in power to Blub, but with all this other hairy stuff thrown in as well. Blub is good enough for him, because he thinks in Blub."
It would definitely work though.
If there is a conflict with an existing feature you could always create a Slang. A Slang is a module that changes the parser. (It could be argued that with this feature all programming languages are a subset of Perl 6)
https://www.cs.ox.ac.uk/people/jeremy.gibbons/publications/a...
http://www.ccs.neu.edu/home/shivers/papers/rank-polymorphism...
If you mean "type" rather than "paste", well that's more complicated.
gsettings set org.gnome.libgnomekbd.desktop load-extra-items true
in a terminal will make it show up, then you just set it to toggle with some button.That's pretty much how I'd want to use it, and the only way I'd bother. It's cool tech but it's general purpose appeal is nonexistent and there is already Julia and Matlab in technical computing space.
If I could draw APL symbols and have some common libraries for JSON and Http and stuff like that, I could see a renaissance having enough steam to do something.
Otherwise, it's only the top gun high level nerds that already use it anyways, that would want to work in non-ascii. Modern developers seem to have an ever decreasing attention span these days.
How many developers under 25 use vim? It's always less than it was last year.
:(
So, I've never written apl, and I'm glad I read this comment because that's an excellent point you raise.
To expand a bit, I was thinking about being able to notate computation graphically. That's really what I want. Visual programming has existed and has sucked forever, but those thoughts don't go away that there might be a way to do it, if I just had the missing piece.
I need to sit down with dyalog and find out what I'm missing, it sounds like.
Thanks!