Live data from Hacker News

Writing an editor in less than 1000 lines of code, just for fun

antirez.com

141–146 of 146 posts

Re: Writing an editor in less than 1000 lines of code, just for fun

#142
post #116

Earlier quoted context omitted.

> Really? Is it lame to be using an email clients these days? I think he means that wether nano is derived from an email client or not is not important

You might be right; I may have misinterpreted. He might be saying, "The notion of email client itself is gone from Nano at this point, everything changed about Nano ".

For what is is worth, I read it in the same way as you. And found it kind of an odd statement, for a guy who has a website with a monospaced font...

Re: Writing an editor in less than 1000 lines of code, just for fun

#143

Earlier quoted context omitted.

While you're correct that it's a state diagram processing HTTP semantics and not parsing; parsing a text-based protocol is far from trivial. In fact, the HTTP2 FAQ explicitly mentions [1] that reducing parsing complexity was a motivation for going binary with HTTP2. [1] https://http2.github.io/faq/#why-is-http2-binary

I've done perfectly adequate HTTP parsing with this Python 4-liner: headerText, body = text.split('\r\n\r\n', 1) headerLines = headerText.split('\r\n') method, path, protocol = headerLines[1].split(' ') headers = dict(line.split(':').map(str.strip) for line in lines[1:]) For production use you'd probably want something a bit faster & more robust like Mongrel's HTTP parser (itself only 166 lines of Ragel), which power…

That's a perfectly adequate 4-line HTTP/1.0 parser :) But for HTTP/1.1, which must support chunked transfer coding [1], this won't work.

[1] https://tools.ietf.org/html/rfc7230#section-4.1

Re: Writing an editor in less than 1000 lines of code, just for fun

#144

Earlier quoted context omitted.

Yes, thanks for pointing that out. I'm more interested in total time. Not time to write. :)

Hello! It was a few hours (probably 6-8) across a total of two weekends (so a total span of 9 days where I did 2 "days" of work, 5 days of pause, 2 days of work).

Thanks for answering.

Re: Writing an editor in less than 1000 lines of code, just for fun

#145

@Antirez please please please let this thing have a future: there is a great need for a modern, simple and usabile CLI editor.

Neovim https://neovim.io/ is a modern, simple, usable, and powerful CLI editor.

anyone who thinks vim isn't simple just hasn't had a good instructor / tutorial.

Re: Writing an editor in less than 1000 lines of code, just for fun

#146
post #83

Earlier quoted context omitted.

If you create a screencast I assume you give it your best. Look at the typing skills demonstrated in the screencast accompanying this project, https://asciinema.org/a/90r2i9bq8po03nazhqtsifksb Judging from the screencast he use around 10 seconds per line. That would be, (10s * 1000 loc)/3600 = 2.7 hours just to type 1000 lines of code. Programming is of course not typing, but a mental activity first and foremost. Let…

> Of course it will take a few days to create a 1000 line C program that does anything useful. You'd be surprised. Especially if you have done C for 1 or 2 decades, you can write 1000 lines in 5-6 hours easily, even without thinking, especially since those lines are for a very specific, and not surprising domain and functionality. It's not like you need novel thinking or to solve some unique challenges to build a tex…

Leaving it here for context:

"In Oct. of 1978, a month after introduction, Barnaby began coding Wordstar with new features. According to Rubenstein, who carefully tracked Barnaby’s work, it took four months to code Wordstar. This was done in assembler from scratch. Only 10-percent of Wordmaster code was used. That was the text buffering algorithms. In four months Barnaby wrote 137,000 lines of bullet-proof assembly language code. Rubenstein later checked with some friends from IBM who calculated Barnaby’s output as 42-man years."

Post reply on HN