APL is very nice. If you find it interesting, there are two descendants:
J, which drops the special characters in favor of ASCII, and tries to retain (and improve on) APL's elegance with respect to math.
K drops the special characters and a lot of the data structures, functions, operators and syntax, and tries to be as pragmatic as possible (including speed).
K programs tend to be 30-50% shorter than the equivalent J or APL program, and much faster than APL (although comparable to J).
If you prefer Ada or Pascal to C, or Haskell to OCaml, you'll like APL or J better.
If you prefer C's shorthand to Ada's verbosity, and OCaml's pragmatism to Haskell's purity, you'll like K better.
I like K better.
By beagle3 12 years ago
I too like K better but it is nice to see another APL implementation and a free one at that. Also note that dyalog has made their commercial APL available on the RaspberryPi.
The open source "kona" is close to K version3 (no longer available from kx.com as they have moved on to Q, another very powerful array / database language). So far kona is only 7.2K lines of C code though admittedly very dense code (it is sort of like writing K in C!).
By bakul 12 years ago
You are probably aware, but just in case: K (v4) is underlying Q. You can get to it by typing a single backslash followed by enter (or alternatively, prefixing a line with "k)", or loading a script that has the .k extension)
K (v5) is shaping up here http://kparc.com/ . Still early, but it looks like if Arthur Whitney ran the STEPS project, it would be closer to 2,000 lines, than to 20,000 ...
Holy cow! I am floored that they are doing that. That is a hugely ambitious departure from the high-end enterprise niche they've always been limited to. How exciting.
> J, which drops the special characters in favor of ASCII,
> K drops the special characters and a lot of
I've covered this at length before [0][1][2][3].
Calling J and K improvements over APL because they do away with APL's symbolic notation (which is a powerful tool for thought) is like saying that transliterating an orchestral score into randomly chosen ASCII characters is an improvement. Let's take the whole note and represent it with an "o", a half note will be ".", eight is ",", sixteenth is "`" and so on. Let's also ASCII-fy all other elements of the notation. Slurs could be a grouping of the above characters between parenthesis, like this "(o,,,,````````..). I could go on.
It's ridiculous.
Musical notation is a fantastic tool for the expression of, well, music and if you know it well, it is one of the tools you use to think about your music. You can read it, write it, sing and imagine the music in your mind, all from this notation. APL is the same. If you know it. If you don't take the time to master musical notation it is either gibberish to you or it is really thick and dense, almost impenetrable and decidedly useless as a tool for thought. The same is true of a language like APL.
J came at a time when doing custom notation was difficult. In the early days you had to use specialized terminals (as in real terminals, not terminal emulation software) and go as far as installing custom ROMs in graphics cards in order to be able to display the custom font. In that context it is easy to imagine someone thinking that ASCII-fying APL was a good idea. And, in the process, rip out the most important tool in APL: the power of notation.
I'll have to play with GNU APL. I am glad to see this happen. Not necessarily thrilled that it is written in C++. This could open the door to exponential gains in programmer productivity [4] for writing web applications. As I mentioned in [1] there's a huge list of evolutionary changes that could really take the APL concept to a whole new level. Who knows, maybe this is the start of a comeback of sorts.
[4] An experienced, capable and well-rounded APL programmer can easily do the job of five to ten programmers in C-like languages. The productivity gains are hard to believe until you've experienced both ends of the scale yourself. As an experienced C programmer I could never even hope to produce code fast and accurately enough to keep up with what I could do in APL with just a few lines of code. It's not about coding speed but rather the speed at which ideas can be translated into working solutions.
By robomartin 12 years ago
When it comes to notation, there is always a tradeoff. The question is, what's worse?
In my meager opinion, APL was plagued with acceptance problems from the very beginning. Note that acceptance is a very personal thing, free of such diverse distractions as logic, reason, the right thing, and so on. Having used APL for nearly 40 years and having made a decent living with it for nearly 35 of them, looking back, a significant fraction of my projects could be called "APL Exit". Whether it was a customer leaving a timesharing service for something cheaper, or a corporate mission to migrate to a different, allegedly standard, technology, APL was being replaced by something else. The language was thought to be declining, dying, no longer taught in university, not commonly known, and so on.
Arguably, two items which didn't help APL's acceptance were the usage of strange and Greek symbols (of which there were five?) and an order of execution which contravened that which was learned in third grade. This is not to say that they were worse, just not accepted. Nor is it to say that J, K, and Q's notation is better or worse - that is largely a matter of personal taste and maybe technical upbringing. Maybe a thoughtfully ASCII-transliterated APL where the scheme did not play second fiddle to the "genuine" APL characters (APLUM and STSC APL Plus PC come to mind) would have boosted the acceptance level to the point where APL would still be growing. A large user community vs. a better notation? What's worse?
Back to GNU APL, I'm very pleased to see that this finally happened, and really do hope that this is a start of a great comeback.
PS: I am happy that GNU APL is not written in Java.
By Lobachevsky 12 years ago
Thanks for this excellent comment. I hope you stick around; we need more contributions from experience around here.
Since you worked with APL so intensively for so long, would you care to describe what you think is good about it? And how it differs from more familiar approaches? (Apart, of course, from charset and order of operations.)
By gruseom 12 years ago
I started learning APL (it was a cut down APL\360 with 32K workspaces) in the mid 1970s. My first language was Fortran. When I started with APL shortly afterwards, at first I thought it was a sort of continuation of array studies.
What's good about it?
- APL lends itself well to a kind of incremental learning. You don't need to know that much to get started solving problems. Learn as you go, the learning curve is as steep as you want it to be. No hurdles, just a consistent slope.
- APL abstracts away a lot of the mindless tedium of conventional programming. Having said that, there are rewards (like execution speed) for programming in something like C. Speed is sometimes less important these days than it was in the mainframe days
- APL is an excellent prototyping environment. You can concentrate on getting the right answer and understanding what you are doing, then later, moving the solution to the standard, approved language of your choice.
- APL lends itself to the construction of simple DSLs (Domain-Specific Languages). What is lost in flexibility is made up in ease.
- APL itself is an excellent learning tool for quickly learning the domain area you are working in. As it encourages interactive, exploratory programming (as does J, K, Q, R, S, Matlab, and so on) learning the domain area (i.e. Physics, Finance, linear algebra, writing a parser, etc.) can be much easier and fun.
I had a passion for APL which continues even today - I could not muster any such passion for say Java.
By Lobachevsky 12 years ago
While J is mostly a transliteration of APL (with improvements like trains and forks, and other stuff)
K is a different language. Arthur carefully picked the most useful 20 monadic (unary) and 20 most useful dyadic (binary) function and put them on symbols that make sense and are easy to remember:
a+b is addition
+m is transpose (think of mathematical notation for transpose)
a*b is multiplication
*v is "first", like in C
a|b is max / or
|v is reverse (closet graphic to APL)
etc.
Also, K does away completely with matrices and uses nested vectors exclusively.
By beagle3 12 years ago
I used APL many years before I even knew about K but I like them both (I don't have much experience with J). K is a simpler language than APL and it would be not fair to call it just a "transliteration into randomly chosen ASCII characters". IMHO its notation is well chosen. To me it is the Scheme of array programming languages. I looked at the kparc.com site "beagle3" referenced and it seems Arthur Whitney is continuing to distill the language.
Regardless, it is a joy to use either language. Especially after having to look at baroque C++ code all day long.
By bakul 12 years ago
I'm open to the possibility that this is true, but experience with regular expressions seems to indicate that terse and complex DSLs are resented for their lack of maintainability. The analogy to music notation is good, but how much editing is done on music in musical notation? The top priority is conveying music to the performer.
I'm glad to see an open source APL implementation that isn't a derivative like J, because it's good that these things should have reasonably canonical implementations out there for people to use. I don't think J's popularity is much higher for relying on ASCII, but I also don't think it suffers much because its syntax isn't APL's. Realistically, these options are not presented or noticed by the vast majority.
By fusiongyro 12 years ago
> experience with regular expressions seems to indicate that terse and complex DSLs are resented for their lack of maintainability
The problem with regular expressions is the "regular expressions gone wild" effect. Also, the lack of a mechanism for documenting intent is a serious hindrance. One such example are the various forms of email validity regex strings floating around out there.
I'll also say that there's somewhat of a lack of "topology" with regex expressions. What I mean is probably best explained with an analog. If you look at a page full of cleanly written mathematical notation you will quickly identify what I am calling a "topology" of sorts. You'll see the equal sign creating a demarcation between sides. You might see integral signs providing further grouping. The same is true of division lines, parenthesis, exponents and radicals.
Now, a page full of equations can be insanely opaque. Alone they mean very little to most people. However, properly inserted comments and guidance can take something that was impenetrable and turn it into a more approachable problem. Of course, all of it assumes that you know both the notation and the mathematics behind it. Hard to understand differential equations if you never studied them.
A language like APL can be very similar to this. I can write an ugly impenetrable hunk of code in one line and good luck figuring out what it does. On that point you are absolutely correct.
If one starts to work with APL on a daily basis one invariably develops "idioms" --short chunks of reusable code-- that are applied with some regularity. Perhaps the most famous library of APL idioms is the Finn APL Idiom Library [0].
Here you have a set of expressions that do very useful stuff that can be plugged into any program. Generally speaking, a good programmer would include a comment identifying the idiom any time it is used. These little chunks of code, again, if APL is your daily 8 to 12 hour focus, become like words that you use in your code. You learn to recognize them very quickly.
Unlike regex, the symbols in APL, similarly to the mathematical example I gave above, create a topology of sorts that helps you read and understand the code. The programmer has to be sensitive to the fact that, very much like regex, APL can easily become impenetrable, particularly to the casual observer. It is important to recognize this and both format and comment code appropriately.
My general rule for programming, regardless of the language I use, is that I need to leave myself enough information, breadcrumbs and documentation to be able to understand what I was doing after five years of not having looked at the code or used the language it was written with. This approach has saved my butt multiple times to the point that I can say, at least to my satisfaction, that it is the only way to create code --regardless of language-- that can survive the test of time and is easy to maintain.
The short answer to your observation, then, is that a good programmer should easily eliminate the impenetrability issues the language might have.
Certainly more than two, with R being probably the most popular due to a familiar syntax.
By mbq 12 years ago
What is the relationship between APL and R?
By jdale27 12 years ago
A mixture of array and functional paradigms; writing efficient code in R requires basically the same type of thinking like in APL or J/Q/K and friends. Historically, R is a sort of a Scheme-based implementation of S, an earlier language which was basically a mixture of APL and Fortran that a statistician would use (i.e. not get discouraged by a bizarre syntax or for-pyramids). Syntax is probably an effect of the fact that both C and S were co-evolving in the same institution.
By mbq 12 years ago
Both APL and R promote interactive exploratory programming. Both are strong in computational programming and intended primarily for domain experts, though over the years APL has drifted more into a domain for developers.
In my opinion, APL's array capabilities are far stronger and notation less noisy, i.e. less syntax and punctuation. R seems to have been developed with tools like Lex and Yacc and the language has a certain look and feel.
By Lobachevsky 12 years ago
Your comparisons to other languages are pretty misguided. In particular, virtually everyone who prefers haskell over ocaml also prefers C over ada or pascal, making it contradictory. Ocaml isn't more pragmatic than haskell.
By asdasf 12 years ago
It's an "or", not "and necessarily". People I know that prefer J (or APL) to K, tend to prefer Haskell to OCaml, _and_ / _or_ Ada to C _and_ / _or_ VHDL to Verilog. YMMV.
Ocaml is more pragmatic than Haskell, in my opinion: Eagerness is more practical than laziness (if less elegant and less theoretically beautiful), refs more practical than e.g. state monads. I'm not fluent in either, so correct me if I'm wrong, but my impression is that OCaml is in most senses an impure superset of Haskell (there is always a relatively simple, though rarely trivial, translation from Haskell to OCaml, but the other way around does not exist if you use any state). http://jxyzabc.blogspot.com/2009/03/haskell-vs-ocaml-or-ravi... echoes my impression.
The discussion is, of course subjective - given a way to do IO and turing completeness, all languages are in many senses equally practical.
By beagle3 12 years ago
>It's an "or", not "and necessarily".
Yeah, but what I am saying is that you put the same people on both sides. Virtually everyone in haskell land is a C fan, it was a recent topic of discussion actually.
>Ocaml is more pragmatic than Haskell, in my opinion
There's a reason the haskell community is far larger than the ocaml community, and that the tools and libraries for haskell are way ahead of those for ocaml. From a purely pragmatic perspective, haskell is a far more useful language than ocaml. I say this as someone who switched from ocaml to haskell for entirely practical reasons.
>Eagerness is more practical than laziness
No it isn't. In 95% of cases it isn't relevant. In the other 5%, you want to use the right one. For practical purposes, it does not matter if a language is lazy by default or strict by default, as long as it is easy to do the other one. Ocaml makes it easy to do lazy, haskell makes it easy to do strict.
>refs more practical than e.g. state monads
Refs are not comparable to state monads. They are comparable to IORefs, or MVars, or TVars. Which are more useful than ocamls refs. A state monad is an extra thing ocaml simply lacks altogether.
>so correct me if I'm wrong, but my impression is that OCaml is in most senses an impure superset of Haskell
Not at all. Ocaml and haskell share a similar subset, but both have large area the other doesn't. There is very rarely a simple translation from haskell to ocaml, as ocaml is missing so many things that are commonly used in haskell code. There is more often a simple translation from ocaml to haskell, as idiomatic ocaml rarely uses objects. First class modules is generally the issue with translating in that direction.
Yes, and it repeats the same weird memes about haskell that don't actually make any sense to someone who has used haskell for a non-trivial project. Like "needing monads for state".
By asdasf 12 years ago
Ok then, I stand corrected. What would you recommend as a good Haskell text for someone who's gone through learn you a Haskell (and countless other tutorials, which all seem to be fixated on Monads and do a bad job at it)?
And, which non trivial but not too big project would you recommend I study to get an idea of good pragmatic Haskell practices?
By beagle3 12 years ago
I probably can't help you much there, I think LYAH is pretty good. Are you trying to avoid learning monads, or you want a different approach to learning them? I think this is the best explanation of monads: http://blog.sigfpe.com/2006/08/you-could-have-invented-monad...
GHC itself is a good example project to look at, the base libraries tend to all be pretty idiomatic. Xmonad is a good option too.
By asdasf 12 years ago
>GNU APL is made up of about 50,000 lines of C++ code
A GNU project in C++, isn't this unusual?
EDIT: Today the GNU Coding standards says [1]:
"When you want to use a language that gets compiled and runs at high speed, the best language to use is C. C++ is ok too, but please don’t make heavy use of templates. So is Java, if you compile it."
Using the WayBack Machine to 2004 [2]:
"When you want to use a language that gets compiled and runs at high speed, the best language to use is C. Using another language is like using a non-standard feature: it will cause trouble for users. Even if GCC supports the other language, users may find it inconvenient to have to install the compiler for that other language in order to build your program. For example, if you write your program in C++, people will have to install the GNU C++ compiler in order to compile your program.
C has one other advantage over C++ and other compiled languages: more people know C, so more people will find it easy to read and modify the program if it is written in C.
So in general it is much better to use C, rather than the comparable alternatives."
The GNU coding standards were altered not long ago to say that C++ is ok nowadays.
By jordigh 12 years ago
Well, even GCC uses C++ these days.
By sanxiyn 12 years ago
Back in 2004, trying to compile C++ with g++ was like trying to skin a cat with a toothpick. It just gets really tedious after a while.
By brokenparser 12 years ago
Maybe C++ written against other compilers... I never had any problems working on (large-ish, not huge) C++ code bases written against g++ (and making good use of definitively C++ features like templates).
By dllthomas 12 years ago
This is great! I am a long time apl user and think that the symbols make things much easier to read.
By alexcweiner 12 years ago
life←{ ⍝ John Conway's "Game of Life".
↑1 ⍵∨.^3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵ ⍝ Expression for next generation.
}
my first programming job (as in 12-14 hours/day) was mostly IBM APL2, some C and fortran (we often built parallel models that had to tie out to the penny). That's actually pretty idiomatic (doesn't use any language extensions from STSC, Sharp or IBM) but, um, I can't understand it.
BTW, the last time i checked (the 90s?), the only decent book for learning APL was Polivka/Pakin, but doesn't seem readily available
it's the first one, I think, mine had a red cover.
By gtani 12 years ago
I don't specifically follow the code itself but I watched the youtube video, and my undestanding is that it takes a 2d array of the previous game board as 0's and 1's, duplicates it 8 times (that's this part: ¯1 0 1∘.⊖¯1 0 1∘.⌽), uses the rotation operators to transpose the arrays left, right, up, down, upleft, upright, downleft, downright, sums the result (this part: +/,) , and runs that through a test for whether the sum in each cell is either 3 or 4 (this part: 3 4=) , turns that into a 1, and returns 0 on all the other cells. the result is the next step.
There's little details in there that I don't quite get due to my unfamiliarity with APL
By TheZenPsycho 12 years ago
I used to work with a bunch of old geezers from IP Shsrp. Good times, tho' left my mind spinning!
By gaius 12 years ago
Yeah, those Toronto guys hated IBM APL.
I had a friend whose Dad got him a job in high school working for Ken Iversen at IBM, who taught him APL programming.
By gtani 12 years ago
I would really like to see an APL interpreter on an iPad or tablet device. Running APL on such devices where virtual keyboards can be customized would an interesting possibility for dealing with the APL glyphs. If only I had the time… Also +1 for ngn APL.
By julienchastang 12 years ago
I mean, the J Software app is basically that, although J instead of APL. The terseness makes for a pretty good programming environment despite the slow input speed of the virtual keyboard. You don't get the unicode APL customisation you're talking about, but it's pretty close.
By cabacon 12 years ago
When I first read the title, I thought it was some new license they were announcing. ;-)
By cromwellian 12 years ago
I parsed this as a 1.0 release of the Affero General Public License. The GNU AGPL, rather than GNU APL. Easy mistake to make.
By samatman 12 years ago
I made the same comment! it's how the "acronym brain" works.
| I am happy to announce that, after a few years of development, GNU APL 1.0 has been released.
| APL is an ancient programming language.
| GNU APL has the latest and greatest features (nested arrays, complex numbers, shared variables) and is intended to be a full implementation of the ISO standard 13751 "Programming Language APL, Extended".
By lelf 12 years ago
APL looks like an interesting language. I am not very good at math, but the APL keyboard looks exciting, rather than frightening.
I want to echo the comments of Wiz Zumwalt in The Wizardry Consulted: "Sure, if you've got a computer that can render hieroglyphics, and if you never need to remember what you did."
On the other hand, Wiz later used a line of APL to stump a dragon in the riddle game. So there's that.
(Wiz's coworker Jerry was exploring the use of APL as a language for their magic spell compiler, originally written in a Forth-like language.)
By erbo 12 years ago
APL was one of those languages they shown us in college to be "A terrible thing, so be grateful for new languages like C."
Looking at APL here, it actually looks really interesting.
By Posibyte 12 years ago
> "A terrible thing, so be grateful for new languages like C."
While a common sentiment, it has about as much merit as saying: "look at those japanese characters. You can't read them, therefore japanese is a terrible thing".
By beagle3 12 years ago
I didn't tried too hard, but for 5 minutes I tried to find who is the author and failed. It is not good that GNU does not put some emphasis on people writing the software, I just see "GNU" everywhere and a citation of Stallman in the front page. Credit is due and is an important part of free software.
By antirez 12 years ago
His name is in the man page (in the source, did you look there?).
Also if you read this whole thread before commenting, you would have seen the project's very recent announcement on the GNU mailing list.
No, Stallman isn't trying to steal Juergen Sauermann's work.
By verroq 12 years ago
for anyone interested in "modern APL" check out https://github.com/ngn/apl/ runs in node/browser and has good interop functionality so you can use APL where it makes sense.
By shaunxcode 12 years ago
Or https://github.com/openj/core -- the GPL'd source to J. It's definitely not written in javascript, but you can use ASCII!
By imsofuture 12 years ago
I use APL daily because our production codebase is based on it and we are (thankfully) phasing it out. Imo, it's a giant calculator and has no place in production code
By useful 12 years ago
Initially I thought it was new license! just after looking at the comments I realized it was about the language.
By wslh 12 years ago
Someone needs to start a twitter account that tweets APL one-liners (or tell me about it, if it already exists).
By tokenrove 12 years ago
and a browser extension that executes them in place.
By TheZenPsycho 12 years ago
Is there no public version control (git, bzr, svn, cvs, hg, whatever) for this or am I blind?
By beagle3 12 years ago
By bakul 12 years ago
By beagle3 12 years ago
By gruseom 12 years ago
By doublec 12 years ago
By robomartin 12 years ago
By Lobachevsky 12 years ago
By gruseom 12 years ago
By Lobachevsky 12 years ago
By beagle3 12 years ago
By bakul 12 years ago
By fusiongyro 12 years ago
By robomartin 12 years ago
By mbq 12 years ago
By jdale27 12 years ago
By mbq 12 years ago
By Lobachevsky 12 years ago
By asdasf 12 years ago
By beagle3 12 years ago
By asdasf 12 years ago
By beagle3 12 years ago
By asdasf 12 years ago
By rrreese 12 years ago
By jordigh 12 years ago
By sanxiyn 12 years ago
By brokenparser 12 years ago
By dllthomas 12 years ago
By alexcweiner 12 years ago
By lelf 12 years ago
By gtani 12 years ago
By protomyth 12 years ago
By gtani 12 years ago
By TheZenPsycho 12 years ago
By gaius 12 years ago
By gtani 12 years ago
By julienchastang 12 years ago
By cabacon 12 years ago
By cromwellian 12 years ago
By samatman 12 years ago
By wslh 12 years ago
By lelf 12 years ago
By terminalcommand 12 years ago
By erbo 12 years ago
By Posibyte 12 years ago
By beagle3 12 years ago
By antirez 12 years ago
By verroq 12 years ago
By shaunxcode 12 years ago
By imsofuture 12 years ago
By useful 12 years ago
By wslh 12 years ago
By tokenrove 12 years ago
By TheZenPsycho 12 years ago
By fafner 12 years ago
By tjr 12 years ago
By fafner 12 years ago