25 ms·
Arthur Whitney's 'B' Language
- 3xblah 8y agoWhere is k.c?
- icen 8y agoWhy would you expect a k.c? This is b. There's a b.c.
- tluyben2 8y agoIt's referenced in the Makefile.
- theoh 8y agoOn a possibly unhelpful tangent, I'm expecting it to look something like this: https://code.jsoftware.com/wiki/Essays/Incunabulum https://code.jsoftware.com/wiki/Essays/Incunabulum
- ColanR 8y agoIt sure does: http://kparc.com/b/b.c http://kparc.com/b/b.c
- theoh 8y agoI'm so tempted to just respond with "wanker", though I know HN norms don't allow that. Either the code is for human consumption (in which case, fulfil that goal) or you're writing demoscene assembler which displays virtuosity without any positive impact on society.
- ColanR 8y agoI think the problem is, we intuitively estimate the readability of code based on the space it takes up, when we should take into account the information density. That code is extremely readable - if you assume it will take just as long to understand as the entirety of the GCC compiler: https://github.com/gcc-mirror/gcc https://github.com/gcc-mirror/gcc
- avmich 8y agoRead "A programming language", where APL came from - https://www.amazon.com/Programming-Language-Kenneth-Iverson/dp/0471430145 https://www.amazon.com/Programming-Language-Kenneth-Iverson/... - you might get more understanding why it is the way it is. It is the mathematical notation, put into, as Dijkstra expressed, "technologies of the past", completed (to be Turing-complete) and made executable. At least, I think, this is the basic idea.
- deleted 8y ago[deleted]
- theoh 8y agoThe code I linked to was written in one session (probably) and it really isn't comparable to GCC in complexity. It's an interpreter, but one where the author has made no attempt to make the process of interpretation legible. He's too busy "achieving" things with his code. I guess there should be a niche for people like that, but the APL/post-APL community seems to think that Arthur has special computer science knowledge that can be best (or only) expressed in this form. We all know that's bullshit.
- 3xblah 8y agoCompanies pay large licensing fees to use this software. There must be some "positive impact" on their business.
- nemo1618 8y agok is probably omitted because it's not open-source.
- jshaqaw 8y agoWhitney’s code is what I expect code to look like post-singularity when hyper intelligent AI program themselves!
- mark_l_watson 8y ago+1 thanks You got me thinking how AlphaGo reinvented the style of Go for human players. A real AI taught one of our programming languages would code in a way that would be alien to us. Whitney’s code is fascinating. I thought that someone might use a good C IDE to rename symbols to longer human readable names, but, that would harm the terseness of the code.
- jonathanhd 8y agoWhitney follows the enlightened solution to the NL=\n|\r\n debate, just don't end your lines ever.
- pushpop 8y agoWhich also solves the tab vs spaces debate.
- seanmcdirmid 8y agoIt is notable that newlines are a relatively new invention anyways in the history of writing. But then again, so is white space.
- faissaloo 8y agoI believe the modern term is 'galaxy brain'
- rmbryan 8y agoThis was helpful to me: https://en.wikipedia.org/wiki/K_(programming_language) https://en.wikipedia.org/wiki/K_(programming_language)
- ptrott2017 8y agoFor those interested but needing a little help deciphering Thomas Lackner has a handy repo: https://github.com/tlack/b-decoded https://github.com/tlack/b-decoded
- egwynn 8y agoWhy does the makefile need to run $(CC) under sudo?
- nemo1618 8y agoWhitney is so fascinating to me. His code is simultaneously awe-inspiring and horrifying. It's like he struck a Faustian bargain to gain programming powers beyond the ken of mere mortals, and is now cursed to write transcendently beautiful code that manifests as unintelligible gibberish to everyone else.
- jonathanhd 8y agoIf you think this is horrifying you should see what people-who-aren't-Whitney write when they're copying his style, or adding to his codebase.
- yiyus 8y agoI think this is one of the reasons he does not release his code. K is such a small language, with a very limited number of primitives, that were chosen for the task they wanted to solve. Every user would want to change that one he never uses for that one he uses the whole time, so we would have lots of k implementations, each of them with its own mesh of spaghetti code and slightly different behaviors. Talking for myself, I would love a FOSS version of k, but I am sure as hell I would patch a couple of things, and I am sure I would write much worse code than Whitney's (in his style or in my style).
- ploxiln 8y agoI think the closest thing is https://github.com/kevinlawler/kona https://github.com/kevinlawler/kona
- sansnomme 8y agoA more up to date version: https://github.com/JohnEarnest/ok https://github.com/JohnEarnest/ok
- 4thaccount 8y agoKevin Lawler and Scott Locklin (posts on here sometimes) tried to make a tsdb similar to kdb+ called kerf I think. I don't think it worked out, but it would've been nice to have a more affordable competitor.
- gricardo99 8y agoThis is from 2015. I really wish something more from Whitney/kparc would materialize. Whitney/kparc previously covered on HN: https://news.ycombinator.com/from?site=kparc.com https://news.ycombinator.com/from?site=kparc.com
- tlack 8y agoHe just released a new product a few weeks ago: http://shakti.com http://shakti.com Downloadable now: https://www.reddit.com/r/apljk/comments/b1l5hi/shakti_trial_via_anaconda/ https://www.reddit.com/r/apljk/comments/b1l5hi/shakti_trial_... Didn't get much attention on HN: https://news.ycombinator.com/item?id=19326007 https://news.ycombinator.com/item?id=19326007
- gricardo99 8y agoI did not know that was his. Thanks for the tip.
- dang 8y agoIt got attention here: https://news.ycombinator.com/item?id=19418570 https://news.ycombinator.com/item?id=19418570.
- stesch 8y agoDoesn't look like B. I'm a bit irritated. https://en.wikipedia.org/wiki/B_(programming_language) https://en.wikipedia.org/wiki/B_(programming_language)
- azhenley 8y agoWell, at least there are comments, right?
- yiyus 8y ago// :+-*% ^&|<=> x64 JJ Jj o2 cc tst RET cll psh pop acdbsbsd89.. o[m[s|d]] c3 eb+1 e8+4 e9+4 [f2/66/4*][0f] 5* 7*+1 b*+4 0f8*+4 03 23 2b 3b (6b 83) 89 8b ..
- yiyus 8y agoI studied this code for a long time. I have lots of notes, going through everything almost line by line. I would be embarrassed of making them public because I never finished (at some point, I was just rewriting the x64 reference), but if somebody is interested I do not mind sharing. I would recommend everyone doing C to have a very careful look at this. The code is full of nice tricks and you start appreciating the terse style after a while. I understand why this style is not more commonly used, but I really like it.
- jdmoreira 8y agoI would love to take a look at your notes. I'm fascinated by this and would greatly appreciate any help approaching it
- yiyus 8y agoHere it is for anyone who wants to have a look: https://docs.google.com/document/d/1W83ME5JecI2hd5hAUqQ1BVF32wtCel8zxb7WPq-D4f8/edit?usp=sharing https://docs.google.com/document/d/1W83ME5JecI2hd5hAUqQ1BVF3... I recommend you to keep the original files at hand for reference. Once you have understood it the first time, they are a better reference than my many pages document. When AW says he hates scrolling, it is not because he is lazy, it just doesn't go well with this style. I am sure there are mistakes. If you find any, please let me know.
- jdmoreira 8y agoThank you! This is awesome
- v_dev 8y agoYou are a hero
- VictorSCushman 8y agoThank you! This is fantastic!
- gnulinux 8y ago
- otikik 8y agoProgramming is not telling the machine what to do. That's the easy part. What programming is about, and what's hard, is telling the next programmer what the machine does. This makes the easy part a bit easier, and the hard part much harder, than using C. And I already disliked C to begin with, for similar reasons.
- quadcore 8y agoNow I think you're right, but there is two strategies which boils down to the following: "you can either make a program that's so complex there is no obvious defect, or you can make a program so simple it's obvious there is no defect." What it says is that the hard part to make the next programmer understand what the machine does is not reading code, it's code complexity. Training yourself to read terse code is O(1), understanding code is at least O(N) where N is the number of lines of code. Before you start arguing, try it. Try writing code as simple and succinct as possible. You won't go back to anything else because it works. It does make programming simpler and more productive.
- theamk 8y agoI did, once, when I was at school. It was great - everything was so fast to type, the program (a somewhat complex game) would fit in on two screens. I almost finished it in a week. And the I had exams, and did not touch the computer for two weeks. When I came back, I forgot it all. Cx? Dzy? Those names were meaningless. This was a very importantly lesson - programs must be maintaineable. Unless you want to spend your entire life working on a single piece of software, you want to be able to context switch, and do it quickly.
- quadcore 8y agoCx? Dzy? Those names were meaningless. A programmer doesn't rely on variable names to understand what the machine does, or very little. The contrary is a myth. In other terms, you always check what a variable contains anyway. That being said, I make a distinction between obfuscated code and less code. The former is about presentation, which in my opinion you're free to decide while the later is about #node in the ast. Sort of.
- 3xblah 8y agohttps://gitlab.com/k7db/k https://gitlab.com/k7db/k Wasn't this public? https://duckduckgo.com/lite/?q=https://gitlab.com/k7db https://duckduckgo.com/lite/?q=https://gitlab.com/k7db Reference: https://cs.nyu.edu/cs/faculty/shasha/papers/tutorial https://cs.nyu.edu/cs/faculty/shasha/papers/tutorial
- fao_ 8y ago404: Not Found
- SifJar 8y agoBinaries can now be obtained from Anaconda: https://anaconda.org/shaktidb/shakti https://anaconda.org/shaktidb/shakti Not sure what was on gitlab, I assume not source?
- 3xblah 8y agoThe install for Anaconda is over 500MB. If it is anything like k, the "shakti" binary is probably small, maybe under 260KB. Is there a way to download just the shakti binary? What are the restrictions on the trial version of shakti? Is it time-limited (e.g., 30 days)? Does it need an internet connection to be able to phone home? (I think FD/Kx started doing this with their 64bit trial.) The backstory for all this is that Whitney sold his remaining interest in Kx around July of last year for around 53 million. Quick US trademark search does not show any filings for a "shakti" mark that covers computer software.
- lelf 8y agoJust download it ‘manually’ https://anaconda.org/shaktidb/shakti/files https://anaconda.org/shaktidb/shakti/files and tar -xf bin/k is 185K
- 3xblah 8y agoThank you! Exactly what I was looking for. Even give us a static binary. Alas, I am getting "Illegal instruction (core dumped)". Will have to try another kernel.
- 5166cc9c39fa61 8y agoI think a good introduction to this style of coding is the first "proof of concept" prototype interpreter for a small subset of J, also written by Whitney: https://code.jsoftware.com/wiki/Essays/Incunabulum https://code.jsoftware.com/wiki/Essays/Incunabulum Once I realized it was K&R C, I thought it was pretty straightforward.
- scottlocklin 8y agoThis is worth a look. Some of the old A+ stuff is as well. I'm told by reliable sources that an awful lot of Art's code looked like this over the years; even the more recent K7 stuff. Art's gonna do his thing. Opinions differ as to whether or not it is a generally good idea, but you can't argue with the results, and at this point I find stuff like the J source code to be fairly readable, even if it is really different from what most people are used to. Basically, you're just expressing C as APL primitives. If you understand APL primitives, it's not so bad. If you want to see APL expressed as C primitives, something like Nial is pretty good: https://github.com/danlm/QNial7 https://github.com/danlm/QNial7
- leni536 8y agoI ran it through gcc -E and clang-format. https://pastebin.com/21qiRDi5 https://pastebin.com/21qiRDi5
- 5166cc9c39fa61 8y agoAnd not surprisingly that makes it less readable. It is a lot harder to have one-character names when you need to scroll across many pages to look up what they mean. So the more code you have, the longer code you need. As Eric Evans points out, naming things in computer code is difficult and important; wrong names can be misleading. This style avoids the problem by avoiding names.
- recursive 8y agoIt says same ops, but it seems some are missing? I see no modulus. Am I reading this right?
- biosed 8y agoDid he ever release K OS? I seen a few bits and pieces from Geocar but never seen a release or download.
- caymanjim 8y agoThis code is a horrid abomination. I don't care if this guy is a genius and could single-handedly write the best OS in the history of computing; his code is write-only, unmaintainable garbage. There's nothing elegant or praiseworthy about this at all.
- ulucs 8y agoIf you don't know the language, of course most things will seem understandable b[Ii]{h:#x;l:0;while(h>l)$[y>x[i:/l+h];l:i+1;h:i];l} b -> function name [Ii] -> type declaration h:#x;l:0; -> initial definitions And the rest of it are bog-standard binary search operations with implicit return of l. Honestly, it's more understandable than Java with annotations or other magic constructs
- caymanjim 8y agoitsnotthatitcantbereadbysomeonewhoknowsthelanguageitsthatitsincrediblydenseandhardtoreadandlacksanymeaningfulcontextclues
- 3xblah 8y agoI actually had no problem reading that! At first glance, it looks unsightly but when one actually starts reading it (all of it, not just looking for "clues"), how it looks makes little difference. These threads that mention k are always entertaining. There is usually some amount of comments like yours. There is this concept called "Tall Poppy Syndrome". I am not sure what we might call this stuff here (it should have name), but we see some of it every time k comes up in a thread on HN. Fortunately we also see people commenting who like APL or at least are curious. Not everyone is trying to cut Arthur Whitney down for being good at what he does.
- yiyus 8y agosentence(lang HumanLanguage){ if(lang!="EN"){ throw_exception(UNKNOWN_LANGUAGE_EXCEPTION); } with subject(combine_adjective_noun("context", "clues")){ verb[to_be::present::plural]"are"([adjective]"overestimated"); } full_stop; } Do you find this more readable than a simple English sentence? AW's code is way too terse, but most code is much more verbose than I'd like it to be. Finding the sweet spot is difficult (and it may change when you are coding just for yourself and when there is a larger audience). In order to find a good compromise, it is always interesting to explore all the possibilities in both directions. We have code with many safety measures, extensive comments and visual clues and we have code like this and, in contradiction with every theory, the terse style is doing quite well in terms of bugs and programmer efficiency. Why? Is that a coincidence? Could we have the best of both worlds? I do not say you should use this style for your projects, you don't even have to like it a little bit, but criticizing it because of its disadvantages without trying to understand its advantages is not a very productive point of view, in my opinion.
- QuentinM 8y agoQ is one most important language here at BitMEX. Complicated or not, it's on KDB that all our trades happen, up to $8B in 24H volume last summer - it's highly efficient at its task, and never made us or any of our customers, loose a single Satoshi.
- abeaulne 8y agoWith all due respect, requests to BitMEX during times of high load have >50% probability of hitting a 503 Service Unavailable error. Meanwhile, competitors with similar volume/activity don't have this problem.
- UncleEntity 8y agoThey've done studies, you know. They say 60% of the time, it works every time.