Skip to content
HomeVideosBooksBlogs
AllTop postsTopics
Podcasts
HistoryListsWatch laterLiked videosFollowing

The videos, books, blogs and podcasts Hacker News keeps recommending, all in one place.

VideosBooksBlogsPodcastsAboutPrivacySettings

Data from Hacker News, HackerTube, HackerBooks, HackerBlogs and Open Library. Credits · Not affiliated with Y Combinator.

HomeVideosBooksBlogsPodcasts
Ctrl K
    C

    Catch22

    catch22.net · Personal blog · on HN since 2013

    Tutorials on Windows programming, including a Win32 text editor series, piece chain data structures, device drivers and small utilities.

    Visit blogRSSHN submissions
    ProgrammingSystems & Performance
    What HN says

    HN commenters recommend its Neatpad and piece chain tutorials as a good way to learn text editor internals, including undo and redo.

    Stats for nerds
    17HN people shared it
    7linked in comments
    190story points
    Dec 2023last shared
    2016people per year2023

    Top posts on HN

    1. 1
      Design and Implementation of a Win32 Text Editor (2005)
      7 people · 177 points · first shared 2013 · 51 comments on HN
    2. 2
      Piece Chains (2006)
      2 people · 7 points · first shared 2023 · 1 comments on HN
    3. 3
      WinSpy – Select and view the properties of any window in the system
      1 person · 3 points · first shared 2021 · Discussion on HN
    4. 4
      Piece Chain Implementation
      6 people · 2 points · first shared 2016 · Discussion on HN
    5. 5
      Introduction to Windows NT Device Drivers
      1 person · 1 points · first shared 2013 · Discussion on HN
    6. 6
      Hexedit
      1 person · first shared 2016

    What HN people wrote when they linked it

    • deathanatosOct 2017

      > Furthermore in ropes every leaf spans one character,

      The Boehm paper on ropes[1] (which is about the only academic literature on the subject that I know of) does not do that (and explicitly suggests one should not), nor does any real-world implementation, (e.g., the Boehm implementation, SGI's impl) do that. It would be incredibly inefficient, and for no real gain.

      A good rope implementation will store an array of characters/bytes in the leaves, up to some threshold.

      > Furthermore with ropes, every operation returns a new rope data structure, that means ropes are immutable.

      There is nothing inherently immutable about ropes, and it is certainly possible to mutate a rope. (For example, appending a single character to a leaf with space is much quicker if the rope as a whole is mutable.)

      Look at the SGI implementation for an example here; their reference docs[2] contain sufficient details to see that the rope itself is mutable.

      Now, a rope typically just describes a sequence of characters. It is entirely possible for a leaf node in a specialized rope to reference on-disk content, and other leaves to reference in-memory content. In that regards, it can be like a piece table. Implementing an undo/redo on top of a rope is less straight-forward; whereas a piece table's undo history can essentially share large portions of the linked list (see the lovely diagrams here[3]) I'm not sure the same can be done on a Rope's tree, due to the tree's need to balance and re-balance. That…

    • ttdOct 2017

      I think implementing a simple text editor with undo/redo support is a worthwhile exercise for everyone to do at least once in their career. It's a great example of something that on first glance seems simple, but has quite a bit of subtlety especially when you get into styled text.

      Piece chains are another good data structure to know for this application, though their implementation is more complex than a gap buffer. See http://www.catch22.net/tuts/piece-chains for a nice tutorial.

      Also worth reading for insight and motivation is the 1985 CACM article "Concepts of the text editor Lara" by J. Gutknecht.

    • akavelMar 2016

      The article is missing one of the important but commonly overlooked structures: a "piece chain" [1] (aka "piece table"). Not easy to find editors using it, especially among the popular ones, but:

      - from what I've read somewhere, MS Word was/is (?) using it internally [http://1017.songtrellisopml.com/whatsBeenWroughtUsingPieceTables, ]

      - AbiWord [1]

      - [1]: http://www.catch22.net/tuts/piece-chains

      - https://github.com/martanne/vis

      - the text editor of the Oberon OS used it [1]

      One of its most intevesting advantages is that it trivially supports fast unlimited and persistent undo/redo

    • swahOct 2016

      I really enjoyed typing along with this 3-part series: https://www.youtube.com/watch?v=oDv6DfQxhtQ
      Per writes the beginnings of an emacs-inspired Windows (directwrite) text editor.

      I want to continue developing it, but have no idea what to do regarding design... I'm considering using Sublime's themes.

      Another interesting tutorial: http://www.catch22.net/tuts/neatpad

    • benj111Dec 2023

      I'm surprised there isn't much discussion of data structures here, as that would inform an undo algorithm.

      I infer from 'PieceTree'

      That this is a binary tree based piece chain.

      That makes undo really easy, especially character by character.

      Nice explantation of piece chains

      https://www.catch22.net/tuts/neatpad/piece-chains/

    • swatkatDec 2016

      Sysinternals has a Windows equivalent[1]. Although most of the hex editors[2][3] have an in-built strings dumping functionality.

      [1] https://technet.microsoft.com/en-us/sysinternals/strings.aspx

      [2] https://www.safer-networking.org/products/filealyzer/

      [3] http://www.catch22.net/software/hexedit

    Related

    Beejbeej.us233 people

    Beej's Guide to Git

    Beej
    Personal · last shared 2026
    Arm Community Blogcommunity.arm.com147 people

    An update on GNU performance

    Arm Community Blog
    Company · last shared 2025
    Lambda the Ultimatelambda-the-ultimate.org615 people

    Simon Peyton Jones Elected into the Royal Society Fellowship

    Lambda the Ultimate
    Publication · last shared 2026
    Chris Wellonsnullprogram.com295 people

    Why Aren't There C Conferences?

    Chris Wellons
    Personal · last shared 2026
    Our Machineryourmachinery.com36 people

    Virtual Memory Tricks

    Our Machinery
    Company · last shared 2022
    Dev Geniusmedium.com/dev-genius36 people

    A principled approach to GraphQL query cost analysis

    Dev Genius
    Publication · last shared 2026
    Not a Monad Tutorialnotamonadtutorial.com40 people

    Weld: Accelerating numpy, scikit and pandas as much as 100x with Rust and LLVM

    Not a Monad Tutorial
    Publication · last shared 2023
    Simon Willison's TILstil.simonwillison.net111 people

    One-liner for running queries against CSV files with SQLite

    Simon Willison's TILs
    Personal · last shared 2026