5 ms·
This little thing caught my interest: APL takes care of binary-vs-decimal inexactness too, so 3×(1÷3) is really 1: 3×(1÷3) How is this done? How we
by mamcx 5y ago
This little thing caught my interest:
APL takes care of binary-vs-decimal inexactness too, so 3×(1÷3) is really 1:
3×(1÷3)
How is this done? How well it scale? I suppose well, because APL is good for math, rigth? But then I remember that must be slow...?
- gugagore 5y agoTo be honest, I don't know what that claim means, but know that `(1 / 3) * 3` is exactly 1 under plain-old IEEE floats. The "fun" is with, e.g. `0.1 + 0.2`. I just tried on the website 0.1 + 0.2 - 0.3 2.775557562E¯17 which agrees: julia> 0.1 + (0.2 - 0.3) 2.7755575615628914e-17
- deleted 5y ago[deleted]
- mlochbaum 5y agoThat must be a reference to tolerant comparison, but the way it's written is bizarre. Comparisons in APL are (optionally: you can turn it off) subject to tolerance, meaning that numbers with a small enough difference are treated as equal by comparison or search functions. There are probably better resources but I describe it at [0]. However, Dyalog just uses IEEE doubles (with an error in place of infinities or NaNs; also you can configure to use higher-precision decimal floats), no different from JavaScript. The result of, say, 0.1+0.2, is not the same as 0.3, it's just equal under tolerant comparison. [0] https://www.dyalog.com/blog/2018/11/tolerated-comparison-part-1/ https://www.dyalog.com/blog/2018/11/tolerated-comparison-par...
- bostonsre 5y agoIt was used heavily for legacy trading and accounting applications at a fortune 50 company that I worked at early in my career. I don't recall any performance discussions at the time, but we were processing a large chunk of money on a handful of expensive ibm power pcs.
- 7thaccount 5y agoIt's still used at those companies. Arthur Whitney wrote an APL variant called A+ still in-use at Morgan Stanley. He then left and wrote the "k" language, which is just ASCII APL (although definitely some major differences). K is the language of the extremely expensive kdb+ time series database (normally used for stock price data analysis I think). It's all in-memory data on a giant SSD (very fast and elegant design). He since left kx systems (company he made kdb+ with) and has a new startup called Shakti. Finance are generally the only folks that can afford the prices I believe.
- bostonsre 5y agoYea, I have no doubt that there are still a handful of extremely well paid APL devs at the company I worked at then (I wasn't at morgan stanley). I was part of a project that helped put a webservice frontend in front of the app so that non-power users didn't have to use a cli to interact with the application if they didn't want to. I don't think there was any appetite or desire to engage in a re-write due to the risk involved when I was there then and I would guess they have maintained that reasoning. I have a vague recollection of some of the stories from the APL devs, one of them was the first to get APL working on a personal computer way back in the day. He carried the computer into some APL conference and demo'd it and got a massive ovation supposedly.
- 7thaccount 5y agoThat's a great story. I wish I could write modern APL at work. Would be a lot of fun.
- dlevine 5y agoI worked at a company right out of college that used K for some things. They did some consulting work for the financial services industry early on, and I think that's how they started. I ran through some basic tutorials, but never worked on any of the projects that used it, so never became proficient. Only a special subset of blessed people got to use K. The only things I remember are that a symbol could could do 3 things when used with a monad, dyad, or infix, and that it was very hard to read anyone else's code because it was so terse. They also went through a phase of naming their Java classes things like com.a.b after getting used to K's terseness. Fortunately, that didn't last very long.
- anthk 5y agoSo does forth: 3 1 3 */ .s <1> 1 ok
- b2gills 5y agoSo does Raku say 3×(1÷3) # 1 It works because `1÷3` is a rational number. my \rat = 1÷3; say rat.numerator; # 1 say rat.denominator; # 3 If you multiply it by 3, you get another rational number which represents 1. my \result = 3×rat; say result; # 1 say result.numerator; # 1 say result.denominator; # 1 --- Now that this may be slower than using floating point numbers, but it isn't that much slower. You only have two integers that you have to manage. Actually on many older processors there wasn't built in support for floating point numbers, so it might actually have been faster to use rationals like this. (I'm not sure if this is how APL handled it.) --- APL happens to be one of the languages Raku copied ideas from ×/⍳10 Translated to Raku [×] 1..10 That is rather than `×/…` it is written `[×] …`. Partly because `/` is the ASCII version of the division operator. We could go further towards replicating it. { sub prefix:<⍳> (UInt \n){ 1..n } sub infix:</> (&f, +list){ [[&f]] list } constant term:<×> = &infix:<×>; say ×/⍳10; # 3628800 }