FYI: This only implements a subset of K (I'd estimate 1/3).<p>Calling it a 'release' is an overstatement. The docs state that it is a work in progress. It's also quite buggy (it's easy to get a segmentation fault). The version I saw in January was about 1/3 the size of this version, and also buggy. I hope that the final version of this code is less buggy and more usable.<p>If you want to learn the K language, don't use this version. Any of the other open source K projects are better than this (more complete, less buggy, better documented). This project is good if you want to learn more about the Arthur Whitney C coding style, because it is so small. Other projects written in this style (some open source K implementations, the J language) are huge by comparison.
Those are some very big claims with respect to performance. Has anyone outside of the author been able to reproduce the claims, considering you need to pay 100k/month just to do it?<p>I also wonder if the commercial version has anti-benchmark clauses like some database vendors. I've always seen claims that K is much faster than anything else out there, but I've never seen an actual independent benchmark with numbers.<p>Edit: according to <a href="https://mlochbaum.github.io/BQN/implementation/kclaims.html" rel="nofollow">https://mlochbaum.github.io/BQN/implementation/kclaims.html</a>, commercial licenses do indeed come with anti-benchmark clauses, which makes it very hard to take the one in this post at face value.
Interesting things in here.<p><pre><code> #define _(e) ({e;})
//!< isolate expression e in its own lexical scope and clamp it with ;
//!< note the outer parens, which is a very powerful c trick: they turn _(e) into a so called
//!< r-value, which basically means we can do x=_(e) for as long as e evaluates to or returns
//!< at least anything at all, i.e. not void. this macro is fundamental to k/simple implementation.
</code></pre>
I didn't know that corner of C. Removing the () from the macro does change what you can pass as e, and assigning the result of a block does work as one would expect.<p>edit:<p>-Wpedantic on gcc will tell me ISO C doesn't like the construct but it still compiles it happily.<p>Clang offers -Wgnu-statement-expression-from-macro-expansion<p>So it looks likely that this is the GNU statement expression extension after all and not a part of C. Shame.
Everyone here charges too little for software.<p><pre><code> the free(MIT license) version is shakti.com/k/k.zip
the supported version(supported and 10 to 100 times faster)
is $100K per month(minimum)
</code></pre>
<a href="https://groups.google.com/g/shaktidb/c/5SPufca3mo4" rel="nofollow">https://groups.google.com/g/shaktidb/c/5SPufca3mo4</a>
For those who haven't heard of or aren't familiar with K, the Wikipedia page[1] has a remarkably helpful brief overview:<p>> <i>K is a proprietary array processing programming language developed by Arthur Whitney and commercialized by Kx Systems. The language serves as the foundation for kdb+, an in-memory, column-based database, and other related financial products. The language, originally developed in 1993, is a variant of APL and contains elements of Scheme. Advocates of the language emphasize its speed, facility in handling arrays, and expressive syntax.</i><p>There was also a great thread on HN about it as well[2].<p>[1] <a href="https://en.wikipedia.org/wiki/K_(programming_language)" rel="nofollow">https://en.wikipedia.org/wiki/K_(programming_language)</a><p>[2] <a href="https://news.ycombinator.com/item?id=28493283">https://news.ycombinator.com/item?id=28493283</a>
For people not accustomed to the style of Whitney, you can read various HN threads from the past to learn more about why he writes programs the way he does.<p>It’s deliberate and powerful.<p>Here is a recent one:
<a href="https://news.ycombinator.com/item?id=39026551">https://news.ycombinator.com/item?id=39026551</a><p>There was an epic post some years ago but couldn’t find it now from my phone.
I'm going to have to take another run at learning this corner of computing soon, but it's a prospect I'm not relishing. Everything about it rubs me up the wrong way.<p>If you'd like an antidote, have a read of Gerald Jay Sussman's books, where you'll see profound concepts from maths and physics captured in succinct and expressive (as opposed to merely terse) code, accompanied by eloquent explanations devoid of boasts or name dropping and provided free of charge online. That will change the way you think about computing too, but it will be a more pleasant experience.
The code looks heavily obfuscated. It's more like "source available" than open source. E.g.<p><pre><code> g(_M,W-=1<<f;xx=M[f];M[f]=x)Ui(M_,Ux=M[i];x?(W+=1<<i,M[i]=xx,x):30>i?_M(i,M_(i+1))+(2*n0<<i):OO())f(_r,pt?x:65535&rx?(--rx,x):e(if(!Tx)n(_r(xU))_M(mx,x-n0);x))f(r_,pt?x:65535&++rx?x:OO())
</code></pre>
Edit: Looking at it a bit more, I can't tell if the code is obfuscated or if the author really wrote it like this...
K by Arthur Whitney: <a href="http://archive.vector.org.uk/art10010830" rel="nofollow">http://archive.vector.org.uk/art10010830</a><p><i>vector</i> the journal of the British APL Association
He showed K @ Royal Society & bunch of apl & aplus guys were there. Someone asked , where are the comments? AW said comments get out of date with all the changes, if you can’t read the code you Shldnt be working on it. We then all looked at each other..
This language is very popular among quant finance people associated with Morgan Stanley. I don’t see the appeal myself. Maybe it helps prevent people stealing the code since it’s so awful looking to work with! At one point I had to learn it and I think I’ve totally forgotten it now— it’s like my brain repressed it. Not my cup of tea, that’s for sure.
Functionality is, at this time, extremely limited (and the first kfun was out in January so I don't think there's really any intention to get this to usability on a short timeframe). No support for paired syntax like parentheses, functions in braces, and square brackets for indexing and function calls. No stranding or tacit functions. I doubt it's Turing complete. Many primitives are unimplemented and others are flaky: for instance calling count (#) on an atom can give an arbitrary number, print garbage, segfault, or allocate memory until it's killed. But it's got vector instruction support.<p>If you're looking for a practical k implementation, I recommend ngn/k, and several other implementations are listed at <a href="https://k.miraheze.org/wiki/Running_K" rel="nofollow">https://k.miraheze.org/wiki/Running_K</a> .
He might be a smart person, with a very high IQ and on a different level than the rest of us, but by writing with this style, with no comments, with no proper capitalization/style and with this attitude, he’s putting me off (IMHO).<p>Oftentimes, the way something is presented and how the language is used, might be as important as the thing itself ;-)
Just packaged it up on my private Guix channel. Here's the package def (along with the one for ngn/k as well) if anyone's interested: <a href="https://gist.github.com/xelxebar/c37ab9285b297fed3e9e0f9ce781db9b" rel="nofollow">https://gist.github.com/xelxebar/c37ab9285b297fed3e9e0f9ce78...</a>
This reads like the incomprehensible ramblings of a mentally ill patient scribbling in the walls. There is zero context, zero explanation. Very vague or incomplete statements scattered all over the place. I don't understand what someone not already familiar with the project is supposed to take away from this.<p>Is the terseness of the site mean to reproduce the terseness of the language? Is that the gimmick?
Is there some application that demonstrates the utility of this language?<p>E.g. it's tempting to dismiss Haskell as something invented by mathematicians more concerned with the elegance of their abstractions than actually getting things done, but Pandoc is so undeniably good and useful that you're forced to admit Haskell can be a good choice. What's the Pandoc of K?
Since this was posted, the source code was changed, and a makefile was added.<p>The new version requires ARM 64 or Intel 64 with AVX2. It requires clang-13 (clang-14 and later won't work). Gcc doesn't work.<p>With clang-14, I got build errors. First error:
./a.h:38:30: error: use of unknown builtin ‘__builtin_ia32_pminub256’ [-Wimplicit-function-declaration]<p>Seems to be related to this LLVM change which removed the above builtin: <a href="https://reviews.llvm.org/D117798" rel="nofollow">https://reviews.llvm.org/D117798</a><p>When I replaced __builtin_ia32_pminub256 with __builtin_elementwise_min and ditto for max, then it compiles and apparently works.
OMG, just yesterday I wrote a comment saying that I regret not learning K (I instead chose J) due to being too hung up on the notion of free software at the time... What a coincidence! Now I have no excuses anymore, time to learn K!
Other than ngn/k ...<p><a href="https://ktye.github.io/kdoc.htm" rel="nofollow">https://ktye.github.io/kdoc.htm</a><p><a href="https://github.com/ktye/i/releases/download/latest/k.c">https://github.com/ktye/i/releases/download/latest/k.c</a><p>IIRC, some old UNIX versions had an APL interpeter in the userland. For me, a k interpreter could be the ultimate UNIX utility. But interoperability with pipes and other UNIX utilities is awkward to say the least, as is having to use other programming languages as duct tape.
The link to the archive ‘k.zip’ has moved to <a href="https://shakti.com/" rel="nofollow">https://shakti.com/</a> with terse documentation in the ‘education’ section.
Some big claims, but I wonder if there are some published repeatable benchmarks<p>Also when someone claims 1000x better Performance I want to know why. For example MySQL or PostgreSQL -> Clickhouse I can clearly attribute to column store, compression, vectorization, parallel execution on multiple CPU cores and machines...
If you ask ChatGPT to reply in the style of Arthur Whitney, you get amazingly concise summaries. Like a language verion of this code. I use that prompt often.
And I though that Skala, FP (monad in X is just a monoid in the category of endofunctors of X) people are pretentious sect, this is so much worse, given their customer base, I immediately presume that this is nothing more than approach to deliberately make things unintelligible for as many people as possible, so that your white collar hedge fund guy would have heart stroke just by glancing at this source code, not even trying to read or understand it, that is one way to treat people and make business, it is despicable. Industry needs to formalise this into well known phenomena much like Security through obscurity [1] so that kind hearted pragmatic people avoid this like a plague.<p>[1] <a href="https://en.wikipedia.org/wiki/Security_through_obscurity" rel="nofollow">https://en.wikipedia.org/wiki/Security_through_obscurity</a>
The website reads like an edgy script-kiddy blog. Is K actually a useful project, or is it just a passion project of someone who happens to be sort of famous?