Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
J vs. K by Example (sourceforge.net)
26 points by rscho on Feb 5, 2021 | hide | past | favorite | 13 comments


Do note that this is K2/K3 vs. J

J hasn't changed much, but K has. K9, the most recent incarnation, is much simpler and more generic than the version described here, and also significantly faster.


The latest k is also still under active development by Arthur and colleagues under Shakti. There are frequent releases to play with.


I know a fair bit of J, but never used K. What do you mean by "more generic"? I'm interested.


It has 3 data shapes: atom, list, dict. Lists of elements of the same kind are called a vector, are more efficient, and are like J/APLs one dimensional array - but semantically are the same as any other list.

A matrix is represented by a list of lists. No specialization there. You work on the 2nd dimension with “each”, on the 3rd with “each each”.

Integers are all 64 but, but storage expands and contracts based on actual range.

There is one operator for both “where” and “replicate”, one operator used for both “or” and “max”, similarly “and” and “min”.

K is less pure and prefers to reuse concepts like lists instead of having more complicated (though sometimes helpful) structures like multiple dimensions.

Hope that helps.


K is a successor to J? It came 3 years later?

https://en.wikipedia.org/wiki/K_(programming_language)

And I guess there's also Q.

https://code.kx.com/q/ref/

Which one of these has some industry traction?


kdb+/q has the most traction. However, it could have more traction and first derivatives has done a terrible job at promoting the language.

I love k/q and see a lot of the ideas of array languages perculate into the mainstream thru numpy and Pandas. However, both are really shitty compared to a true array language.

I personally love k/q, J I'm not as keen about.

I've also created my own array language called xs: https://cryptm.org/xs/ I don't really work on it anymore, but it might be interesting to some folks researching/developing new array languages.

I think there's a lot further we can, and k/q definitely has a bunch of warts that hopefully shakti/k9 will solve.

I really want Shakti to have lexical scoping, and I feel like too many compromises are made for performance/simplicity reasons that reduces the ergonomics of current array languages.


I use J quite a lot. I'm interested in why you're not keen about it?

Asking because I'm thinking of adding some form of array language to the statistical/data science Racket framework.


I don't know J as well as k, but it seems to map less to trading/finance, my domain of expertise.

I like that k/q is a more traditional language in a sense, you can write code (if you have to) that looks like regular functional/imperative code. J is more obtuse and takes a more mathematical approach that can be confusing.

I do like forks and the point free style though.


Both APL and K enjoy substantial industry use in financial and heavy industry companies. J much less so, but it is more mathematically inclined (and is open source). APL's and J's cores are very similar apart from their character sets. J has substantially more primitives, especially pertaining to mathematics.

K is architecturally distinct, in that it does not have true multidimensional arrays. It instead uses lists of vectors. This is logical given its main use case: finance, i.e. analysis of rather long series of low-dimensional data. Q is syntactic sugar on top of K.


Q is K3 with some utility functions. It is sold by Kx Systems as part of kdb+, which I have the pleasure of working with on occasion.

The most recent version of K is K9, aka "Shakti"


   ]D=.~. S=.
I thought I was looking at a sendmail config file at first!


I want this to have APL





Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: