Show HN: Two Kilo – A curses-based text editor in 2kb of code
0x0.st
0x0.st
* 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.
"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.
$ dtrace -n 'pid$target::strlen:entry { print(arg0) }' -c './a.out 2'
CPU ID FUNCTION:NAME
⋮
4 22139 strlen:entry int64_t 0You 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.