k & q

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:

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.

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:

2 Responses to “k & q”

  1. g lewis Says:

    finding words in k
    not working
    $ problem

  2. Jason D. Says:

    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


Leave a comment