Kay Language

The language K was created by ArthurWhitney, and is distributed by http://kx.com It belongs to both the ArrayOrientedLanguage Class and the Data Base Management Class of languages. It shares some characteristics with APL (AplLanguage) and J (JayLanguage) and its predecessor A+ (AplusLanguage), although its greatest use seems to be in the area of managing huge transaction-oriented data bases. In this class of problem K's performance is often staggering.

These links are good as of Jan. 2014.

K is quite daunting at first glance. It is surely a good candidate for the MostExoticRealProgrammingLanguage list. There is not only the K language itself, there is KDB, an SQL-like data base management language that is used for managing huge scale data bases. KDB builds on K to implement two other languages: SQL 92 and KSQL. KSQL being similar in character to SQL, but is considerably more compact (though not as compact as K).

Although K is a very expensive product, its productivity in operational-scale systems is sufficient to make it quite capable of being sold. Under normal circumstances this would mean that only a few of us would ever get program in it, but Whitney decided, some while back, to release a version for development that was free. Of course it is restricted in some ways, but so far not in any way that has hindered learning and experiencing the language. -- DavidNess

There are many remarkable things about K. To those of us who have become inured to `program bloat', it is absolutely astonishing how much can be done in the 128k download that installs the language, and in the 192K download that installs KDB. And we can hope that future releases will fix its deficiencies (the primary problem with the current release is that error messages provide almost no information).

The most recent version of kdb+ uses the new Q language by default. Q is a thin wrapper layer over K (written in K and found as q.k in the distribution). K can still be used.

David, since you have an active interest and presumed expertise, I'd like to see some kind of comparison of J and K...and even with the small WithGlee project, since it appears identical in purpose to J and K.

At first glance K seems wildly obscure, but as is true with some other seemingly obscure things, once you get the hang of it, it proves to be both elegant and incredibly powerful -- DavidNess

K belongs to the class of MinimalistLanguage, because its footprint is so small.

After using K and KDB for the past 6 months in a large development project (for a large international public company), I am very impressed. The language, once learned, is more powerful than anything else I've worked with for querying and analyzing historical datasets and the performance cannot be touched (more than 20x faster than other systems we have), while requiring *much* less code and time. I was lucky enough to have Arthur W. himself actually sit at my desk and show me a few things early on... Bob

The interesting part of the story of APL, A+ and K is that we have awfully unusual languages - usually considered dead or at least zombified - being adopted by large, conservative financial institutions and thriving in a demanding application niche.

The niche in question is tick databases. K is used at a number of investment banks to record all stock market transactions in real time. This amounts to somewhere in the neighborhood of 30 million transactions per day, or about two gigabytes of data. Kdb can apparently support queries on these databases, as well as billions of records of historical tick data, all on relatively mundane hardware (they recommend 2-4 CPUs and 2 to 4 gigabytes of RAM).

It can also perform queries on time-series data more efficiently than standard SQL databases, because its tables are ordered. It can trivially provide price change data and moving averages and other things that financial analysts salivate over.

The application niche and K's adaptation to it is described at http://www.kx.com and in the paper "Time Series In Finance: The Array Database Approach" at http://cs.nyu.edu/shasha/papers/jagtalk.html.

How does it compare to FoxPro and dBASE dialects with regard to nimble table-handling ability? At least FoxPro is less expensive.

yes, FoxPro is less expensive, I can imagine a tick database using it would be worth every penny you didn't pay for it

Does anyone know where one can find help on using the language? I downloaded the evaluation version and I can't seem to get the hang of it...

try asking in the kxforums: http://kxforums.com or try working through some of the manuals http://www.kx.com/download/documentation.php

Recently, the Kona project (http://github.com/kevinlawler/kona) has been working on a fully open-source implementation of K. -- ScottVokes

If you are looking for help on the Q language, there is an excellent book available: "Q for Mortals" by Jeffry A. Borror. Help with the current version of K is another matter. The current 32-bit trial version of KDB+ comes with Q and with K (version 4, or maybe version 5, ...). However, after version 3.2, K became a proprietary language for use by Kx Systems. They no longer sell K2 or K3.2 You can find the orignal User Manual, Reference Manual, and Quick Reference for K2.0 at "Links" on the wiki at http://github.com/kevinlawler/kona


EditText of this page (last edited October 20, 2014) or FindPage with title or text search