Hacker News

K7 Tutorial(shakti.com)

96 pointschl posted 11 days ago43 Comments
apricot said 11 days ago:

Man, I want to like J and K but the constant vibe of "this language is so dense and complex, only a few genius programmers will ever understand it" is getting old.

tmcb said 11 days ago:

You shouldn't feel intimidated by their density. Both J and K are extremely approachable languages, but you need to try them an open mind and act as if you didn't know a thing about good coding practices. With time you will realize that only a tiny fraction of those apply to the APL language family.

Domenic_S said 11 days ago:

Maybe that's the marketing ploy -- make anyone who learns it feel like a genius for learning it.

rpz said 11 days ago:

Have you had a look through the tutorial? Which parts of the tutorial made you feel as if you needed to be a genius to understand it?

munificent said 11 days ago:

Well, the part where it says:

> Arthur Whitney's k and its derivatives have served a small number of highly skilled programmers

Doesn't exactly start off with an inclusive tone.

rpz said 11 days ago:

As a k programmer myself I'd say to take that statement with a grain of salt and at least give the language a chance if you have some spare time. It's certainly true that the community is small and it's certainly true that there are plenty of really sharp programmers in the community but that doesn't mean that you need to be a genius to write k code.

arrayThrowaway said 10 days ago:

It answers this question: if the language is so great and has been around for so long, why haven't we heard about it?

said 11 days ago:
chrispsn said 11 days ago:

As a companion to this tutorial, the community is building out a clickable version of the k7 reference card. It also covers the current state of Python-k integration:


lolc said 11 days ago:

"Customer shall not, directly or indirectly, and shall not authorize any third party to: (i) decompile, disassemble, reverse engineer, or otherwise attempt to derive the source code of, reconstruct, or discover any hidden or underlying elements of the Software"

Looks like I don't want to spend the effort learning it.

avmich said 11 days ago:

Just in case you want to look at the sources of something similar, here is a good one: https://github.com/JohnEarnest/ok

tluyben2 said 11 days ago:

I like oK because it allows nice toying around with graphics in the browser but while k is incredibly fast, oK is really slow. It is nice to play with and learn from but anything beyond, better check out Kona or another APL like like A+ or J.

4thaccount said 11 days ago:

I'm not aware of too many folks using A+ anymore as it is pretty ancient and hasn't been updated in a very long time.

Array languages I would consider for actual work are mostly:

Dyalog APL, J, and K if I could afford kdb+.

If I wanted to play with implementations I agree that Ok and Klong are pretty cool.

arrayThrowaway said 10 days ago:

Perhaps Nial would be of interest: https://github.com/danlm/QNial7

justinsaccount said 11 days ago:

This a typo?

    x: 3 4 5 6 7 8 9 10
    y: 100 200 300 400

    ?[x;3;y] / replace what's in position 3 by y
  3 4 5 100 200 300 400 6 7 8 9 10
tmcb said 11 days ago:

Looks like the comment is zero-indexed as well. I wouldn't consider that a typo.

justinsaccount said 11 days ago:

Pretty sure the output should be

  3 4 5 100 200 300 400 7 8 9 10
Otherwise that is not replacing, that is inserting.

Weird, I tried it on http://johnearnest.github.io/ok/index.html and that agrees with the doc.. kinda confusing. Seems like it should be

  ?[x;3;y] / insert y at position 3
  ?[x;3 4;y] / replace what's in position 3 by y
tmcb said 11 days ago:

I see. In that case, the output is right and the comment is misleading.

justinsaccount said 11 days ago:

yeah, I updated my comment after finding http://johnearnest.github.io/ok/index.html so I could test this out and came to the same conclusion.

nemo1618 said 11 days ago:

"Shakti k also has primitives for blockchain operations."

That's... Interesting. I couldn't find any further mentions of "blockchain operations" in the reference. What do they mean, exactly? Since k is traditionally concerned with financial markets, I might guess that they're offering deeply-integrated ways to parse transactions, check the number of confirmations, query the current exchange rate, etc.?

tlack said 11 days ago:

It has built in RSA key stuff, common hash algorithms, and the ability to encode/decode Bitcoin addresses. Perhaps other stuff too[1].

[1] https://k7contrib.gitlab.io/docs/#shakti-python

manjana said 11 days ago:

What's the benefit using k vs. c, cpp or java for the same? Does it run or compile faster?

The article says you can do the same with cpp and some extra libraries, but I wouldn't immediately think cpp or java was easily beatable -- manjana wonders --

avhon1 said 11 days ago:

K is interpreted, not compiled. You can run your code the instant it's written.

As other's have said, K (the language and the interpreter) is highly optimized for processing tabular data. I've heard of it outperforming C in processing billions of rows of financial data. (Which, by my understanding, is K's primary market.)

Lastly, K (like APL, J, A+, Klong, Kona, etc.) is very terse. A phrase I've seen online is "one line of K is roughly equivalent to 100 lines of C". K programs, like APL & co., very often fit entirely into a screenful of text, but require close and complete reading to understand. There are lots of videos on youtube of people writing literate sudoku solvers or conway's game of life in a dozen lines or so, and terse solutions in a dozen or so characters.

People who like these programming languages tend to like their terseness -- they can view the entire program all at once (no scrolling or searching), and refactor or rewrite the program in a few seconds of minutes of typing.

arrayThrowaway said 10 days ago:

If you would prefer to use keywords instead of symbols, Nial is a good option: https://github.com/danlm/QNial7

4thaccount said 11 days ago:

If I understand you correctly, why use K over another language like Java? Java is a good enterprise language, but K is a good analysis language. It is very terse and powerful. Look up Kdb+.

ksherlock said 11 days ago:

It depends on what you're doing. If you wanted to analyze some tabular data, k, sql, or even excel are probably more appropriate than c++ or java.

ah- said 11 days ago:

If your problem fits it you can solve it with a fraction of code. It also runs extremely fast and apart from licencing it's trivial to deploy.

jxy said 10 days ago:

Is shakti related to kx? What is going to happen with kdb+?

I also have a practical question. Does `brandelf -t Linux bin/k` violate the License agreement?

arrayThrowaway said 10 days ago:

The founders of Kx (Arthur Whitney and Janet Lustgarten) sold their stakes in the company to First Derivatives plc and have now founded Shakti. Kdb+ is still sold by Kx. Shakti seems to be a successor system to kdb+.

As for you second question, how would brandelf change the binary (disclaimer: not a BSD user)?

max_ said 11 days ago:

Does anyone understand if this is fully compatible with Kdb+? been learning q & it would be nice to add vanilla K7 to the list

yiyus said 11 days ago:

It is not. Every k version is in fact a new language (and rewritten from scratch every time). That said, I guess they may implement some kind of compatibility layer at some point.

SifJar said 11 days ago:
ngcc_hk said 11 days ago:

Whilst One can run j in iOS, j and k are different. May have to try k again.

galaxyLogic said 11 days ago:

I wonder what are its improvements over APL?

4thaccount said 11 days ago:

K uses traditional ASCII characters and is usually bundled with kdb+ for speedy timeseries analysis.

I would use Dyalog APL or J over K in many cases. K is also really expensive (kdb+)...I'm not sure about Shakti (the K inventor formed a new company and left the first one).

dman said 11 days ago:

Can someone compare this to Dyalog APL?

4thaccount said 11 days ago:

Dyalog uses non ASCII symbols which are really cool to me and make the primitives very easy to learn. Check out tryapl.org to get a feel for it. You can also download a trial version and there is a free book. They have decent library support and full .NET support too as well as easy parsing for CSV, JSON, XML...etc. They have Dyalog APL notebooks, database access, multiplatform support, parallel and tacit features...etc. If it wasn't $1k a year for a license (honestly pretty reasonable) I'd use it pretty often. It just feels like they love their product and support it from the annual coding competitions, monthly webinars...etc.

J uses ASCII symbols and has a small community of very intelligent users that are stats smart, software smart, math smart...etc. It has great bindings to Lapack, built in graphs (well Dyalog does too) and tutorials called labs. The community is much smaller though and it doesn't have any parallel primitives. J is free to use, but the Jd columnar database is commercial, but very reasonably priced.

Honestly, both are awesome, fun, powerful, and plain cool.

dman said 10 days ago:

Thanks - my next sabbatical is going to be Rust + APL

4thaccount said 10 days ago:

My usual advice is to also check out Aaron Hsu's talks on YouTube and his posts on HN (user arcfide I think). Really eye opening and alien stuff.

Dyalog also sells a standard keyboard with the APL symbols printed on the keys. You might find that interesting.

avmich said 11 days ago:

Among other things, Dyalog now employs Roger Hui, one of principal creators of J, so Dyalog APL features are using full knowledge of J. Arthur Whitney's, the author of K, wrote the first implementation of J. So it's a small world...

patrickg_zill said 11 days ago:

Alternatively, you can look at the completely free www.Aplusdev.org, "A+" language that was also created by Whitney.

There is also GNU APL which I have been playing with and has some good ideas also, including the ability to create scripts.

tmcb said 11 days ago:

I would like to recommend Kona[1] as well. It is an open-source K implementation, with some small differences.


patrickg_zill said 11 days ago:

Thanks for the reminder. I had seen it before, but I now see that it is active, with the last commit 8 days ago. I compiled it on my Linux box quickly and will be testing it out...