22 ms·
What about K?
- sebg 2y agoA companion guide that I always recommend if interested in K is: Q for mortals, found here - https://code.kx.com/q4m3/ https://code.kx.com/q4m3/ Note, from wikipedia: Q serves as the query language for kdb+, a disk based and in-memory, column-based database. Kdb+ is based on the language k, a terse variant of the language APL. Q is a thin wrapper around k, providing a more readable, English-like interface.
- mwexler 2y agoPulled from above: Coding Style The q gods have no need for explanatory error messages or comments since their q code is perfect and self-documenting. Even experienced mortals spend hours poring over cryptic q error messages such as the ones above. Moreover, many mortals eschew comments in misanthropic coding macho. Don’t. A more enjoyable read than the parent post.
- nialv7 2y agoThere's also Nial: https://github.com/danlm/qnial7 https://github.com/danlm/qnial7 which is (pardon the oversimplification) APL but with words instead of symbols.
- steveBK123 2y agoA set of links with good examples of common problems solved in Q https://code.kx.com/phrases/wikipage/ https://code.kx.com/phrases/wikipage/ https://code.kx.com/q/kb/programming-idioms/ https://code.kx.com/q/kb/programming-idioms/ https://code.kx.com/phrases/ https://code.kx.com/phrases/
- kvdveer 2y agoThe linked document only contains a warning about how versioning is weird, and a description of the syntax. No examples beyond trivial one-liners. What problem is K trying to solve? What does a K program look like?
- sz4kerto 2y agoAbsolutely not being sarcastic: one problem it solves is that it is very hard to read as a beginner, so it can be intimidating (although it becomes much easier to read a bit later). This, coupled with the general arrogance of k/q practitioners (again, not really saying this in a negative way) and that k, kdb, etc. deliberately doesn't give you guardrails makes people who write k/q seem a bit 'mythical' and make them feel very clever. So I think k, q and kdb are fun to work with, but one of the major components of its success is that it allowed a community (in finance) to evolve that can earn 50-150% more than their peer groups who do the same work in Java or C++. 10 years ago a kx course cost $1500 per person per day.
- pjmlp 2y agoTo note that those are typical prices for enterprise level certifications, including some products that some Java or C++ devs might need to interact with, when working on those kind of environments.
- cppandjava 2y agoHmm. I work in finance writing C++ and Java and I doubt other people in finance make 50-150% more than me because they know `q`.
- gitonthescene 2y agoI don't know. If you're writing Java you may not be working on the same types of problems.
- bear8642 2y agoK is a fast vector language, used (primarily) for time series data analysis. >What does a K program look like? You might want to check out https://news.ycombinator.com/item?id=40335921 https://news.ycombinator.com/item?id=40335921 beagle3 and geocar both have various comments you might want to search for.
- 2y ago
- z5h 2y ago> Readability is a property of the reader, not the language. Similarly, the inability of a person to write machine code directly is a property of the person, not the hardware. Yet some of these people admit their limitations and use K.
- pyrale 2y agoSilicon computers are a crutch for the people too flawed to run their calculations in their head.
- deleted 2y ago[deleted]
- Ygg2 2y ago"It is by will alone I set my mind in motion. It is by the juice of Sapho that the thoughts acquire speed, the lips acquire stains the stains become a warning. It is by will alone I set my mind it motion..."
- psychoslave 2y agoDo you mean that not everyone use butterfly yet? How quaint!
- coder543 2y agoButterflies? Easier to catch a caterpillar and set it on the right path to one day flap its wings in just the desired way.
- tempodox 2y agoLet me sell you an AI that genetically engineers caterpillars to do just that.
- jagged-chisel 2y agoBut can it also provide instructions to set the universal constants at the start so the universe evolves the desired result?
- hcfman 2y agoI build a language called K for my masters thesis in 1984. Who was first ?
- mlochbaum 2y agoYou win! Whitney was just out of graduate school at the time, and had worked some with APL at I.P. Sharp but was implementing "object-oriented languages, a lot of different LISPs, Prolog"[0]. Next was the more APL-like A around 1985 and K only in 1992. [0] https://queue.acm.org/detail.cfm?id=1531242 https://queue.acm.org/detail.cfm?id=1531242
- ZeroCool2u 2y agoI cannot warn folks against using q/kdb+ enough. Use Polars or DuckDB, get the job done, and enjoy your life.
- jerjerjer 2y agoEh, no need. Author states in the first two paragraphs that there are 9 versions of k, each developed from scratch and incompatible with each other. Anyone who develops software for money should and would leave immediately. I do appreciate the honesty, though.
- 7thaccount 2y agoWhat has your experience been like? What are the drawbacks besides the cost and proprietary nature?
- ZeroCool2u 2y agoI don't want to be too disparaging, so I will just say that the language is exotic. Otherwise, the licensing model is Oracle-esque based on host and core counts etc. The software is fast, that you cannot deny, though it does critically depend on the speed of the storage attached to the host. Also, it's written in C++ and it shows. Had to do multiple (paid) upgrades due to memory leaks. I'm sure there was a time it was best in class and even now maybe it's the best for a few niche use cases, but unless you're absolutely certain you need it, I would flee from it and save your sanity.
- 7thaccount 2y agoI thought it was written in just plain C based off old Arthur Whitney stories. Yeah...Oracle licensing sounds scary and having to pay to fix their own memory leaks sounds frustrating. Thanks for the experience.
- ZeroCool2u 2y agoYou know what, I can't place where exactly I heard it was C++ rather than C and they just ship you a binary blob executable, so I may be wrong and it absolutely could be plain C.
- HexDecOctBin 2y agoWhat is the difference between APL and all the various APL-like languages like BQN, J and K? Which one should a beginner start with? Which has the best tooling for debugging, type checking, etc.?
- radiator 2y agoI think the best today cannot be APL, because it carries so much historical baggage and because commercial implementations dominate it. So start with BQN, it is free, has the tooling and it also has succeeded in building a community.
- skruger 2y agoDepends. APL is the OG. Try a few and see what you like. If you learn one Iverson language, it's pretty easy picking up the others. Here's a gentle guide to APL by the same author (me): https://xpqz.github.io/learnapl/ https://xpqz.github.io/learnapl/ Dyalog APL is likely the best supported in terms of tooling, debugging etc. If you're looking for static typing, you're in the wrong place.
- tomku 2y agoThere's several ways to look at the differences. The one that will jump out at most programmers who are familiar with mainstream languages is that J, k, q and Nial use ASCII characters while APL, BQN and Uiua prefer glyphs. q and Nial additionally favor words rather than shortened abbreviations, and Uiua has plain words that auto-format to its glyphs to aid in typing. The other glyph-based languages rely on custom (software) keyboard layouts or input methods to let you type the symbols they need. You do not need a special keyboard to program in any of these languages. ASCII-or-not is not a decision that any of the array languages have made lightly or for purely aesthetic reasons, it has deep consequences for how the languages feel that won't really make sense until you get some hands-on experience. As a beginner you'll probably gravitate towards one of the sides without understanding those deeper implications, and that's totally okay, but please keep an open mind. If access to a high-quality open-source implementation is important for you, your options narrow a bit. J, BQN, Uiua and Nial all have a primary implementation that's open source. k has implementations that are open-source but the official versions of k that most people use "in anger" are commercial products with a limited free trial, and afaik there's no mature open-source versions of kdb+/q, which are kind of k's killer app. There are many implementations of APL but Dyalog is the clear leader and it's a closed-source commercial product with a personal/non-commercial free version. I wish this was less of a factor because it's so hard to get people interested in languages when the best versions aren't available to them, but it has gotten better in recent years. Regarding tooling, you should go in with minimal expectations. Some of the tooling is quite good (particularly J and Dyalog APL, in my opinion) but it's heavily biased towards the specific type of iterative, interactive development that nearly all array programmers favor. Debuggers are sometimes present but usually not a primary tool. None of the major array languages have static typing. There are some array-adjacent languages like Futhark and Dex that do, but they're very different than the "Iversonian" array languages you asked about, and are also active research projects. (Edit: Also worth mentioning that package managers and build systems are not common in the array world.) There are many other differences that matter immensely to the array community but you won't have context for as a beginner, so I'm not going to go too deep into them, but if you're curious, https://github.com/codereport/array-language-comparisons https://github.com/codereport/array-language-comparisons has some comparison tables and example code written in a variety of languages. code_report/Conor's Youtube channel at https://www.youtube.com/@code_report/ https://www.youtube.com/@code_report/ is also an excellent place to get exposure to various array languages and concepts. All that said, in my opinion the easiest languages to recommend to get started are BQN and J, depending on whether you want glyphs or not. If you're comfortable using a closed-source tool with restrictive licensing, Dyalog APL is also an excellent choice. Any of the three will show you both the joys and pains of array programming if you put time into learning it, and give you enough context to make an informed decision about going deeper or finding another array language more to your taste.
- jamal-kumar 2y agoI always thought it sounded super cool but it just doesn't exist in the problem spaces I work in. Like kdb+ was specifically designed to be run on bare metal without a full OS in the way of things going fast, and in quant environments where you're trying to shave off nanoseconds on the computations because your company's gone and invested in a dedicated fibre line to trading servers.
- eudhxhdhsb32 2y agoThat's actually not true at all. No one who cares about nanoseconds is using kdb+ for a production trading system. It's primarily used for trading research and surveillance, not live trading. And I've never heard of anyone running it without an OS.
- bear8642 2y ago> And I've never heard of anyone running it without an OS. kOS is in development though current status is unknown. (https://gist.github.com/chrispsn/da00835bb122c42f429a084df83fd746 https://gist.github.com/chrispsn/da00835bb122c42f429a084df83...)
- 7thaccount 2y agoI think that got abandoned ages ago.
- jamal-kumar 2y ago""Arthur succeeded in getting it to run, but eventually got drowned in device drivers." heh
- WorkerBee28474 2y ago> No one who cares about nanoseconds is using kdb+ for a production trading system. For those curious, what they're actually using is FPGAs and custom silicon.
- pie_flavor 2y ago> Readability is a property of the reader, not the language. Uiua[0]'s stack model is much more annoying to work with, but I really appreciate its embrace of unicode glyphs. Every other derivative of APL throws those out at the first opportunity, but when you have a lot of glyphs, you stop being so tempted to make different arities cause the same glyph to mean wildly different things, when the arity is not actually written down explicitly and depends on whether the next thing to the left is a parameter or another function. Once you can See The Matrix, this is the chief thing that still does make K and friends objectively unreadable in a way they don't have to be. [0]: https://uiua.org https://uiua.org
- xg15 2y agoI appreciate the idea (and Uiua's examples indeed look beautiful, almost like visual programming) but I'd at least like some obvious way how to pronounce the code.
- RodgerTheGreat 2y agoAll of the symbols in Uiua have short english words as alternate names, and the online editor allows you to type them by alias. K has "traditional names" for all the primitive operators which appear in reference cards and which are typically used when discussing code aloud with other K programmers. Q and Lil, which are both K descendants, outright replace some symbols with those named keywords. Named keywords can make the primitives superficially easier to remember, at the cost of making idiomatic patterns in the language less visually apparent.
- xg15 2y agoAh, that makes a lot more sense. Thanks!
- gweinberg 2y agoOriginal quote is just mind-bogglingly stupid. If If I can't read any programming language, that's a defect on my part. If I can read pretty much any language except k and brainfuck, that's a sign k is particularly difficult to read.
- blablablerg 2y ago"K is a general-purpose programming language that excels as a tool for data wrangling, analytics and transformation." How does it compare to R/tidyverse?
- 7thaccount 2y agoIt's mainly for quants where you couple the array language with a time series database of all your stock quotes. Once you understand the language you can do a ton of analysis with extremely little code. Think of it as a mathematical SQL dialect I guess. In my opinion, it's very cool, but Python's ecosystem (and R's) is just so much better with scientific libraries and charting and all that. Kdb+ (the database) and K the language are likely much faster than R for general analysis type stuff. R is also free and Kdb+ is not.
- poulpy123 2y agoI'm somewhat convinced that there is a middle ground between corporate java and languages like K
- tempodox 2y agoIDK, I'd rather have a language that compiles to native code, isn't quite as write-only as that, and doesn't cost an arm and a leg, even when using a DB.
- unit149 2y ago[dead]
- sl0thentr0py 2y agoi've been doing the last 3 years advent of codes in q/kdb+, it's a lot of fun https://github.com/sl0thentr0py/aoc/blob/main/aoc2023/3/foo.q https://github.com/sl0thentr0py/aoc/blob/main/aoc2023/3/foo....
- James_K 2y ago> Strings are just vectors of characters I hope not.
- lytedev 2y agoCan you elaborate? Why not?
- James_K 2y agoA character could be 1 byte long, in which case the language cannot properly handle unicode; it could be 4 bytes long in which care there is lot of wasted space storing text and it cannot properly handle extended grapheme clusters; or a character could be arbitrary length at which point strings no longer have a flat representation in memory. None of these are good. The exact properties of a string can really only be encoded efficiently with a flat linear access data-type.
- dzaima 2y ago1-byte characters (i.e. what k's typically have) handle ASCII just fine, for which doing reversing/splitting/uppercase/lowercase/iteration/etc is actually meaningful (stock symbols, stringified dates, identifiers, etc). And if you have to handle arbitrary language user input, there's basically no operations you can/should actually do anyway. Uppercasing/lowercasing? Doesn't make sense on CJK languages. Reversing? Completely meaningless. Trimming to the first N chars for some visual display/summary/preview? Even grapheme clusters won't help avoiding a character with ten thousand combining components, and you'll have to do language-specific logic to not cut in the middle of a word for languages where the display of a prefix of a word may change depending on later letters! And forget about spaces meaning anything. Basically the only string ops I can think of that make sense for non-ASCII generally would be splitting/joining on newlines and escaping for JSON/HTML or whatever, which'll work completely fine on a byte list anyway. There's perhaps some middle-ground of doing things for a specific set of languages, but even for such you won't care about the storage format anyways, as what matters for you is just whether operations you use (presumably using some library; and even if you write a manual uppercase for French specifically or whatever, you'd notice if you implemented it wrongly) do the thing they should. So a list of byte chars is just fine for anything one would actually do, providing optimal access to ASCII, and not actually making things worse for non-ASCII.
- khazhoux 2y agoDevelopers act like they forgot about K
- pjmlp 2y agoWhat seems to be a pity about most array languages is that in theory, they would be ideal DSL languages for SIMD and MIMD code exploration, but as far as I understand from ArrayCast guests, most are still interpreters at heart focusing on plain CPU execution.
- dzaima 2y agoThe big problem with using array languages for lower-level SIMD stuff is that that generally requires some amount of typedness, but tacking on types on an array language without ending up with having types be the majority of the syntax and code (or taking up a ton of mental capacity if utilizing very heavy type inference) would be rather non-trivial. And the operations you want for lower-level ops are quite different from the higher-level general-purpose ones too. (and, of course, some interpreters do make good use of SIMD and/or multithreading) That said, some form of array language more suited for stuff like that is a somewhat common question; maybe one day someone will figure it out. Vanessa McHale is doing some interesting work on a typed compilable array language, Apple[0]. [0]: https://github.com/vmchale/apple/?tab=readme-ov-file#apple-array-system https://github.com/vmchale/apple/?tab=readme-ov-file#apple-a...
- pjmlp 2y agoThanks for the hint. While we have CUDA being polyglot, it is still pretty much C and C++, or shader languages, hence why I keep thinking why not an array language that is also a kind of shader language DSL.
- dzaima 2y agoOh, another interesting thing is http://beyondloom.com/tools/specialk.html http://beyondloom.com/tools/specialk.html - a simple k DSL for shaders. Though it still follows the shader language paradigm of running the function for each pixel separately, rather than the array language paradigm of taking & returning a list of things to process.
- Pompidou 2y agoMaybe codfns for apl will solve this ? That's what I understood.. but maybe I'm wrong.
- airstrike 2y agoSide note, but some people have such an evident talent for writing that it makes reading about _any_ topic a worthwhile experience. This author, Stefan Kruger, seems to be one of them. I almost wish this link was to a blog rather than to a book about K, for which I only have a perennial curiosity. Here's to hoping they consider writing said blog. I notice they have one but it only has 3 posts, all of which are about past Advent of Code puzzles.
- bear8642 2y agoThe about section has links to other things he's written/presented.
- jyscao 2y ago>for which I only have a perennial curiosity. Guessing you meant to say "peripheral curiosity" here? Perennial would mean you have a long-lasting and/or continued interest/curiosity.
- airstrike 2y agoI was wondering if anyone would find that unusual! It's long lasting but never rises to anything more than curiosity, so I wanted to juxtapose the two to convey the mixed feelings I have for it.
- skruger 2y agoThat’s nice of you to say so.
- IshKebab 2y ago> The same baseless accusations of “unreadable”, “write-only” and “impossible to learn” are leveled at all Iversonian languages, k included. I'd be really curious to know if they really are baseless. It's very very difficult to imagine that K developers can really read a mess like this as easily as one might read Go or whatever. https://github.com/KxSystems/kdb/blob/master/e/json.k https://github.com/KxSystems/kdb/blob/master/e/json.k Has anyone tested this? Take a K program and ask a K developer to explain it? Or maybe introduce a deliberate bug and see how long they take to fix it compared to other languages. You could normalise the results based on how long it takes them to write some other code. Free research project for any compsci researchers out there... (though good luck finding skilled K programmers).
- geocar 2y ago> It's very very difficult to imagine that K developers can really read a mess like this as easily as one might read Go or whatever. 水落石出。 > Has anyone tested this? Take a K program and ask a K developer to explain it? I am not sure what you're asking. Do you want me to read it to you? Here is me reading some other people's code: https://news.ycombinator.com/item?id=8476633 https://news.ycombinator.com/item?id=8476633 https://news.ycombinator.com/item?id=22010223 https://news.ycombinator.com/item?id=22010223 Do you want me to read to you the JSON encoder (written twice) and the decoder in this way? > Or maybe introduce a deliberate bug and see how long they take to fix it compared to other languages. https://news.ycombinator.com/item?id=27209093#27223086 https://news.ycombinator.com/item?id=27209093#27223086 > You could normalise the results based on how long it takes them to write some other code. https://news.ycombinator.com/item?id=22459661#22467866 https://news.ycombinator.com/item?id=22459661#22467866 https://news.ycombinator.com/item?id=31361023#31364262 https://news.ycombinator.com/item?id=31361023#31364262
- IshKebab 2y agoThanks that was very interesting. It seems to me that it has a lot of the same properties as regex. Looks like gobbledygook at first glance, but after learning it I can write them, and read them with some effort (depending on the complexity). However nobody would describe regexes as "readable", and they're quite error-prone. I definitely wouldn't want to write a whole program in regex. Regexes shine most when they're used interactively, e.g. in one-off greps, or editors. There readability doesn't matter at all, error-proneness doesn't really matter, and terseness is important. The problems start when people put those grep commands in scripts where the output isn't supervised by humans. I wonder if the same is true for K - it started as a query language for one-off queries & investigations, and then people started saving those queries and making bigger programs?
- russellbeattie 2y ago> "there is no single definitive k, but instead a sequence of slightly incompatible versions. If you decide to stick with k, you’ll see mentions of k4, k5 etc." I don't know about the qualities of k itself, but I think the idea of having a common practice for experimental programming languages to be grouped under a single name like "E" with a number is quite attractive. There are lots of students, hobbyists, researchers, professional devs and companies who are developing their own working programming language. There are a million of them, all with their own names. 99.9% of them are ignored, or criticized unfairly by others expecting fully fleshed out features. I can imagine a GitHub repo where you can register a new language "En" (with n being a number) rather than it living in obscurity on a random website. Then others can jump in and experiment with the language and give it feedback, fork it, etc. This isn't just for toy languages, but for big organizations like Google. Instead of naming a not-fully-baked C++ successor as "Carbon" and getting flak for it not being ready for real world code yet, they could simply call it "E321" and the status of the language would be self-explanatory. Then if one of the E languages gains enough traction, it could "graduate" to its own named language. I also like the cred that an "official" E language could get when a dev talks about it to others. Everyone would immediately know it was experimental and where to see the code.
- sedatk 2y ago"k" was used in lowercase throughout the article, including the title.
- nottorp 2y ago> As you’ve landed here, you’ve clearly somehow sought out k, and you likely have an idea what it’s about. Author didn't expect to end up on HN then :)
- shric 2y agoMy first thought was "weird, they made a language called k even though there is already a language called K". I then realized it's actually talking about K. Thoroughout the article it's spelled k consistently except at the start of a sentence. This is weird. The language is K not k. Nobody spells the C language as c.
- cess11 2y agoIt's actually rather common to spell its as k, as well as K. I think q is more common than Q.
- Nihilartikel 2y agoImplement all this jazz with s-expressions and I am on board!
- liveranga 2y agoYou're in luck: https://github.com/phantomics/april https://github.com/phantomics/april
- sega_sai 2y agoI had to learn it for the interview homework for a quant job. It is a fun language to to solve small-ish problems. I somehow got a feeling it's a good language to show off clever solutions, but in the same time I can't comprehend how one could use such a language for any serious large code.
- rak1507 2y agoI had a peek at your github profile, and noticed "sqlutilpy", "Python module to efficiently query SQL databases and return numpy arrays". K is like if a language just did that by default.