14 ms·
Papers from the Lost Culture of Array Languages (2011)
- pjc50 9y agoThis reminds me of "[semantic] compression oriented programming": https://caseymuratori.com/blog_0015 https://caseymuratori.com/blog_0015 The arary languages have always struck me as the extreme end of this. The semantics are very dense: each operator does a lot. Intermediate results aren't granted names. The few people who can follow this find it pleasant as the "extraneous" information is removed. Most people find it hard to adapt to. And it doesn't readily suit a lot of business logic. Possibly the one context where arrays-as-language-primitive has really taken off is the 3D processing world, first with OpenGL's matrix stack computation and later with shader programming. Note that shader programming is the other way round: you don't start with a screen object and apply functions to it mapped across all the pixels (fragments), you write a small program as if for one pixel. Even if the end result is executed in a highly parallel fashion.
- jacquesm 9y ago> Possibly the one context where arrays-as-language-primitive has really taken off is the 3D processing world, first with OpenGL's matrix stack computation and later with shader programming. There are many more applications than 3D, most notably APL and all its descendants applications in analysis work, logistics, stats and so on. Though Python is making inroads here.
- guidoism 9y ago> Intermediate results aren't granted names. I would argue that most programmers are fine with this. Unix pipes are a very similar point-free way to program that we're all comfortable with. If people came to APL thinking of it as something similar to pipes as opposed to something similar to C they might have an easier time with it.
- posterboy 9y agoIt's funny to call this point free when OOP notation like ps().grep(pid).kill(9).or(halt); comes down to the same thing. Just rambling because I'm confused. lol.
- uryga 9y agoYou're right, method (OOP) notation lets you compose/pipeline functions. Pipes enable the same thing. So does F#'s pipeline (|>) operator, Haskell's composition (.) operator, Clojure's threading macro, concatenation in stack-based languages like Forth, etc... It's not a concept unique to OOP, which is why GP referred to 'point-free programming', which describes the general idea.
- carapace 9y agoI don't like that blog post on "semantic compression". He's rediscovered refactoring but doesn't think so: > This is a very bottom-up programming methodology, a pseudo-variant of which has recently gained the monicker “refactoring”, even though that is a ridiculous term for a number of reasons that are not worth belaboring at the moment. I also think that the formal “refactoring” stuff missed the main point, but that’s also not worth belaboring. Point being, they are sort-of related, and hopefully you will understand the similarities and differences more over the course of this article series. Um, what? Refactoring is called refactoring because that's what it is: You're pulling out a "factor" of the program and reifying it into a symbol which then replaces the factored code. "semantic compression" is a great name for it, but it's been the done thing in Forth, for example, for many decades. It's just like factoring polynomials. This is a textbook example of what I call "half-smart": He's smart enough to write this article, but not smart enough not to. (Also that site disables reader mode. Boo! Why would you do that?)
- sharpercoder 9y agoWith many languages adopting LINQ object querying, I find it more and more suitable to start using math's set operators for them. Many languages have almost identical behavioral sequence operators (.find in js, .Where in C#, etc) but math sort-of standardizes them all with a sound theoretical background. I'm not entirely sure if they all map 1-to-1, but at least most will. const items = ∅; // empty set if (myItem ∈ items) { ... } // is element of const union = items ∪ otherSet; assert items ≌ ∅; // items are all equal
- tomsmeding 9y agoWhat exactly do you mean by "items ≌ ∅"? The only thing I read in that is "is isomorphic to the empty set", which with all reasonable definitions of isomorphic is the same as that 'items' is empty, which isn't the same as "items are all equal".
- sharpercoder 9y agoAll items are equal to the second sequence. Which means, no items in "items". I could have picked a better example :P
- garmaine 9y agoYou should read Date and Darwin’s The Third Manifesto.
- pvg 9y agoThis a great example of how 'naming things' is by far and away the hardest problem in computer science. If you're going to call something 'normal form' or 'manifesto' it's best if there's exactly one of them. By the third one, others start wondering how normal the first form could have been and whether it might not have been more prudent to try a communique or memorandum before going full manifesto.
- garmaine 9y agoWhile I understand your point, it is my understanding that the first two "manifestos" weren't by Date and Darwin. I think Cobb's original article introducing the very idea of the relational model is one of them, and I forget the other. They are rather making an egotistical (but IMHO deserved) point that their work is the 3rd revolutionary call to action in the history of relational database systems.
- poster123 9y agoI have used Fortran 90+, Python with Numpy, R, and (rarely) Matlab/Octave, all of which allow operations on whole arrays and array sections. Would they be considered array languages? What is qualitatively different about APL, J, and K?
- jacquesm 9y agoR is definitely an array programming language, but with the accent on statistics (historically, though you can do a lot more with it than that). Fortran and Python are much more general purpose languages that also happen to have array operations to speed things up. Matlab/Octave are more math oriented than any of the above and are far more than just programming languages, they are more like interactive notebooks, the IDE for Matlab (and for Octave too now, though I haven't worked much with it) is so closely coupled with the language that the language has no stand-alone right to existence. APL, J and K are all more closely related to each other than to any of the others, the closest of the others would be R.
- jgtrosh 9y agoMinor aside: when I worked at Scilab I couldn't bear having to interact with a GUI so I got used to working either in complete CLI mode or sometimes in the partial CLI mode if I wanted to use a specific GUI feature. I only needed it for interactive plots or interfaces (iirc), however if I had been using xcos I would have needed it. So I don't know about Matlab / octave but I don't think they're fundamentally linked to their GUI; at least not in the sense of the programming language.
- opencl 9y agoOctave only got a GUI 3 years ago, and spent 27 years not having one.
- stepvhen 9y agoJ (i and i assume APL/K to an extent) is called an arry language because arrays are, essentially, a primitive data type. There is no special syntax for arrays, either for creation or handling. The verbs in J just work with arrays, and in most cases, work better with arrays than if you were to manually break it down.
- sumanthvepa 9y agoI had the good? fortune of programming in A+ (a derivative of APL) at Morgan Stanley in the mid 90s. Not sure if it is used there anymore. For someone coming from a background in object-oriented languages like C++ and Java (only just introduced in 1995,) A+ was utterly alien and incredibly powerful. A single line could accomplish stuff that would take 50-100 lines of C++. But that single line looked like Egyptian hieroglyphics! To even read or write code in A+ required a special font addition to XEmacs to work as the glyphs would not render in any other font. I never fully understood the art of programming in A+ in the year or so I had to work on the product that was written it it, but I was amazed at the things the experts in my team could achieve with it.
- FractalLP 9y agoThe glyphs are unicode now and I bet A+ is just legacy and new things are kdb+ which is the successor to A+. Can anyone confirm?
- tluyben2 9y agoIt is still there and open source [0] and I guess you can say k (not kdb or q!) are it's successors in some ways. Definitely in the way they are all very much APLs, with or without the glyphs. If you read the APL book by Iverson and then go to implementations of APL, A+, J, K, you'll notice differences, but there are all identical enough to pick them up fast once you are proficient at one of them. kdb+/q are different beasts and that is were the issues start (and the big bucks are to be found); debugging (performance) issues related to critical software written on top of k. [0] http://www.aplusdev.org/index.html http://www.aplusdev.org/index.html
- ca01an 9y agoDo you have any experience with kdb+/q? I was considering taking a job offer where I'd have the opportunity to learn kdb+/q but I don't have any experience with it and I can't find a huge amount of information about it online.
- geophile 9y agoAPL, (which is the array language I had some exposure to), had three interesting characteristics: 1. It implements an algebra: Operators take arrays as input and yield arrays as output. 2. The special characters bound to those array operators. 3. It is functional. #2 definitely gave APL programs a distinct and elegant personality, but probably didn't help with widespread adoption. But #1 and #3 are powerful ideas, and have showed up in other forms. SETL was a set-oriented language from the late 70s/early 80s. I took compiler courses from the guy behind it, R. B. K. Dewar (of Spitbol fame). Fantastic teacher. SETL programs were concise and powerful like APL programs, exactly because of #1 and #3. Later in my grad school career, I got into relational algebra, which also has these characteristics. My advisor was T. H. Merrett who engaged on a many-years, quixotic quest to explore relational algebra as the basis of a general-purpose programming language. I didn't buy into all of that, but as a database guy, I find relational algebra to be powerful and useful on a day-to-day basis. Finally, I really like functional stream approaches as a great way to bridge set-at-a-time programming (for lack of a better term) with ordinary, low-level programming. Java 8 streams and lambdas is a great (if flawed) example of this approach. Even Map/Reduce is, under the vast amounts of complexity. I like this approach so much that I built a command-line tool, osh (http://github.com/geophile/osh http://github.com/geophile/osh) based on it. The idea there is the Unix idea of composing simple commands using pipes, except in osh, the pipes carry streams of Python objects. And the commands that operate on the objects in these streams are Python. E.g., to print the pids and commands of processes whose commandline contains "emacs": $ osh ps ^ select 'p: "emacs" in p.commandline' ^ f 'p: (p.pid, p.commandline)' $ (37268, '/usr/bin/emacs24 ') (42107, 'emacs ') (63758, '/usr/bin/python /usr/bin/osh ps ^ select p: "emacs" in p.commandline ^ f p: (p.pid, p.commandline) $ ') (113605, '/usr/bin/emacs24 ')
- iheartmemcache 9y agoI read your post, thought 'hmm sort of powershelly with a bit of awk', clicked on your Github project page and saw Powershell was listed as the first 'Software with Similar Goals to Osh'. I've been searching for the 'panacea' of shells (and/or auxilary shell tools/hacks that dup() fd's 0,1,2 to enhance existing shells) that hits that same 'sweet spot' you describe. As such, over the last ~15 years I've been through a litany of setups, ranging from: - the standard "bash/zsh/fish" approach (where you extend the shell) to - the "scsh/ipython/eshell" approach (where you bring an inferior shell's functionality into a language) to, - the screen/tmux approach (where you take a shell and then layer functionality over it). I.e., for directory navigation, I'd written my own f-recency+bookmark system that would hook 'cd <tab>' and generate a pane sort of like Midnight Commander to nav around I'm not sure where I'm going with this other than, I feel your pain and I'd imagine tons of other people do/did as well. Powershell is painfully slow and RAM heavy but the ability to add custom properties(!), providers, access the registry, and manipulate all of these objects as you'd like. Your project definitely looks like an interesting take on things as well. At least we're making some progress, I suppose ;) === (!) This is incredibly powerful since you can take a path, like C:\users\foo\downloads\video\, take file item, and then have Powershell invoke an executable to extend functionality out. If Windows doesn't have "Length" or "Encoder" as a property on the file out-of-the-box, you can just use an auxilary tool (say, ffprobe), "mapcar" the exec to the list-of-files, grep out the Length: field, and bam, that file now has Length. ``ls|where Length -gt 15'' ends up being pretty magical.
- deleted 9y ago[deleted]
- pklausler 9y agoArrays in array languages are functions of their indices, and many array operations can be viewed as compositions of functions on those indices.
- pacaro 9y ago:lightbulb: thank you
- bitminer 9y agoI remember APL as part of learning how to program at my high school in the early 1970s. I could touch type APL on the IBM 2741 text terminals (basically Selectric typewriters with serial interface.). And could compose simpler APL codes at that speed. The principal weakness was APLs narrow view of data type. Text was a 3rd class citizen. There was no substring searching in the early IBM implementation. As a result one had to: Form a cross product of text with the substring, testing for equality of each character Rotate each row of the cross product by n steps where n is the row number (This aligns the tests along columns) Perform AND reduction along the columns to find the full matches. None of this was intuitive and no I didn't invent that method.
- alejohausner 9y agoWhen I was in high school in the 70s I got to attend a week of programming classes at U Waterloo. I had never programmed before. My first programming language was APL. We sat for hours in front of IBM typewriters with strange symbols, trying to write simple programs. The noise from a roomfull of typewriters still rang in my ears at night. I didn't learn much, sadly, but it sure piqued my interest in programming. APL is a great language, but it shouldn't be the first one you meet.
- geocar 9y ago> None of this was intuitive It's extremely intuitive! ⌊/(⍳≢b)⊖a∘.=b Let me illustrate why with q: q)a:"this is some cake i like" q)b:"cake" Form a cross product of text with the substring, testing for equality of each character q)a=/:b 000000000000010000000000b 000000000000001000000000b 000000000000000100000010b 000000000001000010000001b Rotate each row of the cross product by n steps where n is the row number q)(til n:count b) rotate' a=/:b 000000000000010000000000b 000000000000010000000000b 000000000000010000001000b 000000001000010000001000b Perform AND reduction along the columns to find the full matches. q)(&/) (til n:count b) rotate' a=/:b 000000000000010000000000b And there we have it. A naive string search in an array language. Now some interesting advantages fall out of rediscovering this: - It's obviously parallelisable: The "obvious" (iterative) solution in other languages isn't, and without some difficulty it isn't clear where the work can be split up. - It uses "outer product" with compare = instead of multiplication × -- an experienced programmer might forget how deeply satisfying it is when first learning how to compose operators - With some thought it gives a programmer ideas on how they can do string search even faster. Fast string search in an iterative language doesn't look anything like the naive solution. b⍷a (b find-in a) is useful enough that an experienced programmer should expect a "modern" language to implement it (in q it's called "ss", other languages of course call it different things) but it is far from necessary, and we might cheat ourselves of something. After all, when we are experienced enough to see these things as obvious, other things become obvious as well.
- protomyth 9y agoF-Script was an interesting array language object combo that was originally written on OPENSTEP. It fit great with Cocoa later and was quite nice to program in. https://en.wikipedia.org/wiki/F-Script_(programming_language) https://en.wikipedia.org/wiki/F-Script_(programming_language...
- chc 9y agoF-Script was really interesting. It was basically array programming welded onto Smalltalk welded onto Cocoa. It had a whole Smalltalky object browser, and the array programming features felt surprisingly natural.
- ljw1001 9y agoThanks for posting this. Very interesting. Smalltalk actually had some array-language like elements (Alan Kay knew a good idea when he saw one), but this takes it another level.
- segmondy 9y agoThe key thing is "Notation as a tool of thought" What would mathematics or music be without notation? It might be hard to believe but there was once a time mathematics didn't have notation for "+, - * /" or even the decimal point "." Mathematics was solved by writing words, it was slow, it was painful and it didn't progress as fast. Likewise with music, sure we can write music by writing do re mi fa so la ti, but really? Yet, this is how we program today with words, writing english words that don't mean what they claim to be. SomethingManager, SomethingDelegator, etc. Bah! The very ideal behind APL is to notations, to represent code with symbols which are non ambiguous and always mean the same thing. There's a lot that we have lost. It's still worth taking a look at. For those interested, J (www.jsoftware.com) is a free version with lots of great learning resources.
- pasabagi 9y agoAs somebody who started programming long after I learned to touchtype, I feel like programming uses a lot more typographical fauna than normal language - granted, not as much as maths - but I'm pretty sure half of the maths notation is as it is because it looks cool. Further, when you have a SomethingManager, is it really representable by a general symbol? What symbol would that be?
- tabtab 9y agoThey kind of got replaced by "table oriented" query languages, like SQL. Arrays can get very unruly to coordinate, manage, and/or comprehend. Tables tend to ensure a bit more structure and can "do" most of the same things as arrays if you normalize properly. SQL is probably not the ideal "table processing" language, but it's good enough and a strong enough standard such that competitors have yet to unseat it (although I'd like to see more competition, such as Tutorial-D/Rel, SMEQL, etc. fight it out in the market-place.)