Hacker News new | ask | show | jobs
by sergiotapia 1345 days ago
That has to be the tersest language I have ever seen in my life. Code golf but it's actually a real language used heavily in finance.
2 comments

I think ‘used heavily’ is a bit of an overstatement.

I think the right intuition for APL-family languages is that they mostly do numpy-like operations except their set of operations tend to compose very nicely. So the idea is that one can quickly and interactively figure out a composition of the operations which will do the calculation you want, but you don’t have a complicated compiler and spend most of your time in the operators rather than the interpreted language, and the operators tend to make the cpu happy – they work on contiguous memory, tend to be vectorized, don’t branch unpredictably, etc – so even if you have to compose many steps, you win on the time to write and the time to execute can be hard to beat because the constant factors of each individual operation are good.

For obvious reasons, things like numpy, pandas, dplyr, etc are more popular as their syntax is a bit more readable and it is easier to get data in/out. I think they do lose a bit by not having lots of the useful compostable APL-style operators because those things don’t have comprehensible names.

I wrote http://KlongPy.org to blend Klong and python. Eat your cake and have it too :)
> compostable APL-style operators

APL-style operators have been sent to the compost heap of history for a reason.

Fold

Scan

Map

Head/tail

Index (with an array)

The integers up to n

Concatenate

Flatten

Most of the operators are already familiar but they tend to work well on multidimensional arrays and with each other due to broadcast semantics (and some axis selection features). In other languages you may see the magic broadcasting for some operations like addition but many of the functions only work on vectors.

Some exchanges like BitMEX are written in kdb+, as in, the trade engine.
What is a trade engine?
The actual thing that lines up a series of sell-at-this-price bids and the series of buy-at-this-price bids (or even more complicated types of orders, this the easy case) and crosses them over, figuring out who gets what bids filled by whom at what price, at supremely fast speeds and large volumes.
I think I’ve only heard of such a component referred to as a matching engine.
I've heard it both ways. Now you have as well, so next time you see it, you won't need someone to explain it to you.
I did try looking it up fwiw. That was my guess but I was wondering if you meant something else and didn’t want to jump to conclusions.

I was surprised by the suggestion that kdb+ was used for this because a matching engine doesn’t really sound like the kind of case that APL-family languages would be well suited to – they tend to work well on large batches of data but for a matching engine, you have messages that come in over time and you want to process each message with reliable low latency (if you have higher latencies you will get wider spreads which is a competitive risk and leads to collecting less in fees), which means not operating on batches.

Do you have a source for the claim that kdb+ is used for the matching engine?