I really don't understand why more people in this generation don't run their own strip mining operations for processor fabrication anymore. It's incredibly helpful in both understanding just how many man hours go into a single google search as well as teaching one how to get the most performance out of every last electron.
"St Mary's church of the pool of the white hazels near the pool"
But, its also kind of a cheat, since the name was established in order to be the village with the longest name for British railway station. - Some early tourist attraction-thingy. The isle of Anglessey has many natural and cultural sites, that are more interesting than railway station with a really long names though.
This is the second small code snippet I've seen on HN this week that is intentionally unreadable. What is the draw in obfuscating code to make some silly "art"? I'm far less likely to compile and run it when I can't read it.
I would say it is more "craftsmanship" than "art": it is the proof of an ability, not something made to please.
Of course, this is just debatable. But the normal person will not be awed or simply pleased seeing the code. Only a good craftsman will appreciate it, which is its purpose.
If you think this is unreadable you should look at what "normal" APL code looks like. Then consider there are people who work with such code every day, being very productive in it, and to which normally-formatted C would appear excessively verbose. That really changes your perspective...
* The code generates a number of warnings when compiled with '-Wall -Wpedantic'. Look at IOCCC entries; a number of them take pride in having no warnings whatsoever, even with full warnings enabled.
* The code does not include instructions. Even a 12-line 900 character obfuscated program can include basic usage instructions.
* Most importantly, the code does not work. When I compiled it with GCC on Cygwin (gcc -o zolW zolW.c -lncurses), then ran 'touch foo ; ./zolW foo', I almost immediately got a core dump.
So, yes, this is a good first attempt, but I would like to see this get revised. Fix all compile time warnings; make sure it works with both GCC and CLANG. Add test cases. Add documentation.
Shameless plug: Yes, I have made a small, 900 character 12 line program which does not generate compile-time warnings, does not generate core dumps (even going so far as to fix a core dump which only happened after running the code for over an hour and generating 16 gigabytes of data), has a usage manual, has test cases, and even has basic usage information in the code. So I know it can be done. See https://github.com/samboy/rg32hash/blob/master/C/tinyrg32.md and scroll down for the actual obfuscated C code.
Segfault: I know of a segfault when you try to run it on a file with nothing in the first line, which I'm working on. Beyond that, though, I'd have to do some rearchitecturing in order to get the char-count low enough that I'd have space for more documentation.
P.S. there is documentation already. Try ./two_kilo -h or with no args.
On the subject of small code: embedded folk have to do this sort of thing all the time. Put a wifi AP and client on a tiny processor with 1Mb of flash/256K of RAM. Host a web site so the user can configure the device. Contact a cloud server for continuous IoT provisioning. And perform whatever function the device does.
OTOH, the embedded context is kind of special in that you can hyper-optimize for each device, right?
For example: a program that runs on a desktop may have to take into account many edge-cases, but if an embedded device has quirks then they always apply for that device, so you can remove the "non-edge case" code from the binary.
Further: there are 'board support packages' or BSPs that are tailored to the processor, support chips and package that you're coding too. They work exactly for that configuration and no other. It'd be impossible to fit much in there otherwise!
48 comments
[ 2.2 ms ] story [ 103 ms ] threadCurses has huge functionality.
https://github.com/oriansj/stage0/blob/master/stage1/SET.s
"St Mary's church of the pool of the white hazels near the pool"
But, its also kind of a cheat, since the name was established in order to be the village with the longest name for British railway station. - Some early tourist attraction-thingy. The isle of Anglessey has many natural and cultural sites, that are more interesting than railway station with a really long names though.
You might as well ask of painting and drawing artwork what its purpose is.
Of course, this is just debatable. But the normal person will not be awed or simply pleased seeing the code. Only a good craftsman will appreciate it, which is its purpose.
* The code generates a number of warnings when compiled with '-Wall -Wpedantic'. Look at IOCCC entries; a number of them take pride in having no warnings whatsoever, even with full warnings enabled.
* The code does not include instructions. Even a 12-line 900 character obfuscated program can include basic usage instructions.
* Most importantly, the code does not work. When I compiled it with GCC on Cygwin (gcc -o zolW zolW.c -lncurses), then ran 'touch foo ; ./zolW foo', I almost immediately got a core dump.
So, yes, this is a good first attempt, but I would like to see this get revised. Fix all compile time warnings; make sure it works with both GCC and CLANG. Add test cases. Add documentation.
Shameless plug: Yes, I have made a small, 900 character 12 line program which does not generate compile-time warnings, does not generate core dumps (even going so far as to fix a core dump which only happened after running the code for over an hour and generating 16 gigabytes of data), has a usage manual, has test cases, and even has basic usage information in the code. So I know it can be done. See https://github.com/samboy/rg32hash/blob/master/C/tinyrg32.md and scroll down for the actual obfuscated C code.
P.S. there is documentation already. Try ./two_kilo -h or with no args.
For example: a program that runs on a desktop may have to take into account many edge-cases, but if an embedded device has quirks then they always apply for that device, so you can remove the "non-edge case" code from the binary.
https://news.ycombinator.com/item?id=14046446