
Show HN: Two Kilo – A curses-based text editor in 2kb of code - earenndil
https://0x0.st/zolW.txt
======
strenholme
It has some promise, however:

* 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](https://github.com/samboy/rg32hash/blob/master/C/tinyrg32.md)
and scroll down for the actual obfuscated C code.

~~~
earenndil
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.

~~~
strenholme
Where is the manual for this program? Every IOCCC winner has a "hint" file
which explains what the program does and how to run it.

------
JoeAltmaier
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.

~~~
vanderZwan
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.

~~~
JoeAltmaier
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!

------
cuddlecake
Off Topic: Google translate thinks it's Welsh.

~~~
maze-le
Probably has a small-enough document distance to famous welsh names like:
llanfairpwllgwyngyllgogerychwyrndrobwlll

~~~
ltc5505
Is that an actual Welsh name or did you just jam your knuckles into the
keyboard?

~~~
system2
Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch is also a "real"
word in Welsh.

~~~
Topgamer7
There is a youtube video out there with locals pronouncing it :D

------
EdSchouten
Good submission for [http://ioccc.org](http://ioccc.org) ?

------
StreakyCobra
To compile: gcc -o zolW zolW.c -lncurses

------
qntty
For those who missed it, I assume this was somewhat inspired by this project,
which is building a small text editor without curses.

[https://news.ycombinator.com/item?id=14046446](https://news.ycombinator.com/item?id=14046446)

~~~
earenndil
Nope, I was more inspired by the challenge to make a videogame that could fit
on a business card.

------
saagarjha
This crashes almost immediately on my machine :(

~~~
fit2rule
Did you give it a file to edit on the cmd line?

~~~
saagarjha
Yup.

------
quickthrower2
I don’t get it it’s telling me to F off. Maybe HN is sending too much traffic,
but this seems rude.

------
caymanjim
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.

~~~
subfay
Agree. It's not art but an unfounded fear that one might steal/fork the source
and get more credits.

~~~
boomlinde
I disagree that this is a likely reason. There's nothing novel about the
implementation except the size of the source code.

------
drosan
Really buggy sadly

~~~
earenndil
It needs to be run on a file with a nonblank first line (which I'm working
on), are there other bugs you've noticed?

