GNU APL 1.0
gnu.org
gnu.org
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.
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!).
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.
Please tell me this is all open source?
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.
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.
>http://jxyzabc.blogspot.com/2009/03/haskell-vs-ocaml-or-ravi.... echoes my impression.
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".
And, which non trivial but not too big project would you recommend I study to get an idea of good pragmatic Haskell practices?
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.
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.
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.
[0] https://news.ycombinator.com/item?id=6116911
[1] https://news.ycombinator.com/item?id=6117346
[2] https://news.ycombinator.com/item?id=6119314
[3] https://news.ycombinator.com/item?id=6119221
[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.
Regardless, it is a joy to use either language. Especially after having to look at baroque C++ code all day long.
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.
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.
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.
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.
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.)
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.
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."
[1] http://www.gnu.org/prep/standards/standards.html
[2] http://web.archive.org/web/20041010060657/http://www.gnu.org...
No, GNU Octave and gnash are also mostly written in C++:
https://www.ohloh.net/p/gnash/analyses/latest/languages_summ...
https://www.ohloh.net/p/octave/analyses/latest/languages_sum...
The GNU coding standards were altered not long ago to say that C++ is ok nowadays.
life←{ ⍝ John Conway's "Game of Life".
↑1 ⍵∨.^3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵ ⍝ Expression for next generation.
}
http://www.youtube.com/watch?v=a9xAKttWgP4BTW, the last time i checked (the 90s?), the only decent book for learning APL was Polivka/Pakin, but doesn't seem readily available
http://www.amazon.com/s/ref=nb_sb_noss_1?url=search-alias%3D...
I had a friend whose Dad got him a job in high school working for Ken Iversen at IBM, who taught him APL programming.
There's little details in there that I don't quite get due to my unfamiliarity with APL
| Hello,
| 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".
Looking at APL here, it actually looks really interesting.
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".
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.)
Also if you read this whole thread before commenting, you would have seen the project's very recent announcement on the GNU mailing list.
http://lists.gnu.org/archive/html/info-gnu/2013-09/msg00014....
No, Stallman isn't trying to steal Juergen Sauermann's work.