On the subleq VM, it would run faster if they implemented Muxleq, but it woudn't win the IOCCC contest maybe. Altough in unobfuscated it's C it's just an extra short if clause with two more lines.
> Nixie tube is a tiny electrical tube with filaments in the shapes of all the digits stacked one on top of another, and it displays the desired digit by making just that filament glow
Lol, no. That's a Numitron (although they were 7 segment)
I wonder at what level you could enforce/how far you could take the idea of "don't allow invalid states to be represented" to a programming language, to prevent this kind of language debauchery.
C does seem to sit at the perfect intersection of language age and low-level access to allow this kind of competition, whereas something like Go seems far less suited for it. Javascript is routinely obfuscated pretty well for human readers. I'm not familiar enough with Rust to say, but I bet with what little I know of its syntax you could create some pretty ugly stuff?
I used to write obfuscated C for fun. I haven’t touched it in a while, but as I recall there are really two C syntax features that unlock most of the “magic”. Whitespace is generally not significant, so you can cram a whole lot onto a single line. And the combination of pointers and weak typing lets you be as anarchist as you like about manipulating data. (Oh, and the preprocessor. The one and - thankfully - only C preprocessor.)
Of the two^H^Hhree, I think that the first is what contributes most to the aesthetic appeal of obfuscated C. The only other languages I’ve used that are as good for making code that looks impenetrable are Forth and JavaScript, both of which share that feature.
(Probably any lisp, too, but for some reason I’ve never actually tried. I can say, though, that the most confusing codebase I ever inherited was written in Clojure.)
So yes, I’m inclined to agree that Rust can be a good language for writing deliberately ugly code, and Go not so much. But for a different, perhaps more trivial reason.
> at what level you could enforce/how far you could take the idea of "don't allow invalid states to be represented" to a programming language
Standard ML, Haskell, and Lisp, among other languages are pretty serious about invalid states. One should never be able to break the virtual machine and put it into an unknown state, unless intentionally mucking around with unsafe {} or its equivalent. Rust is often described as being at least partly in the ML family because of its approach to types and safety, which is very ML-ish.
Dependent typing like in Rocq goes even further, and makes it impossible to express invalid algorithms. Expressing practical programs in formal terms like that is rather hard though. It largely goes over my head, for sure.
Typechecking is more less picking a decidable set of invalid programs and making an efficient checker for them. As for ruling out programming styles, a language is, after all, Turing complete, so one could write an IR and an interpreter and then encode the rest of the program in the IR...
Personally, while I see the social advantages of having all code in one language be similarly structured and use the same idioms, I think a language is meant to be used, and it should offer all the building blocks for writing programs in whatever is the most natural way.
TL;DR: the one entry implemented a subleq machine. Google it - it’s a One Instruction Set Computer (OISC). This made me smile. But it also raised a question: when were OISC’s first conceived? Would Apollo and computers of that era have benefitted from this insight?
I've found an OISC that is surprisingly efficient.
four operands: A B D N
D = A - B. If zero or negative then jump to N else PC++.
Various configurations of this give one instruction for: move, subtract, branch equal, jump, inc, dec and most key: branch and link return address. Two instruction sequences synthesize: add, push, pop. And self-modifying code two instruction sequences for: load, store, call, return from call.
With a bunch of macros you get a reasonable instruction set.
Self-modifying code is terrible from an implementer's perspective once you want to go pipelined and have caches involved. And the instruction set lacks any way to rotate right or operate bitwise. So that involves an expensive loop over the width of the word. Otherwise quite practical.
The AI slop Lisp interpreter weighed in at about 40 kilowords.
16 comments
[ 4.4 ms ] story [ 31.7 ms ] threadOn 32k roms for the GB emulator:
https://github.com/tbsp/Adjustris
Old build:
https://pdroms.de/?__df=24010f101611170c163a13544b55553a4d22...
Someone ping back the IOCCC creator, please.
Lol, no. That's a Numitron (although they were 7 segment)
C does seem to sit at the perfect intersection of language age and low-level access to allow this kind of competition, whereas something like Go seems far less suited for it. Javascript is routinely obfuscated pretty well for human readers. I'm not familiar enough with Rust to say, but I bet with what little I know of its syntax you could create some pretty ugly stuff?
Zig could probably support a similar contest as it grows up.
Of the two^H^Hhree, I think that the first is what contributes most to the aesthetic appeal of obfuscated C. The only other languages I’ve used that are as good for making code that looks impenetrable are Forth and JavaScript, both of which share that feature.
(Probably any lisp, too, but for some reason I’ve never actually tried. I can say, though, that the most confusing codebase I ever inherited was written in Clojure.)
So yes, I’m inclined to agree that Rust can be a good language for writing deliberately ugly code, and Go not so much. But for a different, perhaps more trivial reason.
If any you can do the same weird tricks as obfuscated C but with 100% clean code.
Standard ML, Haskell, and Lisp, among other languages are pretty serious about invalid states. One should never be able to break the virtual machine and put it into an unknown state, unless intentionally mucking around with unsafe {} or its equivalent. Rust is often described as being at least partly in the ML family because of its approach to types and safety, which is very ML-ish.
Dependent typing like in Rocq goes even further, and makes it impossible to express invalid algorithms. Expressing practical programs in formal terms like that is rather hard though. It largely goes over my head, for sure.
Personally, while I see the social advantages of having all code in one language be similarly structured and use the same idioms, I think a language is meant to be used, and it should offer all the building blocks for writing programs in whatever is the most natural way.
four operands: A B D N
D = A - B. If zero or negative then jump to N else PC++.
Various configurations of this give one instruction for: move, subtract, branch equal, jump, inc, dec and most key: branch and link return address. Two instruction sequences synthesize: add, push, pop. And self-modifying code two instruction sequences for: load, store, call, return from call.
With a bunch of macros you get a reasonable instruction set.
Self-modifying code is terrible from an implementer's perspective once you want to go pipelined and have caches involved. And the instruction set lacks any way to rotate right or operate bitwise. So that involves an expensive loop over the width of the word. Otherwise quite practical.
The AI slop Lisp interpreter weighed in at about 40 kilowords.
https://github.com/retrac0/ulqasm/blob/main/demos/13_protoli...