How does kdb compare to cloud computing?

Cloud-based solutions (such as Hadoop) are great if

  • you have developers who know how to program them
  • you don’t mind putting your data on a cloud
  • the data you need for even a single query can’t fit in memory
  • you can afford to wait minutes for your query results

For some applications, then, clouds are an excellent approach. kdb+, however, is typically used in scenarios where

  • you can’t (e.g., due to licensing) or don’t want your data outside your firm
  • you don’t have an in-house cloud infrastructure
  • you don’t want each query to be an IT project in and of itself
  • you want the answer to your query in milliseconds (or seconds at worst)
  • you can fit your data in memory (not necessarily all at once)

Is polymorphism supported in q?

While q has no notion of inheritance, class, metaclass, or prototype, you can create structures packaged with associated functions and invoke those functions via the structures. Consider the following tired OO example expressed in q:

Draw: {[shape] shape[`draw] shape}

(Sadly, we cannot write shape.draw shape; dot notation is not supported for local variables, including arguments.)

Given an appropriate set of constructors –

NewCircle: {[x; y; radius] `x`y`radius`draw ! (x; y; radius; {[circle] … })}
NewRectangle: {[x; y; w; h] `x`y`w`h`draw ! (x; y; w; h; {[rect] …})}

etc, the following does exactly what you would expect:

shapes: (NewCircle[0; 0; 1];
NewRectangle[-1; -2; 4; 2]);
Draw each shapes;


This work is licensed under a Creative Commons License.
The views and opinions expressed herein are those of the authors and do not necessarily reflect those of any other person or legal entity.
Kdb+ is the registered trademark of Kx Systems, Inc.