5 ms·
The code looks heavily obfuscated. It's more like "source available" than open source. E.g. g(_M,W-=1<<f;xx=M[f];M[f]=x)Ui(M_,Ux=M[i];x?(W+=1<<i,M[i]=xx,x):3
by frankjr 2y ago
The code looks heavily obfuscated. It's more like "source available" than open source. E.g.
g(_M,W-=1<<f;xx=M[f];M[f]=x)Ui(M_,Ux=M[i];x?(W+=1<<i,M[i]=xx,x):30>i?_M(i,M_(i+1))+(2*n0<<i):OO())f(_r,pt?x:65535&rx?(--rx,x):e(if(!Tx)n(_r(xU))_M(mx,x-n0);x))f(r_,pt?x:65535&++rx?x:OO())
Edit: Looking at it a bit more, I can't tell if the code is obfuscated or if the author really wrote it like this...
- padthai 2y agoDoes writing in this way has any advantage in practical terms (not aesthetically reasons)?
- IshKebab 2y agoThe only possible advantage I can think of is that you can fit more code on one screen so I guess in theory you can see your context more easily. But that seems pretty minor compared to... well, look at it! I read a couple of other threads and some people try to claim less code = fewer bugs, but that's pretty clearly nonsense otherwise minifiers would magically fix bugs. As for why people actually use this (it seems like they really do), my guess would be that it's used for write-only code, similar to regexes. Like, using a regex you can't deny that you get a lot of power from not many keystrokes, and that's really awesome for stuff you're never going to read again, like searching code in your editor, one throwaway shell commands. But they also tend to be completely unreadable and error prone and are best avoided in production code.
- eigenvalue 2y agoI suppose in our new world of LLMs, using as few tokens as possible means you can cram more in a small context window, which could be helpful in various ways.
- 082349872349872 2y agoMaybe someone could produce an LLM which takes a line of vector language code and expands it into the dozen(s) of lines of equivalent pseudo-algol? (I mean, you could skip the whole hallucination thing and write an exact converter, but that'd be a lot of effort for code that'd probably get used about as much as M-expression to S-expression converters do in the lisp world?)
- eggy 2y agoThere are a few articles of using J or APL for ANNs and CNNs out there. Here's one: https://arxiv.org/pdf/1912.05234
- klibertp 2y ago> But they [regexes] also tend to be completely unreadable Regular expressions can be constructed using various syntaxes. Some are optimized for writing them out quickly, and some are not. Choose the latter when going to production, and you'll be fine. As for K/J/APL - it's similar. You can write incredibly terse code which works wonderfully in a REPL (console). Working in an interactive manner is the default mode of operation for those languages. If you ever worked with Numpy/Pandas or similar, in a REPL, you likely concocted similarly terse monstrosities. Check your %hist the next time you have a chance. Going to production, you naturally rewrite the code instead of just committing the first one-liner that produces the desired results.
- xelxebar 2y agoIt's not that any method of reducing code length fixes bugs, it's just happens that optimizing code to be read and worked on by domain experts leads one toward patterns that secondarily end up manifesting as terse expressions. The terseness is certainly shocking if you're not accustomed to it, but it's really not a terminal goal, just a necessary outcome. The disbelief on first encounter is totally reasonable, but from personal experience, once you've gotten past that and invested the time to really grok the array language paradigms, code like this Whitney style actually ends up feeling more readable than whatever features our current SE culture deems Good and Proper. There are a whole lot of moving parts to the why and how of these ergonomics, so I don't expect to be able to convince anyone in a simple, short comment, but if you're at all interested and able to suspend disbelief a little bit, it's worth watching some of Aaron Hsu's talks to get more of a taste.
- IshKebab 2y agoFrom personal experience with regex, yes the first encounter was shocking, and sure I got past it and now can easily write regexes. But they still aren't more readable than the alternatives. Nor would I encourage their use in production.
- kybernetikos 2y agoI've heard it said that it becomes easy to spot common patterns and structures in this style. Without knowing the idioms it's difficult to read but apparently once you know the idioms, you can scan it and understand it well.
- tluyben2 2y agoIt is for APL/k/j; you see patterns popping up in very dense code which does a lot, which does make it readable really once used to it. But most people never get to that point (or even ever look at APL of course).
- koolala 2y agoimaginary numbers in programming languages is the pattern once common we need to see pop up, J and APL got them for sure
- orthoxerox 2y agoThat's just how Arthur Whitney writes code.
- cloudbonsai 2y agoYou may not believe it, but that's how K/Q/J people write C code. Bonus: Go visit and do "View Source" on that website. Even HTML has fragrance of K.
- frankjr 2y agoI don't understand how. How do you debug something this? How do you go about fixing a bug? There are no docs nor tests. It seems like one would spend hours just trying to understand what's going on. Is there a good source on their methodology? Because my mind is blown.
- cenamus 2y agoI recommend checking out more of the APL family language family and the history of the notation, highly interesting. Almost like a parallel universe of computing, when you look past the syntax.
- sph 2y agoYes, but C isn't APL. I don't buy it that this how it was written from day 1. Occam's razor and all, this is obfuscated C, not code written by an alien superintelligence.
- fragmede 2y agohaven't you ever written code with single letter variable names and it makes sense to you? and then been forced to read somebody else's code with single character variable names and found it completely inscrutable? this is just that on (a lot of) steroids
- sph 2y agoNo I don't write entire C programs with single letter variables, because there is no way where "c" is more readable than "cnt" or "count". With the usual exception of "for(int i", x, and y variable inside small scopes. If I was paid by the hour to write C, then I'd use single letter variables too, but I'm too lazy to do twice the work, when I can make my life simpler. Simplicity is a virtue, there is nothing interesting about complexity for complexity's sake. In the words of Terry Davis: https://youtu.be/k0qmkQGqpM8?si=larQzV0Ngdba6vQI https://youtu.be/k0qmkQGqpM8?si=larQzV0Ngdba6vQI
- deleted 2y ago[deleted]
- t-3 2y agoThat's the "Whitney style". See: https://code.jsoftware.com/wiki/Essays/Incunabulum https://code.jsoftware.com/wiki/Essays/Incunabulum It's writing C in array-language style rather than intentional obfuscation.
- frankjr 2y agoThanks. I'm now reading this where people are trying to explain what happened in the ref/ directory. https://github.com/kparc/ksimple/blob/main/a.c https://github.com/kparc/ksimple/blob/main/a.c
- dcuthbertson 2y agoThanks for that link. The comments there help a lot. If I understand them, this is a minimal implementation of K with a lot of limitations, such as: "the only supported atom/vector type is 8bit integer, so beware of overflows" Still, it's fascinating how an interpreter can be written with such a small amount of code.
- tromp 2y agoAn interpreter for BLC, including tokenizing, parsing, and evaluation, can be written in as few as 29 bytes of BLC (and 650 bytes of C).