K: We need to talk about group(gist.github.com) |
K: We need to talk about group(gist.github.com) |
{d:~1=':s:^x / s‿e←1⊸»⊸(>⋈<)' '=𝕩
c:^"aeiou"?_x@&d&~s / c←¬(s/𝕩)∊"aeiou"
x,:,/$`pig`dog c / ins←⥊c⊏["pig","dog"]
x@<(+\d),{3}#c+2*!#c} / ((+`s+e)∾3/c+2×↕≠c) ⍋⊸⊏ 𝕩∾ins
This program implements a Pigdog Latin translator, bien sûr.And with regards to hotkeys, let's say you do Ctrl+alt+shift+esc+e to insert a unicode symbol, is that really better than just having a programming language where the common hotkeys are spelled out with a few ASCII characters?
- k has much fewer primitives. it's easier to remember a smaller set of operations.
- k is statically parsable. APL is not. we know the program structure simply by reading the code.
this is completely subjective. because you find APL more intuitive doesn't prove anything. to each their own.
Yeah, I’d love to discuss with colleagues how square-c works together with right double crowbar.
No, thanks.
eg, instead of "echo yo >> file" you would "echo yo ≥ file"
In the Raku Programming Language there are several non-ASCII operators, although each of them has a pure ASCII equivalent. Some examples: ≤ vs <=, ≠ vs !=, ∈ vs (elem), etc.
The full list: https://docs.raku.org/language/unicode_ascii.html
Part of those two days of commenting was that since K is interpreted all of the developers would hand-obfuscate all of the code so that the variables were a, b, c, etc. so that they would be slightly faster to parse than a multi-character string. This sort of thing is done all the time now, with JS to make it load faster, but his team at least didn't have any scripts to automatically turn developer-friendly code into interpreter-friendly code, they worked with the interpreter-friendly code version.
mine was matlab. thinking of everything as an array, especially things that aren't arrays, was the first pattern I ever learned. I've never used APL in anger but for the most part it comes very easily to me. Maybe not the code golfing and/or idiomatic APL style that people like to post but, like, using the primitives to create increasingly elaborate arrays before discarding anything I don't want, that part has always felt very straight forward.
"""
[...] As a result, K expressions can be opaque and difficult to parse for humans. For example, in the following contrived expression the exclamation point ! refers to three distinct functions:
2!!7!4
Reading from right to left the first ! is modulo division that is performed on 7 and 4 resulting in 3. The next ! is enumeration and lists the integers less than 3, resulting in the list 0 1 2. The final ! is rotation where the list on the right is rotated two times to the left producing the final result of 2 0 1."""
I think the right intuition for APL-family languages is that they mostly do numpy-like operations except their set of operations tend to compose very nicely. So the idea is that one can quickly and interactively figure out a composition of the operations which will do the calculation you want, but you don’t have a complicated compiler and spend most of your time in the operators rather than the interpreted language, and the operators tend to make the cpu happy – they work on contiguous memory, tend to be vectorized, don’t branch unpredictably, etc – so even if you have to compose many steps, you win on the time to write and the time to execute can be hard to beat because the constant factors of each individual operation are good.
For obvious reasons, things like numpy, pandas, dplyr, etc are more popular as their syntax is a bit more readable and it is easier to get data in/out. I think they do lose a bit by not having lots of the useful compostable APL-style operators because those things don’t have comprehensible names.
I love it... It's the exact opposite of every other language design. Others: lets ship it with every tool a developer might ask for. K9: Occam's razor to everything. Nothing is safe.
It is much easier to become good at k/q if you have experts sitting next to you. Learning this at home (or reading about it on hn) can be very frustrating!
Group tells you the places each element occurs in a list. It generates lists of indices.
https://en.wikipedia.org/wiki/Gather/scatter_(vector_address...
The question is... which array language should I pick? What are the reasons to pick one over the other?
I don't really like J but the only serious APL left is the proprietary (though free, and fun) Dyalog; K, the official product, is also proprietary and because Arthur rewrites it every couple of years all the open source clones are of different versions so there isn't much of an ecosystem.
i would also recommend BQN. it has an active community and it's designer Marshall Lochbaum explicitly tried to address some of the warts in APL and j. he's done a great job.
learning any of the array languages will be a tremendous learning experience if you haven't approached the paradigm before
Not that I have any firsthand experience with the matter, but I think Morgan Stanley has been switching over from K to some Haskell-like dialect as well.
APL programmers want to say their language is mathematical notation, well, make it mathematical notation.
https://ngn.codeberg.page/k/#eJxdjssKwjAQRffzFddVFyLFoiiFQD8...
kona : https://github.com/kevinlawler/kona
alto a javascript implementation even with a graphics library : https://github.com/JohnEarnest/ok
edit : assuming you were talking about k and not freq
My maths notebook from high school looked like that. I'm having flashbacks. (At least in text files you can't cram 4 lines of text into 1.)
I used to think that Lisp was bad, with its "God coded the universe in Lisp", then I read only the first part of your sentence, and was "Woha, so APL predates thought?!"
So maybe simply „a“ was the name.
Of course, supporting Unicode variable names doesn't mean a language supports Unicode anywhere, but it's a starting point for historical research at least.
That seems highly unlikely. Do you have a source, or are you sharing speculation as fact?
It’s more likely that APL symbols were included in Unicode as part of its mission to unify all the world’s scripts into single code set.
Seems https://fluxkeyboard.com/ might be a great fit for programming in APL and similar.
The notation-as-a-tool-of-thought camp prefers short identifiers on the principle that the more concise the expression, the easier it is to comprehend in total. This is not at all dissimilar from the general practices of mathematics.
APL-style operators have been sent to the compost heap of history for a reason.
Scan
Map
Head/tail
Index (with an array)
The integers up to n
Concatenate
Flatten
Most of the operators are already familiar but they tend to work well on multidimensional arrays and with each other due to broadcast semantics (and some axis selection features). In other languages you may see the magic broadcasting for some operations like addition but many of the functions only work on vectors.
x = √y
… would you pronounce it as “x, two parallel horizontal lines, V with a left hook, y”?
The symbols have a meaning that’s unrelated to their appearance. It’s the same in APL. The “square c” is just like “V with a left hook”.
“√” isn’t even a natural character, it’s a graphical delineator between an index and a radicand, similar to ÷ or % forms of division. By “obelus” (sharpened stick) do you mean dot above and below a line, a percent, a dagger or just a line?
Sure there will be enough confusion with ~10-30 extra symbols that aren’t even on a keyboard and may not have a single meaning or a name.
The point is, within the programming language, they do have a single meaning and a a name.
the down side is that subjectively some people (myself included) find J uglier, less effective as a tool of thought and due to some syntactic features (hooks and forks, but no proper lightweight anonymous function syntax)-prone to people posting impenetrably dense code as "examples"
In dyalog you can (as of about v13) do that if you want, or you can just use curly brackets { and inside of them have lexically scoped variables, multiple expressions, recursion and if/then (no loops either though) }
I was surprised by the suggestion that kdb+ was used for this because a matching engine doesn’t really sound like the kind of case that APL-family languages would be well suited to – they tend to work well on large batches of data but for a matching engine, you have messages that come in over time and you want to process each message with reliable low latency (if you have higher latencies you will get wider spreads which is a competitive risk and leads to collecting less in fees), which means not operating on batches.
Do you have a source for the claim that kdb+ is used for the matching engine?
https://blog.bitmex.com/bitmex-technology-scaling-part-1/
https://kx.com/news/kdb-powers-trading-platform-bitmex-high-...
https://www.odbms.org/2017/09/use-case-kdb-integral-to-bitme...
It really works, and also the codebase is quite mindbending. There is a weird elegance to it but also huge lock in.
N.B. a sibling says J has added a direct definition construct while I wasn't watching which renders my comment largely irrelevant although the I feel general point that a lot of J 'example code' tends towards difficult-for-noobs to parse verb trains still holds.
{{(-&2 +&$: -&1) ^: (1&<) M. y}} 155x
It'll run in your browser in 0.003 seconds.
https://jsoftware.github.io/j-playground/bin/html2/#code=%7B...