APL – a Glimpse of Heaven (2006)
archive.vector.org.uk
archive.vector.org.uk
When describing APL, people talk about the strange symbols, the mathematics, etc... but I have never seen anyone describe something I only realized after some time: APL makes you approach problems quite differently, when you are familiar with it.
I stopped thinking in 'steps' applied to the individual data points, but rather I solved the problem in my head (and writing the line along the way) by aggregating the data points into larger data objects, and then letting the data objects expand in a many-dimension universe, always larger and larger... and then I simply looked at the resulting mega-thing from a different angle, and started crushing it back along different dimensions until I finally got my answer (and my line completed). The resulting one-liner was very hard to read ... but gave me the correct result.
Inflation, Change of view-point, Big Crush. That is the core of APL.
Yeah I know... sounds crazy. But that was how APL programming felt to me, and I bet I am not alone. No other language I worked with ever triggered in me that kind of mental problem-solving process.
I've been playing with J lately. I've also been a longtime numpy user, going back to the days when it was still numarray. Maybe I'm just writing numpy in J, but I find that my approach in both languages is more or less identical: set up a vector, do some matrix operations, maybe some statistical aggregates, write down the answer.
Can you provide an example for which the APL approach is significantly different from what one would normally do? It might help me understand what insights I'm supposed to gain.
(Note your use of "write down the answer": this is a giveaway that you understand it so well that you're not even aware of your understanding, and might therefore find it hard to explain)
Although SQL is way, way more verbose than J/APL it is still extremely readable, even if the query is massive. Untrained SQL users always point to big queries as some sort of code smell when in fact most queries are logically partitioned by virtue of how they work.
This is absolutely true. People try to make a big deal out of natural language for both programming and simply interacting with computers. Rarely would a natural language description be easier, clearer, or faster than a more precise interface (e.g. text for programming, mouse/keyboard for interacing with computers).
If you are talking about automating every day tasks through "code," then natural language makes perfect sense; the future their is going to be based on increasingly sophisticated dialogue systems in forms like Siri, Now, Cortana.
And, it is not like this is unique to language. Even in math, one often finds a certain lack of precision that is accepted and more cumbersome to work with than without.
Or, mayhap I just misunderstand more than I understand. :) Very likely.
Edit: There is also the issue of a terrible example. If I were to explain a linear function to someone, I would say more that it is a function where the output changes in constant proportion to changes of the input.
y = a * x + b
You could write code like this: height = slope * run + ground
It may not be helpful to write out simple math using colloquial language, but it can be helpful to future maintainers if your variables have meaningful names. Calling it "a variable" instead of "a" is not useful, but calling it "slope" can be.That said, this is always worth watching as a demo of the language's power: https://www.youtube.com/watch?v=a9xAKttWgP4. I'm not afraid to admit that I wish my language could do that.
The thing is, I'm a C++ dev professionally, but whenever I see his code in APL, I cringe. I can't get to make him understand that building what is basically a dynamic spreadsheet in APL is kind of complicated for me, coming from an OO side of programming. Also, that's the only language he knows.
I have a hard time telling him that all the work he did and still does in APL (I guess now there are like thousands of lines) will just go to trash and my uncles will just use Excel to do that when they'll take over the forest business.
Edit: I have another issue with DyalogAPL. When my grandfather sends me a workspace , I can't open it because DyalogAPL is not that much backward compatible ! So if we don't have the exact same version, I just can't open his workspace. It's 2014 , damn !
Maybe github instead?
http://lemire.me/blog/archives/2014/05/23/you-shouldnt-use-a...
It can actually be fun learning radically different programming languages. I find it improves my programming in my primary language. And you're in the lucky position of having someone who can help you learn.
i have basic, z80/x86/pic asm, forth, pascal, c, rebol, bash, awk, ruby, js experience. i've seen the game of life live coding demo a few years ago and also played with j while it was still closed source. to put it into perspective, im only 38yrs old.
after reading this glimpse of heaven apl article, its vibe hit me so im circling back to apl for the 3rd day already. i find it fun and elegant. the the keyboard layout is not an issue either; ⍳⍴×←=⍺⍵⌈⌊ were all very natural after a few minutes.
i would say, u would benefit greatly from learning apl. it's definitely not the past.
just have a look at the nile language for example: https://raw.github.com/wiki/damelang/nile/socal.pdf
bret victor wrote a nice interactive visualizer for it in js: http://tinlizzie.org/dbjr/high_contrast.html
cool shit is coming up and you will be left out if the only thing is c++ which you are comfortable with...
also it sounds quite heart breaking how you discount your grandfather's work... kinda disrespectful... and you are even wasting his time left on earth by recommending him to learn python? just spend a few hours with apl and it should be clear to you too why did he say python sucks. maybe try to implement a bit of his code in python or on a spreadsheet. that should be quite informative (and probably transformative) too.
1) APL clearly made good use of an extensive symbol set. Now that many languages support unicode, this is totally do-able.
2) APL is in love with overloading. It's not totally my cup of tea, but you could definitely fit this into many modern languages.
3) I see a whole lot of MATLAB in there.
4) Did... this article actually define any functions at all? Perhaps I missed this.
5) It looks you could easily implement APL as a DSL within an existing language with an extensible parser. Racket, for instance.
∇ R ← Average V
[1] R ← (+/V)÷(⍴V)
∇5) You'll perhaps lose some power. Notation is important - check Ken Iverson's Turing lecture.
I'm working on something along these lines, but not planning on keeping the APL/J-like syntax (the many meanings of juxtaposition makes parsing a line depend on the run time values attached to names). You can get more of the core idea of APL out of prop:procedure than out of extensible parsing.
The fluent interface is likely to win because I don't want to implement hook and fork.
I would say that K:J is like C:C++ in terms of complexity (not of heritage). I personally prefer the K and C to J and C++ but to each their own.
and
Yes, I'm advertising my own work here.