10 ms·
A History of APL in 50 Functions
- Jtsummers 8y agohttp://www.jsoftware.com/papers/50/ http://www.jsoftware.com/papers/50/ This link gives you the navigation panel on the left. Makes it a bit easier to peruse.
- sctb 8y agoThanks! We've updated the link from http://www.jsoftware.com/papers/50/50_intro.htm http://www.jsoftware.com/papers/50/50_intro.htm.
- kierenj 8y agoTook me about a minute: click ">>" in the top-right of the page. edit: Oh.. reloaded and a side nav appeared. Probably just me then.
- sqlacid 8y agothe joys of frameset
- coldtea 8y agoAs if frameset is generally unreliable?
- hk__2 8y agoFramesets totally break the accessibility of a website. The main website is in one frame, and its navigation in another one. Both frames have different contexts and different URLs.
- coldtea 8y agoThat's only true if screen readers haven't adopted to framesets. With the popularity of the latter for 20+ years of early web, they're totally fine with them (as they are with tables for layout, and many other things people believe "break accessibility).
- wfwefwef32 8y agoI have no idea of what APL is, and the thing doesn't even bother explaining it.
- bebop 8y agohttps://en.wikipedia.org/wiki/APL_(programming_language) https://en.wikipedia.org/wiki/APL_(programming_language)
- rterzi 8y agoAPL has a long an interesting history. It was successfully used for decades in Wall Street firms. It's also worth looking at * The A+ programming language, an APL derivative created at Morgan Stanley by Arthur Whitney. https://en.wikipedia.org/wiki/A%2B_(programming_language) https://en.wikipedia.org/wiki/A%2B_(programming_language). Roger Hui also worked there for a number of year.s * The J language from Roger Hui - https://en.wikipedia.org/wiki/Roger_Hui#J_language https://en.wikipedia.org/wiki/Roger_Hui#J_language * Arthur Whitney and Kx Systems - https://en.wikipedia.org/wiki/Arthur_Whitney_(computer_scientist) https://en.wikipedia.org/wiki/Arthur_Whitney_(computer_scien...
- JulianMorrison 8y agoKona, a K implementation that's open source. https://github.com/kevinlawler/kona https://github.com/kevinlawler/kona Useful for reading K-tradition C programming style, too.
- ColanR 8y agoI've been puzzled about Kona for a while, since I don't really see a purpose for it. K/Q is specifically intended as a very high-efficiency language, and Kona doesn't say anything about benchmarks.
- bakul 8y agoThe original reason may have been that k3 was not open source and the free version was limited. But in general people write these things for all sorts of reasons. Just as there are dozens of Scheme interpreters.
- Avshalom 8y agoWell this is just fucking gorgeous.
- tluyben2 8y agoI was looking for more subtle words, but you are absolutely right. Great work.
- evincarofautumn 8y agoI wonder if array languages will find wider popularity some day with a bit more verbose notation. Take “Array Indexing” (#29): {(,⍺)[(⊂⍴⍺)⊥¨⊃∘.,/⍵]} Or “Inverted Table Index-Of” (#31): (⍉↑x⍳¨x) ⍳ (⍉↑x⍳¨y) These could be written: {(reshape lhs)[(enclose shape lhs) polynomial each disclose outer product reshape reduce rhs]} (transpose take x index each x) index (transpose take x index each y) Same terms, just with searchable words instead of symbols. (Don’t mind the specific words—I’m not much of an APL user!) It definitely sacrifices some important aspects of APL, but in exchange I think it gains something in terms of accessibility by explicitly writing the pronunciations you might have in your head anyway when reading & writing the symbolic notation. It also encourages extracting reusable named definitions instead of repeatedly writing “idioms”.
- beagle3 8y agoThere is some experience with this in the K community, and the answer is "it does not gain accessibility"; and "extracting reusable definitions" goes against the spirit of APL, at least for the simple stuff. Everyone focuses on the syntax because that's the first thing you see, but it's just the tip of the iceberg. The real problem is that you have to think differently, and a weird representation actually HELPS you start thinking differently. My favourite two examples (K syntax - K is of the APL family) are: maximum subarray sum, written in K |/0(0|+)\ and in english "max over 0 (0 max plus) scan"; And flatten, written in K ,// and in english "join over converged". They are both good examples of K's orthogonality (which is shared by APL and J), and of the fact that the english doesn't make them more readable if you don't already have the right mindset. K has a verbose english syntax called Q. People who grok the APL mindset, quickly drop Q for K (which is terser and uses symbols), and people who don't rarely find Q more palatable than K.
- dang 8y agoThe version of this in the Lisp family is the many attempts to replace s-expressions or "drop the parens". The original notation always bounces back unscratched because it's a deep fit for the mindset.
- navium 8y agoThere's not a single code snippet listed on Wikipedia.
- textmode 8y agoAPL was designed to be taught to non-programmers. Indeed it was taught in some high school maths classrooms. I have been reading many books and other historical documents on APL from the 1960s/70s/80s and this one I found to be especially interesting: http://www.softwarepreservation.org/projects/apl/Papers/ElementaryAlgebra http://www.softwarepreservation.org/projects/apl/Papers/Elem... I would like to thank the HN user who has posted this a couple of times. I am grateful for this resource and reading it sooner rather than later. Why I found this particular publication unique amongst all the others I have read: It is many pages before the reader encounters any programming jargon. I believe the use of the term "primitives" may be the first slip. It is possible the reader with absolutely no familiarity with programming would not be alienated by any of the terminology Iverson uses. That is uncommon for an expository text by an author who knows how to program, in my experience as a reader. Perhaps terminology was carefully chosen with a view to avoiding programming jargon and letting the symbols (notation) and example input and output communicate the concepts. Here is another question: Matrix multiplication can play an important role in so-called "AI" or "Machine Learning". For example, Hopfield networks. The extraordinarily popular Python language, specifically the "NumPy" library, is frequently cited on HN. How suitable or unsuitable is APL for matrix multiplication and, by extension, "Machine Learning"? Assuming in each case a programmer competent in her chosen language (i.e. ignoring the competencies of the programmer), which language has faster execution times, Python or APL?
- walshemj 8y agoNumPy is written in C and BLAS in Fortran so for pure technical programming which AI / ML is Fortran Or C is the best choice any interpreted language is going to be at a disadvantage. Arguably all the extra stuff C++ has doesn't really help and Fortan having built-in support for many things the c needs external libs for - Fortran would be the best.
- geocar 8y ago> How suitable or unsuitable is APL for matrix multiplication Matrix-multiply is just plus-dot-times or +.× > which language has faster execution times, Python or APL? This is tricky to answer. For most problems, I'd say APL, but this is isn't quite fair. A competent Python programmer who has made it "as fast as possible" without resorting to extensions will be creamed by a novice APL programmer, so you need to consider third-party modules like NumPy just to compete. Now NumPy is very well-optimised, but you'll really struggle to do well against k/q[1] an APLish that actually focuses on performance, and if you run into a problem where it doesn't, there are extensions you can use to eke out even more performance. At this point, you might try using Tensorflow -- which gives Python a great edge -- but are we really programming Python anymore? kdb+ can use Tensorflow as a library as well... [1]: http://tech.marksblogg.com/billion-nyc-taxi-kdb.html http://tech.marksblogg.com/billion-nyc-taxi-kdb.html fastest non-GPU
- deleted 8y ago[deleted]
- sxp 8y agoWhen reading APL for the first time, how does one determine what the characters mean? E.g, the first example is (+⌿÷≢) x I can look up the '+' '⌿' '÷' characters at https://en.wikipedia.org/wiki/APL_syntax_and_symbols https://en.wikipedia.org/wiki/APL_syntax_and_symbols but I can't find the "≢)" characters which appear to be the '≢ ' and ')' characters when I copy and paste. However, I see it as '≡' '/)' when rendered. Is that broken Unicode rendering of the slash? I'm guessing this function means something like (divide (reduce sum array) (count array)) but I can't search for that triple equal sign on the Wikipedia page.
- agumonkey 8y agoAfter reading a few tiny intros about it, the core of APL is not that hard, that said, it would be hard to suffer dialects and more idiosyncrasies with single symbol heavy languages like that.
- ratboy666 8y agoFrom GNU APL -- )help ≢ monadic function: Z ← ≢ B (Tally) Returns the number of elements in the first dimension of B. dyadic function: Z ← A ≢ B (Not match) Returns 1 if A has not the same shape and ravel as B. But, this is a dyalog expression (which is not an ISO standard APL). Still, the symbol meaning is pretty much the same.
- untangle 8y ago>how does one determine what the characters mean? Download (free) Dyalog APL. Mouse-over any character in the editor and a mini-man page pops up. Or use this cheat sheet: http://docs.dyalog.com/16.0/ReferenceCard.pdf http://docs.dyalog.com/16.0/ReferenceCard.pdf
- neves 8y agoI programmed in APL! When I was doing my masters, I worked with an IBM researcher who had some old code in APL that I had to modify. It is completely crazy. I originally had a special keyboard with all the symbols: http://i.imgur.com/8kOZkEX.jpg http://i.imgur.com/8kOZkEX.jpg I needed to print a keyboard mask to put over the keys to remember where to type. After sometime you get used to it, but it is too much overload in your working memory when you are learning it. The vector operations were really nice and the notation made it succinct, but packages like pandas are far better. It is impressive how usability were not a factor considered when some languages were developed.
- pradn 8y agoPerhaps we should have different keyboards for programming. Traders have Bloomberg terminals. Why shouldn't we have an APL keyboard if we're using that language? If language is a tool of thought, then the input devices reduce time to putting that thought into action.
- mmphosis 8y agohttps://www.dyalog.com/uploads/images/Business/products/uk_rc.jpg https://www.dyalog.com/uploads/images/Business/products/uk_r...
- untangle 8y agoFor those wishing to learn this mysterious language, Dyalog has an excellent online tutorial at: https://tutorial.dyalog.com/ https://tutorial.dyalog.com/ Using this tool, I was "thinking APL" (at a novice level) in a couple of days. Dyalog also has a free-for-personal-use 64-bit version.
- kasbah 8y agoThanks for the link. Do you know if there is something similar for GNU APL? Do you think it will be annoying to switch to GNU APL after going through this? I'd rather not spend time learning a proprietary interpreter if there's a viable free software alternative. EDIT: Have started going through the tutorial using the GNU APL interpreter. I'll see how it goes I guess. 2+5 seems to work the same :) EDIT 2: akt makes it possible to type the symbols without a special keyboard with GNU APL https://github.com/TieDyedDevil/akt https://github.com/TieDyedDevil/akt
- gnulinux 8y agothere is an emacs mode
- kasbah 8y agoAn emacs mode for what? I don't use emacs much but would be up for using it it helps me with something. Fairly happily plodding along with just the GNU APL interpreter and akt though (and akt seems to work with vim through invoking `akt vim`).
- gnulinux 8y agoEmacs mode for APL, it has things such as keyboard support, compilation support, debugging support etc...
- zenhack 8y agoIt has an input method that lets you type the non ASCII characters more easily. The default uses the super key (windows key) like alt uses alt, bit there's also a mode that allows you to prefix things with ., So e.g. to get rho you type .r, and to get an actual . you type .., which I find more ergonomic. And you can launch the repl from inside emacs as well. I'm mostly a vim user myself, and have been using it with spacemacs for a more familiar experience.
- peter303 8y agoMy MIT analog circuits course in 1973 used APL. I dont know what they use now.
- todd8 8y agoI took the same course! I remember that we had been taught to calculate the voltages and currents for all points in an electrical network as vector algebra operations. Then, for one of our assignments we were expected to just learn APL on our own to write a program to do these calculations. As I recall, it wasn't too difficult using APL. I believe that we were given or used some sort of IBM manual to learn APL. I just searched my library and found APL/360 An Interactive Approach by Gilman and Rose, 1970[1]. However, APL was most definitely not the focus of the course so I think this was a book I bought a couple of years later in grad school for myself. We wrote the programs on a fancy version of a teletype machine, made by IBM, called the IBM/360 APL Terminal System. See the photos of the paper based terminal in [2]. [1] http://www.softwarepreservation.org/projects/apl/Books/GillmanAndRose http://www.softwarepreservation.org/projects/apl/Books/Gillm... [2] http://thenostalgicgeek.blogspot.com/2013/09/resurrecting-apl360.html http://thenostalgicgeek.blogspot.com/2013/09/resurrecting-ap...
- gtani 8y agoAPL and C were my first languages, but I can't read most of those, it's been too long. Merrill Lynch's mortgage operation was an IBM APL2 shop with a few dozen programmers, along with people doing non-mortgage stuff. http://www.thocp.net/software/languages/apl.htm http://www.thocp.net/software/languages/apl.htm https://en.wikipedia.org/wiki/APL_(programming_language)#APL2 https://en.wikipedia.org/wiki/APL_(programming_language)#APL... I remember that people who came from the other dialects, Sharp and STSC, had different ways of doing e.g. nested arrays and calling out to the OS which made their code hard to read.
- textmode 8y ago(Novice k user) Exercise: Download to a single html page using k3 and curl cat 1.k c:"curl http://jsoftware.com/papers/50/"; f:("intro";"50_";"chrono";"pers";"fine";"ref";"ack") e:".htm;sleep 3" a:{,/$(c,:[x=0;f[1],f[0];f[1]],:[x>49;f[x-48]],:[x<10;:[x=0;;0,x];:[x>49;;x]],e)}'!55 {`4:a[x]}'!55 k 1 > 1.html firefox file:///1.html
- RodgerTheGreat 8y agoA few simplifications: c:"curl http://jsoftware.com/papers/50/50_" e:".htm;sleep 3" f:{("intro";"chrono";"pers";"fine";"ref";"ack";-2#"0",$x)0 50 51 52 53 54?x} {`4:c,f[x],e}'!55 The pattern of using find and indexing into a table with a default case is a nice way to get rid of lots of twisty conditionals.