Off topic, but my biggest takeaway was that I could aspire to be someone who isn't a twenty something, with a family, with superb work life balance, not living in the valley, sitting in a garden without three 27 inch monitors, not using the latest programming language or fad and still writing beautiful code that a lot of the world runs on.
Writing an editor in less than 1000 lines of code, just for fun
111–120 of 146 posts
Re: Writing an editor in less than 1000 lines of code, just for fun
#112Earlier quoted context omitted.
FastCGI/SCGI were obsoleted by having app servers simply speak HTTP; the web gateway just needs to function as a simple reverse proxy. HTTP is about as simple as it gets to parse - you can write a passable (not quite production quality, but works) parser in about 10 minutes. A lot of the difficulty in webapps is because every webapp is inherently a distributed system, which are always hard. Single-page apps with no c…
Speaking HTTP is worse in almost every way to using CGI: harder to implement, loses meta information (suppose you put an application at /app/ on your server... CGI handles it well, HTTP doesn't unless you do some extension since your server will see GET / anyway) and is harder to centrally log too. I think app servers speak HTTP more because it is kinda convenient for developers to run the local server without settin…
Re: Writing an editor in less than 1000 lines of code, just for fun
#113Earlier quoted context omitted.
He mentioned using cloc to get that metric, so not including comments, formatting, etc.
I think you missed the point: the point is that the correct English usage is "fewer than" when discussing quantifiable items (e.g., lines of code). The title should be "...an editor in fewer than 1000 lines of code."
Lines of code is surely a measurement, which makes the use of 'less' here acceptable.
Re: Writing an editor in less than 1000 lines of code, just for fun
#114Earlier quoted context omitted.
Yeah but that is so much less usable. Quick, which one is up?
I use hjkl consistently in vim and in the shell. Just think about how long it takes you to move your fingers to the cursor keys. You should spend some effort getting used to it, as using hjkl means you can keep your hands in the middle of the keyboard. I have also never had any problems with strain, and I suspect this is part of the reason.
Re: Writing an editor in less than 1000 lines of code, just for fun
#115Earlier quoted context omitted.
That's the state diagram for processing the full complement of HTTP requests. Nothing to do with parsing. The parsing bit is trivial.
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
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 powers several million websites out there:https://github.com/mongrel/mongrel/blob/master/ext/http11/ht...
Re: Writing an editor in less than 1000 lines of code, just for fun
#116> Let’s say this again, “email client”. The notion of email client itself is gone at this point. Really? Is it lame to be using an email clients these days? I still use an email client (Thunderbird) because I can't stand the thought of all my mail sitting forever on Goggle's or whoever's servers. Yes, I know that they could have secretly archived all of my email the moment it was sent or received, and that my privacy…
I think he means that wether nano is derived from an email client or not is not important
Re: Writing an editor in less than 1000 lines of code, just for fun
#117Earlier quoted context omitted.
Yeah but that is so much less usable. Quick, which one is up?
Just look at your keyboard :-) ( https://en.m.wikipedia.org/wiki/ADM-3A#Legacy ) I always try to remember them by noting that the leftmost key moves left, the rightmost key moves right (not too hard), and that 'K climbs' (using alliteration to remember that). That leaves 'J' for cursor down. In practice, though, I use the cursor keys. Luckily, they work on the editors/systems I work on nowadays. Side effect is that I…
Lower-case 'k' has an ascender, lower-case 'j' has a descender.
https://en.wikipedia.org/wiki/Ascender_(typography) https://en.wikipedia.org/wiki/Descender
Re: Writing an editor in less than 1000 lines of code, just for fun
#118Earlier quoted context omitted.
Exactly: muscle memory. In your car, do you move the turn signal lever up or down to indicate a right turn? It actually takes longer to answer this question than to do the action in real life. Another example: There are several passwords that I can type instantly, but I wouldn't be able to recite them.
> In your car, do you move the turn signal lever up or down to indicate a right turn? You rotate it the same direction you're about to rotate the wheel. The vi navigation keys have no such convenient correspondence.
Re: Writing an editor in less than 1000 lines of code, just for fun
#119Earlier quoted context omitted.
I use hjkl consistently in vim and in the shell. Just think about how long it takes you to move your fingers to the cursor keys. You should spend some effort getting used to it, as using hjkl means you can keep your hands in the middle of the keyboard. I have also never had any problems with strain, and I suspect this is part of the reason.
How do you use them in the shell?
set -o vi # bash
bindkey -v # zsh
set editing-mode vi # ~/.inputrc i.e readline