8 ms·
Show HN: Two Kilo – A curses-based text editor in 2kb of code
- AstralStorm 8y agoEh? Count the deps in, then brag about code size. Curses has huge functionality.
- dbdjfjrjvebd 8y agoBut someone else has already tested that code.
- jacobush 8y agoAye, in my day we had to smelt the ore first, but before we could do that we had to ... (drifts off)
- joaomacp 8y agoIn my day we had to invent tools first, but before we could do that we had to evolve from unicellular microbes.
- philippeback 8y agoshaders?
- boomlinde 8y agoWhat is a good place to draw the line? Kernel? BIOS? Microcode? Hardware?
- z29LiTp5qUC30n 8y agoI say hardware and that 1072 bytes beats the shit out of that: https://github.com/oriansj/stage0/blob/master/stage1/SET.s https://github.com/oriansj/stage0/blob/master/stage1/SET.s
- jcelerier 8y agopfft, you aren't counting the megabytes of intel microcode that emulate this
- morgancmartin 8y agoI 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.
- AstralStorm 8y agoI'm even fine with OpenGL if the functionality is impressive. (Generated textures, models, great visuals etc.) A text noneditor is not.
- chrismaltby 8y ago"If you wish to make an apple pie from scratch, you must first invent the universe" - Carl Sagan
- cuddlecake 8y agoOff Topic: Google translate thinks it's Welsh.
- maze-le 8y agoProbably has a small-enough document distance to famous welsh names like: llanfairpwllgwyngyllgogerychwyrndrobwlll
- ltc5505 8y agoIs that an actual Welsh name or did you just jam your knuckles into the keyboard?
- system2 8y agoLlanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch is also a "real" word in Welsh.
- Topgamer7 8y agoThere is a youtube video out there with locals pronouncing it :D
- maze-le 8y agoThats actually the name of a village: https://en.wikipedia.org/wiki/Llanfairpwllgwyngyll https://en.wikipedia.org/wiki/Llanfairpwllgwyngyll "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.
- deleted 8y ago[deleted]
- StreakyCobra 8y agoTo compile: gcc -o zolW zolW.c -lncurses
- saagarjha 8y agoThis crashes almost immediately on my machine :(
- deleted 8y ago[deleted]
- fit2rule 8y agoDid you give it a file to edit on the cmd line?
- saagarjha 8y agoYup.
- lelf 8y agoThe same. It does strlen(0) somewhere $ dtrace -n 'pid$target::strlen:entry { print(arg0) }' -c './a.out 2' CPU ID FUNCTION:NAME ⋮ 4 22139 strlen:entry int64_t 0
- earenndil 8y agoIt requires a file with a nonblank first line. I'm working on that...
- caymanjim 8y agoThis 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.
- chrismorgan 8y agoIt’s art. You might as well ask of painting and drawing artwork what its purpose is.
- pfortuny 8y agoI 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.
- nurettin 8y agoI can clearly read it on my phone. Says "TWO KİLO".
- subfay 8y agoAgree. It's not art but an unfounded fear that one might steal/fork the source and get more credits.
- userbinator 8y ago
- EdSchouten 8y agoGood submission for http://ioccc.org http://ioccc.org ?
- drosan 8y agoReally buggy sadly
- earenndil 8y agoIt needs to be run on a file with a nonblank first line (which I'm working on), are there other bugs you've noticed?
- strenholme 8y agoIt 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.
- deleted 8y ago[deleted]
- earenndil 8y agoSegfault: 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 8y agoWhere 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 8y agoOn 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 8y agoOTOH, 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 8y agoFurther: 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!
- qntty 8y agoFor 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 8y agoNope, I was more inspired by the challenge to make a videogame that could fit on a business card.
- quickthrower2 8y agoI don’t get it it’s telling me to F off. Maybe HN is sending too much traffic, but this seems rude.