HNHacker News
TopNewBestAskShowJobs

leprechaun1066

133 karma · joined June 30, 2020

submissionscomments
leprechaun1066··on Using {blocks} in Rust and Go for fun and profit
K4 is the implementation language of q, kdb is the database part of the language. Most q is just named utility functions written in K4. There isn't really much difference in what the machine does with them under the covers, but when stuck on a problem talking about q is more likely to get help than k.

You can provide up to 8 named inputs in a function definition.

q example for running sum of 8 inputs:

  q)f:{[a;b;c;d;e;f;g;h]sums a,b,c,d,e,f,g,h}
same in K4:

  q)\
  f:{[a;b;c;d;e;f;g;h]+\a,b,c,d,e,f,g,h}
leprechaun1066··on The United States of America vs. Samuel Bankman-Fried Indictment [pdf]
The guy in charge of this for FTX is the same guy in charge of handling getting money back from the Enron collapse. He's currently testifying to congress about the state of things. It doesn't look good.
leprechaun1066··on Zip Function Solution: Haskell, Elixir, JavaScript, Python, Vlang
q:

  {(,')over min[count each x]#'x}
k4:

  {,'/(&/#:'x)#'x}
leprechaun1066··on SQLite: Past, Present, and Future
Most queries to kdb+ do exactly what you are asking for.
leprechaun1066··on K – A simple, fast vector programming language
We stick with q as much as possible. We've found it's better for our front end developers who only touch it a bit here and there to make edits on the APIs they use.

That said we do make heavy use of the functional form of querying tables (https://code.kx.com/q/basics/funsql/#select) in the more complex parts of our systems. The toolbars in the GUIs allow users to select a wide range of possible ways to request data. It's a lot easier to dynamically generate the functional format of the different parts of a select query than it is to try and play with manipulating lots of stored procs. Anyone with experience in a LISP would be familiar with this way of manipulating code as data in this manner, since it's a similar concept.

Some would say this is k, not q and the lines are probably a bit blurred here. Either way there's no question that doing so has made things more productive.

As an aside, there's no performance difference between using k and q. Most of the q keywords are implemented in k. Programs written in k do look quite different to those written in q, even if you stick to the mantra of one thought per expression, one expression per line.

Myself, I used to only like q since it was easier, especially when I started. My only programming background was C# and Python; q made it easy to get into the different paradigm of the APL family. Now, after years working with it, I'd prefer to use k where-ever possible. The brevity is nice. When you write something non-trivial you see a lot of the same patterns of characters on the screen. And it just feels better to write one character for | instead of typing out reverse.

Personally I'd prefer to go with Arthur Whitney's advice from an interview he did years ago (that I can't find a link to unfortunately). He basically said work in k until you need to do big database work with kdb+, then pull in q. Convincing the team and management to let me do that is probably a lost cause though.

leprechaun1066··on K – A simple, fast vector programming language
> let's say I have a finance team that have never heard of it - why might they be interested?

In my experience it's very good at quickly developing real-time analytics applications with only a small set of developers. A couple of q developers can develop, maintain and operate the server side of 5 or 6 separate applications without breaking a sweat. Changes come in at a high speed too.

It's a highly interactive language. A bit like a lisp, you start up a q process, open a port and then you iterate and update your application live without needing to restart. Typically on our projects we've had a well iterated program running in QA for a day or 2 before opening a PR (which becomes more of a formality for getting the solution to the problem into prod at that stage).

The q language itself is quite wordy. Check the reference page: https://code.kx.com/q/ref/ Many programs written in q consist mainly of the key words with the special operators interspersed. Also see some example libraries: https://github.com/finos/kdb

It's been a fairly stable language to work with, having few breaking changes between successive versions. q code written 8/9/10 years ago on older versions will most likely still run the same today. We have source code on one project at work which hasn't had a code change in 6 years now (despite moving through different versions 2.8->3.0->3.3->3.5->4.0) and it runs daily without a hiccup.

Mostly it's a joy working with it because I feel like I get to tell the computer what I want it to do, without also having to tell it how to do it.

leprechaun1066··on K – A simple, fast vector programming language
> so I was just curious if there were any array languages that would be approachable to me

q is a very wordy language that sits on top of K4. Some open source examples of libraries used in finance:

https://github.com/finos/kdb/tree/main/q

leprechaun1066··on Tutorial Series to learn Common Lisp quickly
> the haters that parrot this old, barnacle-ridden trope: it's too powerful! Macros! Nobody can understand it but gods and strange people on the Internet! You will have to listen to these people constantly invade every forum, discussion group, and chat room on the Internet to tell you how you shouldn't be learning CL.

These people are actually the reason I went and learned CL. I couldn't understand why some programmers would hate a programming language so much. Now it's one of my favourite languages.

leprechaun1066··on Fantasy Map Generator (2018)
Also check out https://heredragonsabound.blogspot.com/
leprechaun1066··on Why Lisp?
> One can ask Lisp about all that then

How? As in what commands/functions/macros?

Say I define a function and compile with slime, how do I get the repl to print it back to me? And with a function I loaded from an external library? Is there something like macroexpand-1 for functions which will print it out?

leprechaun1066··on An oral history of Bank Python
The big banks don't write code in K4 though, managers generally encourage people not to write code in it due to the difficulty of finding developers who are fluent in it.

They all use q and q is very wordy and highly readable if you speak english. It's mostly just developer defined functions which are compositions of the keywords of which there are not many: https://code.kx.com/q/ref/#keywords

Most of the code you would see in a kdb+ system in an investment bank won't look like any of the links you've provided.

leprechaun1066··on Stages of Denial
And easier to spot patterns in the source files. Whether someone finds that beneficial or not is subjective I guess, but I think it's useful to be able to immediately recognise what something like +/! is doing whenever you see it in source after using it once or twice.
leprechaun1066··on Learning APL
It's the sign of the number. -7 is negative so you get -1. 7 gives you 1 and 0 gives 0.

  ×-7
  ¯1
  ×7
  1
  ×0
  0
leprechaun1066··on TDD from the Factorio Team
This usually happens when the developers in this situation are focusing (or are being forced to focus) on the tests over focusing on the solution to the actual problem in the product. TDD is just a development methodology which is a means to an end, not the goal.
leprechaun1066··on From Competitive Programming to APL
I am always fascinated by people complaining about decades old programming languages which are still alive and well. Some of those commenters seem to be trying really hard to prove APL and it's offspring are bad/wrong/etc., but history tells us otherwise. Even Numpy relies on the APL family as one of the language groups which guided its design.
leprechaun1066··on How the AWS team will contribute to Rust’s success
> People use tenets for everything at AWS

What is with all the cult/religious/military terminology turning up in software development these days? Squad, ritual, tenet; one day management will be asking us to remember to bring in our robes for the Thursday morning sacrifice...

leprechaun1066··on Brave buys a search engine, promises no tracking, no profiling
> What is the consensus on forwarding any search "terms" to Google and then "scraping" the results back into the user - sort of a "proxy" search.

Isn't this what DuckDuckGo does but with Bing?

leprechaun1066··on How this Ends
He basically said, "Everything that has a beginning has an end." But with way too many words.
leprechaun1066··on A 1000-processor chip powered by an AA battery (2016)
q has this out the box: https://code.kx.com/q/basics/peach/
leprechaun1066··on The Dunant subsea cable
I take my photons medium-rare.
leprechaun1066··on Shorting and Indian capital markets
99% of them are doing more than just not minding Melvin's issues, they're actively feeding off Melvin. Melvin is going to be (or is already) selling off what they have in stuff like FB, MSFT, AAPL, etc, and it's not the retail traders who are benefiting from this, it's the other parts of the investment banking system. Even the sales traders are going to be on the phone with Melvin going "Sell 200k AAPL? No bother."
leprechaun1066··on 2021 will demand new kinds of video conferencing
Friends and I used gather.town for a virtual New Year's Eve party since we were all in lockdown. It went really well.
leprechaun1066··on A review of Dominion, 4000 plays later (2012)
Chapel should just be removed from the game.
leprechaun1066··on Most “mandatory requirements” in corporations are imaginary
The Knight Capital error really messed them up. https://www.reuters.com/article/us-knightcapital-results/kni...
leprechaun1066··on A look at the J language: the fine line between genius and insanity (2012)
Lisp has April, which I thought was pretty cool. https://github.com/phantomics/april
← PreviousPage 2 of 2