Introduction
The k and q languages are general purpose programming language developed at Kx for their kdb+ database. The q language is built on top of the k language (specifically k4, the 4th generation of the k language) which has roots in APL.
I’ve written several blog entries on k and q. Here they are in reverse chronological order:
- 20091209: American Binomial Model in q
- 20091204: European Binomial Model in q and Python
- 20091204: Binomial distribution in q
- 20090913: Gray code in q
- 20090427: A Conversation with Arthur Whitney
- 20090210: Game of Life in (one line of) k
- 20090210: Game of Life in (one line of) q
- 20081215: Faster solver for (1,3,4,6) Puzzle in k
- 20081214: Solver for (1,3,4,6) Puzzle in k
- 20081214: Randomized N Queens in k
- 20081205: Finding words in k
- 20081202: N Queens in k
- 20081130: More Sudoku solvers in k and q
- 20081128: Sudoku solver translated from k to q
- 20080731: Lagrange Interpolation in q
- 20080714: Regular Expressions for q
- 20080704: Longest Increasing Subsequence in q
- 20080701: Birthday Paradox in q
- 20080624: Sieve of Eratosthenes in q
- 20080616: AES in q
Feel free to read them. Constructive criticisms are welcomed!
What makes k and q unique among the multitude of programming languages are their:
- expressiveness: High-level data structures (lists, dictionaries, tables), higher-order functions, adverbs and powerful data manipulation (group, sort, rank, etc) make it easy to express sophisticated algorithms, thus living up to the idea of “notation as a tool for thought“.
- speed: They are blazing fast for an interpreted language.
- conciseness: The compact syntax takes a little getting used to initially but after a while I really appreciate reading a few line of k and q code as opposed to many paragraphs of C/C++.
- compactness: The interpreter is about 240KB as of version 2.4. That’s incredibly small compared to other languages and database products.
- extensibility: It is really quite easy to write extensions for k and q in C/C++.
- vector processing: For problems where one has to operate on large multi-dimensional arrays, this is useful.
- database integration: It is probably true to say that k/q is kdb+ and kdb+ is k/q. Most other languages don’t have a database implementation built-in.
- functional paradigm: I am quite new to functional programming but I find it a powerful paradigm for solving problems and thinking about algorithms.
How to learn k and q
Since k and q are proprietary languages, most of the official documentation are available from Kx’s site.
- http://www.kx.com/developers/
- http://code.kx.com
- http://www.kx.com/q/d/
- http://groups.google.com/group/personal-kdbplus
There are also several sites on k, q, kdb+ and vector languages. The list below is non-exhaustive. I only list those that I know. If there are other sites that I’ve missed, do let me know:
- http://www.vector.org.uk
- http://www.nsl.com (Stevan Apter)
- http://vrabi.web.elte.hu/k/ (Attila Vrabecz)
- http://homepage.hispeed.ch/milano/ (Milan Ondrus)
- http://stuntprogrammer.com (Niall Dalton)
- http://www.rendezvouswithdestiny.net/finance/finance.html (Ng Chu Ming)
- http://kdbconsulting.wordpress.com (streamstar)
- http://lifeisalist.wordpress.com (enlistme)
19 February, 2011 at 11:32 pm
finding words in k
not working
$ problem
8 April, 2013 at 7:16 am
Hi there, first of all your blog is great.
I am currently want to write a Q script to find a shortest path for 2 points on a diagram with some nodes and edges using dijkstra’s algorithm theory. But I do not know how to solve it.
Could you write some codes to inspire me? I can email you my diagram if you need it.
Appreciate