9 ms·
K (2005)
- Koshkin 7y agoYou can pry C from my cold, dead hands.
- kick 7y agoNo one's asking you to get rid of C; Arthur (the guy who wrote this article) actually wrote his own C compiler a few years ago! Ever-elegant, it does away with precedence, which makes for much prettier code. http://www.kparc.com/b/ http://www.kparc.com/b/
- gautamcgoel 7y agoHoly shit, this is the craziest C code I've ever seen!
- kick 7y agoIs it? I find it quite beautiful. Have you read the ngn/k source?
- gautamcgoel 7y agoNo I haven't. I'll take a look. When I said the code looked crazy, I didn't mean to suggest it was bad code. It seems quite dense, I'd really like some explanation for how it works.
- kick 7y agoCourtesy of 'yiyus: https://docs.google.com/document/d/1W83ME5JecI2hd5hAUqQ1BVF32wtCel8zxb7WPq-D4f8/edit?usp=sharing https://docs.google.com/document/d/1W83ME5JecI2hd5hAUqQ1BVF3... Also 'tlack's attempt at it: https://github.com/tlack/b-decoded https://github.com/tlack/b-decoded
- Thorrez 7y agoI'm not a fan of it. It looks like minified code. Every variable 1 or 2 letters, very long lines with everything jammed together as much as possible. I would rather have more descriptive and memorable names, and whitespace that aids in understanding the program structure.
- kick 7y agoShort variable names are features, long lines are good (more horizontal pixels than vertical pixels on modern monitors so you keep it all on one screen). Brief and small. Hard to find another C compiler that you can fit in your head, especially one faster/better at generating binaries than LLVM/GCC.
- mhd 7y agoWell, it's not real C, and simplifying a language makes things a lot more easier than having to stick to a lengthy, detailed standard. Not that the compiler ever argues that it does something different than that, it's named "B" after all (never mind the name clash with the original lobotomized BCPL) Some simple Algol-/Pascal-ish compilers used for instruction aren't that much more complicated. Sure, they don't fit in that many lines, but if you consider tokens on a x/y axis, it's not that different. Wirth's Oberon-7 would be a good example for something not toy-like. I do appreciated the terseness, though. APL/K often operate in a specific domain and/or are used interactively, where this is of a big benefit. It does make me wonder how lengthy interleaved string messages would interfere with this. Would a terse language suffer more from the "context switch" between short identifiers and long strings than one where functionsAreWrittenLikeThis in the first place? Probably calls for more variables, otherwise the actual parts of the code are spread too far apart.
- jim-jim-jim 7y agoI've been seeing K mentioned a lot around here recently. Fostering interest in any array language is a good thing imo, but I'm curious about what draws people to K over J in particular. They're both ASCII based with APL heritage, but afaik J is free software and K isn't.
- chrispsn 7y agoYou might like ngn/k, an AGPLv3 variant. https://bitbucket.org/ngn/k/ https://bitbucket.org/ngn/k/
- jnordwick 7y agoPerformance, KDB+, simplicity. I've heard it said that J is for people with brains too big for K. J can be difficult with its hooks, forks, trains, and other complex function application constructs. Job prospects too. K is heavily used in the financial sector (even YC has postings for K jobs in its monthly listings) and pays extremely well for what is basically a database developer.
- jim-jim-jim 7y agoThanks for the info. I think J's implicit combinators have made me a better tacit programmer, but over reliance on them can make things frustratingly ambiguous. The monadic/dyadic overloading in all these langs doesn't always help either. I recall somebody here recently writing a K implementation where there was explicit syntax for the uh... adicity(?) of operators, but I forgot to bookmark it. Anybody know what I'm talking about?
- uryga 7y agok (well, some version of it) has something along those lines: > [the] `:` in `|:` is used to force the verb `|` to be interpreted as a monad, as by default ambiguities are resolved in favour of dyads. http://www.math.bas.bg/bantchev/place/k.html http://www.math.bas.bg/bantchev/place/k.html
- jnordwick 7y ago
- rpz 7y agoI've noticed the term "low code" being mentioned more often lately, but never in relation to array programming languages. In my opinion languages like k, q, apl and j are the most flexible and expressive low code programming platforms on the market.
- jnordwick 7y ago> K stands for “keys to the kingdom”. Lol. It's actually just the letter after J, since K was supposed to be the next in the APL-ish family.
- rpz 7y agoArthur wrote the article :)
- jnordwick 7y agoHa, I didn't notice that. But I've heard it before on the K list. I think it is more of a backronym than a serious statement. This is a guy who names his source files a.c, b.c, c.c, ..., z.c. I'm unsure why Ken Iverson named the J language that though.
- earenndil 7y agoProbably because A through I were already taken.
- tosh 7y agoalso: https://web.archive.org/web/20041024212043/http://www.kx.com/listbox/k/msg06335.html https://web.archive.org/web/20041024212043/http://www.kx.com... > i call most of my languages A but to avoid confusion i switched to the phoenician aleph. (h/t chrispsn)
- anonu 7y agoInterested to see what happens with Shakti, the newer iteration of Kdb
- 7thaccount 7y agoI wish their site said more.
- kick 7y agoAre you on the mailing list? It's a bit slow, but seriously cool to see random people bring up strange bugs and Arthur going "thanks! fixed in the next release." over and over again like clockwork.
- 7thaccount 7y agoNo, but I might add myself. Speaking of fast bug fixes. 8th is a commercial Forth-like language for embedded, desktop, server, and iOS/Android that is kind of like that. It is basically a small (few MB) binary that is a full REPL that can cross-compile your code into an encrypted binary. It has nice GUI, SQL, Rest, REPL,JSON/CSV/XML...etc support all built-in as well as a bunch of other goodies. Releases happen very regularly and reported bugs are fixed incredibly fast. There is a forum with a lot of activity from the fairly small user base. Probably not everyone's cup of tea, but I've had a blast playing with the free version. The professional version is like $250 and after your free upgrades wear out you can then upgrade for a reduced cost. Full source is also available in the Enterprise edition with an NDA. In some ways it has some similarities with K. Long story short to see hundreds of posts requesting some obscure feature of edge condition and seeing a reply a few hours later with "fixed". It seems to be a pretty mature language for one person to build. I have not bought a professional edition yet as I'm having fun with the free one and this is probably not something big corporate IT would like. If I start building enough tools at home, I might go in that direction. Also, no affiliation with the project, they just seem to get a lot of my wish list right. I really wish it was a free/open source project as I bet it would catch on more.
- 7y ago
- chrispsn 7y agoFWIW, this is from 1993, not 2005. http://archive.vector.org.uk/10 http://archive.vector.org.uk/10
- snicker7 7y agoI work in the financial industry and code in K3 (among a number of other languages). Things I like: highly orthogonal & minimalistic design (basically vectors and functions acting on vectors), easy C FFI, well documented, satisfying to minify production code, my inflated salary (+job security for some). Things I dislike: proprietary, impossible to skim, APL/J/K "culture", over-marketed, functions/operators overloaded in very unintuitive ways, lack of lexical scoping, interpreted languages falling out of vogue. Overall, I recommend every coder to try K (or J or APL) at least once. They compare favorably to NumPy/R in many respects.
- jnordwick 7y ago> interpreted languages falling out of vogue This would be for performance issue though. And K, even when interpreted, is still faster than most people's C code because the interpreter does very little and most of the time is spent in optimized loops. Also, I heard rumors of a JIT (I've seen some of his compilation code and it is pretty amazing and small and even include SSE/AVX optimizations).
- yjftsjthsd-h 7y ago> include SSE/AVX optimizations I would expect K in particular to benefit immensely from SIMD instructions, yes?
- jnordwick 7y agoI think they were added about 5 years ago?
- userbinator 7y agoAPL/J/K "culture" What exactly is it about the "culture" which you dislike?
- shitgoose 7y agohigh brow. some people find it annoying:)
- bollu 7y agoI wrote a post on learning the prototype J interpreter that was written by Arthur Whitney: http://bollu.github.io/#incunabulum-for-the-21st-century-making-the-j-interpreter-compile-in-2020 http://bollu.github.io/#incunabulum-for-the-21st-century-mak... It's an enjoyable codebase to stare at and figure out
- dlevine 7y agoWe used K/KDB at my first job out of college. One one hand, it was fast and terse. The downside was that the code was nearly impossible to read by anyone but the original author, and for some reason they encouraged one-letter variables. This actually propagated to the rest of the code base (com.a.x).
- kick 7y agoSingle letter variables are actually a feature, not a bug. (I think you'll be able to find some passionate defenses of it if you use HN search, better than I can do certainly.)
- dmitriz 7y ago> v: 3 4 /a vector, i.e. a list of 2 atoms. > v+'v /v plus EACH v, i.e. (3+3;4+4). > 6 8 How is for EACH working here? Adding v (a 2-vector) to each element gives a 2-vector, so why isn't the result a 2-vector of 2-vectors?
- chrispsn 7y agoIt applies element-wise across both arrays. What you're describing is more like an each-right (+/:) or each-left (+\:). 2019-09-25 14:44:44 2core 3gb avx2 © shakti l test v:3 4 v+v 6 8 v+'v 6 8 +'[v;v] 6 8 v+/:v 6 7 7 8 +/:[v;v] 6 7 7 8
- dmitriz 7y agoIndeed, that was my confusion, thanks!