Daily Shaarli
December 28, 2023
All look like interesting concepts to toy with!
- Text editor
- 2D game - Space Invaders
- Compiler - Tiny BASIC
- Mini operating system
- Spreadsheet (hard!)
- Video game console emulator (hard!)
- Ray tracer
- Key-value store web API
- Web browser
- Stock trading bot
Also see Challenging algorithms and data structures every programmer should try.
This article talked about three data structures for efficient text editing (a.k.a. text buffer data structure): Rope, Gap Buffer, and Piece Table. It's first time I learned about Piece Table, it works like this:
- Store the text in an append-only fashion in two buffers known as original file and add file
- Store the information about segments of the files as a list of reference to the slices into the two buffers (known as "piece table")
The inserting/deleting in this data structure would simply need to breaking up items in the piece table. It seems like a good candidate as a basis to implement CRDT in a collaborative editor.
From my preliminary understanding of the nature of this data structure, it doesn't seem necessary to have two buffers, a single append-only buffer preloaded with the file should be sufficient.
UPDATE: I found this post on vscode blog extremely helpful: https://code.visualstudio.com/blogs/2018/03/23/text-buffer-reimplementation