6 ms·
Now that I feel the bite from my sedentary lifestyle on my bum, I'm more and more attracted by the idea of a language taking 1/10th the typing compared to what'
by aasasd 8y ago
Now that I feel the bite from my sedentary lifestyle on my bum, I'm more and more attracted by the idea of a language taking 1/10th the typing compared to what's typical today. However, afaict languages following APL's suit specialize in math, so I wonder if the approach could be adapted to more general kind of coding.
Even though the set of short symbols has to be limited, don't we currently have a few dozen often-repeated operations in language keywords and standard libraries? (Especially in the approach of e.g. Clojure, relying heavily on combining standard transformations on strictures.)
- Avshalom 8y agoAPL is actually kind of bad at math, or well the kind of math people tend to think of when they talk about matlab or Fortran being good at math. What APL does well is filter/select/transform more spreadsheet style work than linear algebra stuff. It's a language to describe computation as meant by the sort of computer scientists that were born when computer was a job description.
- avmich 8y agoAPL has map embedded into language. And reduce is an operator in J. APL is conveniently used by those who don't describe themselves as programmers - let alone as computer scientists - but need to get the job done. In this aspect it's similar to Excel, I think. I wonder if APL is that much different from Matlab by the concept.
- 4thaccount 8y agoSyntactically, Matlab is closer to traditional languages. Where it excels at math is that you can do all sorts of things like solving matrices automatically. APL can invert small matrices, but can't automatically find the best way to solve it like Matlab will do. APL has great mathematical notation, but is missing the math libraries you typically need to do real math work (optimization solvers) which Matlab has via toolboxes and Mathematica has builtin.
- vmchale 8y agoFORTRAN is a great language, but it's not really good at math either. It's used with floats, which are a peculiar and volatile beast, though certainly useful. When I think of "good at math" I think of something like Egison.
- 4thaccount 8y agoMost high performance computing was done with Fortran back in the day (and still used today) because working with arrays and matrices is done at a higher level than C/C++ or Assembly, but it is still a fast language and has easy access to BLAS/LAPACK. When I think of scientific computing, I think of Fortran, Matlab, Mathematica, C, C++, Python + Numpy, and recently Julia. APL could've been great here if the vendors had included low level code to do all the numeric work and used APL as the glue language, but it didn't happen that way and became popular in the finance world instead. It's a shame.
- aasasd 8y agoStill, from what I gathered, APL is primarily suited for chewing through a bunch of numbers lumped into arrays, in the manner of shaders or DSP, while I haven't seen examples with traditional control flow (and Perlis notes that loops and branches aren't APL's thing)―though I didn't look for long. Come to think of it, that's similar to what's often done to lists in Lisp, outside of the more traditional control flow of 'business logic.' Precisely the filter-select-transform.
- pmoriarty 8y agoI personally question the utility of such terseness, and much prefer the verbosity of the Lisp family of languages, where cultural norms make for function names like "number-to-string" and "expand-file-name", rather than the norms I've seen in languages like APL, K, J, Q, OCaml, and Haskell, which seem to love more mathematically-inspired single-letter names like "n" or "k", and various operators in a similar vein. The Lisp-like way of programming is more appealing to me because it makes the programs very easy to read. You can mostly get a sense of what they're doing just by reading them like ordinary English. I've found this especially useful when I'm trying to understand code I'm not already familiar with, or when looking at my own code months or years from when I wrote it, and it's especially important these days when polyglot programming is commonplace -- I don't need to remember nearly as much of how to do something in Lisp because it's so easy and straightforward and doesn't have the overhead of remembering a whole bunch of specialized syntax. Contrast this with the terser, more mathematically-inclined languages, where specialized syntax and single-character names are widely used. These tend to be more write-only languages for me, where I have to be constantly steeped in the language in order to make understanding it relatively natural, and if I go away from them for a while, it takes quite a bit of effort to get back in to them enough to make sense of what was written, and reading other people's code is much more of a chore than it is for me in Lisp. In the old days, or perhaps on embedded systems these days, when one had to closely watch the byte count of one's program lest it not fit in to memory, perhaps such terseness was useful. But these days, I'm not yet convinced of its utility outside of a mathematical context, where the mapping of such terse names and operations is more natural. For me clarity trumps terseness.
- rossjudson 8y agoThe notation can yield very dense programs. Significant systems have been written that can be expressed on a screen or two of code (search Arthur Whitney APL for "the legends"). When we learn to read, we learn to "sight read" words. APL/J/K constructs can be "sight read" as well.
- pmoriarty 8y agoSight-reading is a great analogy because as with music, in order to stay fluent and make one's performance (or sight-reading) easy, one has to stay in constant practice. I'd argue that much less of this is required for languages like Lisp, unless, of course, you step away from practicing reading English, in which case maybe the very English-like programs of Lisp will start to seem foreign to you.
- rbanffy 8y agoI hear of APL being used in high-frequency trading and other financial spaces. It's not only because of the language's expressive power, but because the whole runtime fits well within the CPU's instruction cache and, therefore, your program will be ridiculously fast.
- geocar 8y ago> However, afaict languages following APL's suit specialize in math, so I wonder if the approach could be adapted to more general kind of coding. I use k/q regularly, and I'm not using it for "math". The compact notation creates value in helping you make correct programs. See [1] and [2] specifically. [1]: https://news.ycombinator.com/item?id=8476294 https://news.ycombinator.com/item?id=8476294 [2]: https://news.ycombinator.com/item?id=8476702 https://news.ycombinator.com/item?id=8476702 You can write C in a dense style as well. And I do. When I do this, I can see opportunities for reuse that I cannot see if I spread my C program across multiple pages and multiple files. Here is the bulk of my webserver[3] that will beat the pants off of any other webserver -- substantially faster than nodejs or kdb's own webserver[4], and probably nginx or anything else you've got. (PS: If you think you know of a faster one, I'd like to know about it). I am telling you I can only do this because the code is small. [3]: https://github.com/geocar/dash/blob/master/d.c#L63 https://github.com/geocar/dash/blob/master/d.c#L63 [4]: https://github.com/geocar/dash#performance https://github.com/geocar/dash#performance
- aasasd 8y agoNode.js is not the thing to compare C web servers performance to. Like, it's so much not the thing, it goes beyond funny and wraps around to sad. Let me refer you to the TechEmpower framework benchmarks: https://www.techempower.com/benchmarks/#section=data-r17&hw=ph&test=plaintext https://www.techempower.com/benchmarks/#section=data-r17&hw=... Look at the language column there, you'll be surprised.
- geocar 8y agoHere's fasthttp running on my machine (best of three): $ wrk -t2 -c90 -d9s http://localhost:8080/plaintext Running 9s test @ http://localhost:8080/plaintext 2 threads and 90 connections Thread Stats Avg Stdev Max +/- Stdev Latency 831.78us 364.48us 7.56ms 70.19% Req/Sec 40.55k 3.31k 48.04k 74.44% 726417 requests in 9.01s, 87.98MB read Requests/sec: 80603.64 Transfer/sec: 9.76MB which I got by checking out https://github.com/TechEmpower/FrameworkBenchmarks.git https://github.com/TechEmpower/FrameworkBenchmarks.git, disabling the mysql connection, and running frameworks/Go/fasthttp's ./server-mysql (which is what the benchmark script seems to do). I thought this would be easier than getting dash running the TechEmpower results. and here's dash running with the kdb networking disabled (best of three): $ wrk -t2 -c90 -d3s 'http://127.0.0.1:8080/?f=204&k=hi&v=1' Running 3s test @ http://127.0.0.1:8080/?f=204&k=hi&v=1 2 threads and 90 connections Thread Stats Avg Stdev Max +/- Stdev Latency 787.72us 213.62us 3.49ms 71.85% Req/Sec 44.82k 3.04k 60.44k 83.61% 271946 requests in 3.10s, 16.08MB read Requests/sec: 87671.23 Transfer/sec: 5.18MB My laptop isn't a beefy "Dell R440 Xeon Gold + 10 GbE" -- this is just a loopback test, but it's already disinclined me to spend any more time on it; Fasthttp definitely is impressive how close it gets, but dash is still faster. And comparing a 100 line C program to hundreds or thousands of lines of go or C or Java is a bit pointless. If the 100 lines of C doesn't do what you want, I'll throw it away and write a different 100 lines. That's what brief programs get you. NB: I would have tried ulib but it wouldn't even build on my laptop.
- arcfide 8y agoYou may want to check out the Co-dfns compiler, which is proof positive that APL is a terrific language for doing things like tree manipulations, which is the traditional domain of Lisp and functional programming languages like Haskell. https://github.com/Co-dfns/Co-dfns https://github.com/Co-dfns/Co-dfns https://news.ycombinator.com/item?id=13565743 https://news.ycombinator.com/item?id=13565743 https://news.ycombinator.com/item?id=13638086 https://news.ycombinator.com/item?id=13638086 https://news.ycombinator.com/item?id=13797797 https://news.ycombinator.com/item?id=13797797