Live data from Hacker News

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

antirez.com

41–50 of 146 posts

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

#41

> 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…

Gmail's web client also non-optionally auto-wraps text before sending, which is very annoying when you're trying to send a patch or part of a log file.

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

#42
When I started programming, the basic digital world already existed for me. I never had the experience of typing in a program from a magazine. This is one of those odd experiences where you remember that self-hosting[1] can involve far more components than just the compiler, spiraling an unexpectedly deep path into the development stack.

I just used @antirez's 1k LOC kilo editor to edit his 1K LOC editor and it was an oddly pleasurable experience :)

[1]: https://en.wikipedia.org/wiki/Self-hosting

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

#43
post #35

Earlier quoted context omitted.

Yeah but that is so much less usable. Quick, which one is up?

The point is, they are no longer in symbolic memory. At this point they are muscle memory. Quick, which muscle do you use to move your right thumb in? Does it matter?

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.

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

#44
post #18

Earlier 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…

I stole the following from a colleagues `.vimrc` which finally allowed me to learn `hjkl`. Now I forget I have this set, and when I do accidentally use an arrow key it makes me laugh.

    map  :echo 'damnit!'
    map  :echo 'you suck!'
    map  :echo 'this is why you fail'
    map  :echo 'nooooo!'

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

#45
I love seeing little projects like this, and I wish I were better at finding time to do them myself. It’s all too easy when you’ve been programming professionally for a long time, often working on the same projects every day for months or years, to lose that sense of wonder at what we can achieve in a few hours with a modest amount of code. Sometimes it’s good to just sit down for a day or two and hack together a kind of program you’ve never written before, whether that’s a text editor or a puzzle game or rendering a pretty 3D fractal landscape or an IRC chat bot. It’s always nice to see someone else who’s created something that way too, so thanks for sharing.

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

#46
post #38

Earlier quoted context omitted.

I know k is up, because I constantly k in bash, bit the point of using hjkl is exactly not to know which one is what. You set your finger on the keyboard in home position, now your muscle memory does the rest.

> I know k is up, because I constantly k in bash What is ESC-k supposed to do in Bash?

The poster probably changed his bash to use vi editing mode with set -o vi. In this mode, k would put the text of the last command entered back on the prompt.

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

#47

What challenges might you have if you wanted to implement something like this inside a game framework like Unity or MonoGame with C#, where it renders everything via DirectX or OpenGL?

The main challenge is that, even now, in the year 2016, there is no objectively good, fast, reliable way of rendering arbitrary text with formatting in a texture. Hell, even just plain text is kind of a pain in the ass. And yes, I know about signed distance fields.

It's hard enough to just render high quality ASCII text. But when you consider the layout problems if you want to support full unicode, with rtl and combining characters, Indic script, etc it's very difficult.

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

#48

Earlier quoted context omitted.

The main challenge is that, even now, in the year 2016, there is no objectively good, fast, reliable way of rendering arbitrary text with formatting in a texture. Hell, even just plain text is kind of a pain in the ass. And yes, I know about signed distance fields.

The nice thing about a framework like Unity is that they do have a textfield object that behaves a lot like a standard text object in the .NET Framework. It has a lot of shortcomings but rendering the text is the easy part.

Unity only supports Unicode BMP. Unity doesn't support surrogates, RTL rendering/input etc. Rendering the text performantly for none western scripts is definitely not the easy part, especially on mobile (where Unity also fails to behave properly).
Post reply on HN