10 ms·
APL – A Glimpse of Heaven (2006)
- breenhead 8y agoFor anyone interested in apl, take a look at k which is essentially apl restricted to the ascii character set. There's also q (aka kdb) which adds some additional database-like functionality (among other things) however it's proprietary and "free".
- macintux 8y agoThere’s also J, also created by Kenneth Iverson. http://www.jsoftware.com/ http://www.jsoftware.com/
- dmos62 8y agoQuote about motivations behind J, found in Kenneth E. Iverson's Wikipedia page: """ When I retired from paid employment, I turned my attention back to this matter [the use of APL for teaching] and soon concluded that the essential tool required was a dialect of APL that: • Is available as "shareware", and is inexpensive enough to be acquired by students as well as by schools • Can be printed on standard printers • Runs on a wide variety of computers • Provides the simplicity and the generality of the latest thinking in APL The result has been J, first reported in [the APL 90 Conference Proceedings] """ This is how you'd compute a moving average (taken from its Wikipedia page [0]): avg=: +/ % # avg 1 2 3 4 2.5 v=: ?. 20 $100 NB. a random vector v 46 55 79 52 54 39 60 57 60 94 46 78 13 18 51 92 78 60 90 62 avg v 59.2 4 avg\ v NB. moving average on periods of size 4 58 60 56 51.25 52.5 54 67.75 64.25 69.5 57.75 38.75 40 43.5 59.75 70.25 80 72.5 Pretty cool. [0] https://en.wikipedia.org/wiki/J_(programming_language) https://en.wikipedia.org/wiki/J_(programming_language)
- stevesimmons 8y agoIf you want to try kdb, there is are two free noncommercial versions: - 64 bit/16 core, sends "I'm alive" packets back to Kdb: https://ondemand.kx.com/ https://ondemand.kx.com/ - older 32-bit, standalone, very small executable: https://kx.com/download/ https://kx.com/download/ Wkimpedia page has history and links to various docs: https://en.m.wikipedia.org/wiki/K_(programming_language) https://en.m.wikipedia.org/wiki/K_(programming_language)
- curiousgal 8y agoLast time I searched for Kdb I found that it's highly used in finance, is that still the case?
- stevesimmons 8y agoIt has a niche (time series analysis of equity data) where its performance is valued. Kdb developers are rare and expensive so it gets used for specific tasks rather than as a general purpose db.
- osullivj 8y agoNot just equities but other asset classes too. I've seen it used for persisting Eurex order book state for futures contracts. London contract rates for KDB devs seem to be 1000GBP/day.
- smcl 8y agoIt really depends on what you're emphasizing in the question. Are a sizeable number of Kdb's clients in the finance industry? Yes, it seems they are Is Kdb common or widely used in finance? No
- mruts 8y agoIn my experience it is rarely used on the buyside but often uses on the sell-side: most investment banks have atleast a couple people that are using it.
- dkersten 8y agoBitmex, the cryptocurrency derivatives exchange's trading engine is written in kdb+/q.
- breenhead 8y agoSpeaking as a kdb programmer in finance (although for an unusual use case), most big (and some small) banks have an Enterprise license and have one or more teams that maintain a market data store and/or an order reporting/reconciliation/PNL stack. There are a decent number of hedge funds that use it for more or less the same purpose but work with other data sets in addition to market data For storing and exposing market data, you need very little additional code. Maintenance is a different story.
- willvarfar 8y agoAn anecdote about my first and only brush with an APL programmer: Towards the end of the nineties I was a young computer science student standing on an almost deserted suburban above-ground underground station waiting for the next train into the centre of London. A very old but brisk and snappy gentleman in traditional gentleman's clothes came onto the platform, and for some reason we nodded genially as you do when you pass strangers on country lanes; in London you ignore absolutely everyone, so it was strange we did this. And there we stood, waiting for the train. He offered me a peppermint from a small metal tin. Of course my parents taught me to never take sweets from strangers, so I instinctively declined even though I'd now left home and thought of my self as a grown-up. Anyway, we got talking. At first it was 'what are you studying?' kind of polite interest. He was intrigued that I was a computer science student. I've gotta underline again how unusual this was, for anyone in London to ever talk to another stranger, but this really happened. I don't think I ever acknowledged there was anyone else in London, ever. It wasn't even normal to know the names of your neighbours. And so we sat beside each other on an underground train and he told me about his early years as a programmer. Did I know APL, he asked? I had never heard of it! His veiled references suggested he worked with but not for Cheltenham. And he delighted in telling me programmer war stories from when he did commercial stuff like how a vendor had encrypted their APL programs and he had reverse engineered it and waved the decrypted source-code in front of the firm's rep and complained about shoddy code and bugs! At the time I was tackling Simon Singh's Code Book contest so that kind of story caught my imagination and I begun to wish I'd have that kind of chance in my programming future. Now, in his old age, he went from his home in the north of England down to London once a week for a charity meeting he chaired. That's the kind of thing respectable old gentleman do to give their life meaning, I guess. Anyway, afterwards I searched the web for APL (this was before google) and was, of course, gobsmacked.
- smcl 8y agoFor non-Brits, "Cheltenham" = GCHQ
- nostrademons 8y agoFor non-Brits, GCHQ = the British intelligence service, roughly equivalent to the US NSA. (This non-Brit had to Google.)
- Jtsummers 8y agohttps://www.dyalog.com/uploads/documents/MasteringDyalogAPL.pdf https://www.dyalog.com/uploads/documents/MasteringDyalogAPL.... I knew the text felt familiar, the same author wrote the above linked book. The intro covers the same material. If you're interested in APL (NB: Not a professional, just liked playing with it), that book was really useful to me last year.
- michaelbuckbee 8y agoI'm never quite sure what to make of APL. It feels fantastically advanced for its time. Hardware keyboards? Performance?
- 3chelon 8y agoWhen I was a graduate dev I worked for a company whose primary product was a APL interpreter. So it was an interpreted language, but it may well be possible that it can be compiled or JIT these days. The interpreter was written in 68K assembler and was pretty fast I suppose, but then I'm not aware any benchmarks to compare it with, since APL is not like anything else (except, as someone pointed out, maybe MatLab).
- dang 8y agoFrom 2014: https://news.ycombinator.com/item?id=7813204 https://news.ycombinator.com/item?id=7813204
- paperwork 8y agoThose who have experience with array languages, is it fair to say that something like numpy captures most of the benefits of APL/K? If Python allowed a reduce operator “/“, numpy will be able to get even closer to APL, correct?
- icen 8y agoIn terms of semantics, sure. However a real part of the charm of APL (and J, and K) are in the syntax, and how notating your program causes you to think about it differently. Something like or/and outer product in the game-of-life oneliner is very straightforward APL, but is much clunkier to write in numpy.
- improbable22 8y agoI just found that there's a Julia package for at least some APL syntax, perhaps an easy way to play. [3] is a fork updated for v1.0: [1] https://www.youtube.com/watch?v=XVv1GipR5yU https://www.youtube.com/watch?v=XVv1GipR5yU [2] https://nbviewer.jupyter.org/gist/shashi/9ad9de91d1aa12f006c4 https://nbviewer.jupyter.org/gist/shashi/9ad9de91d1aa12f006c... [3] https://github.com/MasonProtter/APL.jl https://github.com/MasonProtter/APL.jl
- TimTheTinker 8y agoI once got talking with an anesthesiologist who was taking care of a family member. Upon hearing I was a developer, he told me he was an APL programmer who spent most of his computer time developing Bible software. He regaled me with a few APL war stories, about how he could get so much more done with so much less code... I was intrigued, and still am. But one thing I didn't catch -- how do you write all those non-ASCII symbols using a standard OS and text editor? Or does it require special tools?
- patrickg_zill 8y agoYou use a font that has those symbols and then Alt key combinations to make the characters.
- vishnugupta 8y agoHaha this brings back memories. In college days, this was our way to hide files. We'd name the files with these symbols, and so you had to know that key combination to open the files. Note that this was pre internet era and DOS prompt, no windows so you couldn't just click on the file.
- TimTheTinker 8y agoWow... How about on a Mac? Option and Shift-option keystrokes?
- patrickg_zill 8y agoYes. I have the free but non open source APLX running on my iMac and have the image of the keyboard map they supply loaded in Preview. Many of them are mnemonic, such as iota being (key)-I for example.
- 4thaccount 8y agoFree because the APLX vendor eventually decided to focus on their legacy software business and get out of selling an APL interpreter. I think they essentially needed a rewrite or just a lot of work on the product and couldn't justify it. Dyalog agreed to host the old and unsupported APLX interpreter on their site if anyone wants it.
- macleginn 8y ago“This example shows clearly that there are ways of reasoning other than those which have dominated information processing for 40 years but they are, alas, still extremely rare. This difference and originality, introduced by APL, are major features. They typify the open and welcoming intellectual spirit of the people who practise it.” — FWIW, this example (+/ Salaries × Rates[Categories]) can be rewritten nearly word for word in R (Sum(Salaries*Rates[Categories])), so at least some of the ideas still have some currency.
- mruts 8y agoI would say that pandas and R can pretty much express everything that APL/J/Q can. They are a lot slower though (than Q atleast, I haven’t used J or APL)
- macleginn 8y agoTheir another downside, I guess, is that they are wildly inelegant. R is inelegant in its core, despite all the nice functionality, and Pandas, IMO, presents a rather ugly addition to the regular Python syntax despite all its nice functionality. So people still yearn for things pure and beautiful.
- disgruntledphd2 8y agoPandas looks like R from around 2010. Now, granted, I can see how R is perceived as inelegant, but I strongly believe that this is driven by unfamiliarity (for many people).
- 4thaccount 8y agoThis is like saying a Turing complete language can simulate everything another Turing complete language can. A decent sized idiomatic APL program will be very different from the same Python program only using Numpy, even if the outputs are the same.
- mruts 8y ago
- rakoo 8y agoIt seems to me APL and family are mostly useful for numerical work on data that is possibly queried (efficiently at that) from a database. A very naïve way would be to say it's a glorified Excel. Is there something I'm missing ? Are there other domains one could use it for ?
- BoiledCabbage 8y agoThere was an extremely impressive video a year or two back of someone who had built a compiler in APL. While I don't code in it, it changed my view of APL and its power. HN was fairly caught up with it for a month or so, and a flood of APL posts. Someone may have a link to it.
- 4thaccount 8y agoJust look for Aaron Hsu Co-Dfns on GitHub, talks on YouTube, and on HN...I think his username here is arcfide. Look for his submissions. He's probably 100x better at coding than me and never leaves notepad.
- brian_cunnie 8y agoAlthough the "glorified Excel" statement makes me cringe, I would agree that APL's strong point is numerical work on data. I wouldn't use APL to write, for example, an operating system. When Ken Iverson wrote APL in the sixties, numerical work was one of the big uses of computers (after the typical finance applications such as billing, inventory, accounts payable/receivable, general ledger), and APL filled that niche quite well. When I was working at IBM in the nineties investment banks were still using APL for some of their modeling. APL also took a different evolutionary path than many of today's languages, operator precedence for example. APL's rule was simple: evaluate left-to-right. I didn't need to remember that exponentiation has a higher precedence than multiplication which in turn has a higher precedence than addition (those were the easy ones to remember; the hard ones were bit operations, logical operations — some languages had both high-precedence logical operations ("&&" and "||") as well as low-precedence ("and" and "or"), which further muddied the waters). I found Reverse Polish Notation (RPN) the most elegant when determining operator precedence, with APL's a close second. Another difference was the way that the code was maintained. For example, my father, who was also an APL developer, often said, "APL is write-only code". Rarely would one modify someone else's code; instead, you'd re-write the function entirely. Thus the most important aspect of writing APL code was documenting what the function took as input and what it spat out. But I'm glossing over one of the most important aspects of APL: it made you think about the problem space differently: instead of nested for-loops, you'd think of vectors and matrices. The manner in which you thought about the problem was incredibly succinct, similar to APL's vocabulary.
- joelthelion 8y agoIs there a good open-source APL-like language somewhere?
- icen 8y agoGNU APL is a perfectly reasonable APL implementation. There are open source implementations of some K versions - Kona, which is K3, and oK, which is ~K5. J is available under GPL3.
- upofadown 8y agoWhen I was in engineering school an APL programmer friend came over to where I was working and looked at my MATLAB homework. She eventually stated that MATLAB was a very bad APL. She then proceeded to solve my homework in a single line of MATLAB.
- GlenTheMachine 8y agoMATLAB doesn't deserve the moniker of a "bad APL". It's a bad FORTRAN.
- JoeDaDude 8y agoIn old computer magazines from the 80's and before, it was a trope to have an article about some technique or algorithm, and then show it implemented in one line of APL.
- yjftsjthsd-h 8y ago> She then proceeded to solve my homework in a single line of MATLAB To be fair, though, was that single line as long as a normal screen of code? I have not decided whether it's a good thing or bad thing, but apl/j/k programmers have some very interesting ideas about how much is acceptable to put on a single line;)
- Karto 8y agoA few years ago, discovering J and playing a bit with it, I went through phases : "this looks square and clean, a nice exercise in language design" -> "those guys take it way too seriously" -> "people seem to be using it for serious stuff, they are simply insane". Coming back to it every now and then for kicks slowly showed me a few strengths. First, with the short verb names and clear semantics, J is the only thing I've found that brings, for me, the comfort of a specialised handheld calculator to the PC. That realization, very independently from its array capabilities, is what got me really going with it, on a gentle learning curve. And you get it on your smartphone too ; I eventually sold my good old HP48 friend. From there I started using it for small things. When I was building a lift for my brother's Warré beehives, J let me scribble a few beam-resistance equations in it and using its solver and plotter to easily get good results. So I started using it for things that were too big for spreadsheets, but that I was too lazy to deal with in a "proper" language. That needs a change of mind regarding how you write and maintain programs. When I want J to do something in a program, I fiddle with it until I get the "sentence" right, and that's it. That sentence will never be modified again. If I need it to work differenty, I'll rewrite that sentence from scratch. Then find a good name for your sentence so that you can combine it with others, and suddently you discover that you can write J like a nice DSL that can very satisfyingly sound like plain spoken language. I wouldn't stretch it though. I'm not passionate enough about it to invest what's needed for mastery. 80 lines of thin J is my largest. Beyond that, switch to something that helps with maintainability, but beware of the sudden and amazing code-size inflation !
- pmarin 8y ago> When I want J to do something in a program, I fiddle with it until I get the "sentence" right, and that's it. That sentence will never be modified again. If I need it to work differenty, I'll rewrite that sentence from scratch. Then find a good name for your sentence so that you can combine it with others, and suddently you discover that you can write J like a nice DSL that can very satisfyingly sound like plain spoken language. I had exactly the same experience with Forth. It is very cool when you define a word as an almost English sentence and all the data flow effortlessly through the stack but I have to admit it can take a lot of time to get it right. I got to the conclusion that Forth is a contemplative language where you spend a lot more time thinking than typing.
- nabla9 8y agoAPL and Prolog/Datalog are local optimums in programming languages. When you enter their domains, you are limping in every other language. It's almost better not to know about them because you can avoid constant "there is a better way" in the back of your head. I think we should just bite the bullet and make them into standard domain specific languages available in every language and environment.
- jeffreyrogers 8y agoWhat domains are they used in? I've learned a little bit of J but got put off because most people involved with J seem more interested in using J for the sake of using it rather than actually doing anything substantive with it. My impression is that APL is similar (at least currently) but I'd love to be wrong.
- nabla9 8y agoAPL is for numerical programming with vectors, matrices and so on. Prolog or Datalog is best when you deal with logic, complex rules, deduction, configurations, graph manipulation, or search. For example, Microsoft used to have embedded Prolog that chose the right combination of libraries and drivers when you installed their OS.
- deoxxa 8y agoYep, Prolog is pretty great for that kind of thing. I'm working on a project right now where I'm using Prolog (via tau-prolog) in the browser to determine permissible input options based on the user's existing selections. I'm also using it (via https://github.com/mndrix/golog https://github.com/mndrix/golog) to apply those restrictions on the server, and to calculate the pricing for a configuration. In most cases I'm generating Prolog code from a collection of tick boxes, but for complex campaigns I can dig in and write a specific implementation of the required rules. Very flexible.
- Jtsummers 8y agoI got into J in the '00s, it was interesting. The community was making substantive stuff, but they were making it for themselves more than for anyone else. I noticed a lot of teachers in the mailing lists. They were making tools that helped them track grades and attendance. They were generating quizes and worksheets from question banks that they produced over the years. They were creating puzzles for their students. All of this was substantive, but it was focused on their ability. J (and APL) really seemed to be an extension of what computing could've been. As a computer scientist and programmer, any language and OS work for me. I want something, I make it. I can write an app in C or C++ or Java or Lisp or Erlang or... because I have the background for all of that. For most other users, they have to find a program that accomplishes their need, or maybe they do it in Excel or Google Sheets. But in the past we had an idea of interactive languages that were the main interface for the user. The user could then produce the things they needed to meet their needs. They didn't need me, the CS guy, they could produce at least a functional prototype that met the need for the day. Then over the years they'd tweak it, add more, grow it into something comprehensive, or it reached a natural limit (due to complexity or meeting requirements). J and APL are from that branch of computing. We've hidden it in our OSes (to varying degrees), encouraging people to buy programs that accomplish X rather than providing them an environment to produce their own programs to do X. The APL family of languages makes it front-and-center about the user accomplishing their needed computations and activities.
- tempodox 8y agoSo, is there a Machine Learning Docker with APL pre-installed?
- rbanffy 8y agoIn college I learned APL. Most of my colleagues complained that we were learning it instead of something with more practical use or market value. APL taught me it was possible (and remarkably easy) to write "write-only" code and how delicate legibility can be. Most of my APL code had 4 lines of comments for each line of code.
- renox 8y agoWhen I learned APL (which I never used) that when there was a bug, it was faster to rewrite the whole line using a different way than to debug the line. A truly 'write only' language.. It shows in the article: the 'min' operation works both with an array and a scalar. Nice when you mean it, not so nice when you don't.
- ColanR 8y agoI still see two things missing from currently available APL dialects: being able to compile programs, and being able to create a control loop (which is required for continuous access to data input). I wonder how much effort would be required to use, say, GNU APL for compiling the language?
- csomar 8y agoQuoting from the article: >> To get a similar result by means of a traditional computer language requires many instructions, which hides the object of the calculation behind arcane programming. Here, for example, is what one would write in PASCAL It seems that the article emphasises on how APL can get a lot done with little code. I know of a programming language that can help you do that: Rust. Rust has two powerful features: 1- Traits: You basically declare a "struct" type that has your data. Implement the Mul/Add Traits to it; and then "boom" you can multiply these seemingly complicated objects with *. 2- Macros: You can abstract repetitive code with macros. For example your code displays a table on the terminal. You have to do that repetitively. You can either create a function to display your data or have a macro do it.
- benji-york 8y agoEvery time APL comes up, I — as a non-APL programmer — am compelled to post this fun video about implementing Conway's Game of Life in APL: https://www.youtube.com/watch?v=a9xAKttWgP4 https://www.youtube.com/watch?v=a9xAKttWgP4
- robomartin 8y agoAs someone who actually used APL prifessionally for a decade I am always surprised by how often the language surfaces on HN. I used it in a wide range of domains, from business and engineering applications to DNA sequencing. The main comment I want to make is that anything that abandons notation is an abomination. The power of APL comes from the use if notation as a tool for thought and the expression if ideas. Notation is crucially important in this regard. Language transliterations like J were huge mistakes in APL’s historical timeline.