https://louissven.xyz/article/how_I_do_container_types_in_C....
Feel free to flag/delete if this isn't the place.
77 karma · joined July 19, 2021
https://louissven.xyz/article/how_I_do_container_types_in_C....
Feel free to flag/delete if this isn't the place.
He told me he found AI to make him really productive and said something along the lines of: "It's really good at summarizing long reports and it saves me time when I have to write end of quarter status updates".
I'm convinced about 50% of management decisions come from Claude now.
Same for font rendering, there is a reason why harfbuzz is used everywhere. Getting an 80% working renderer is easy but the remaining 20% can take years.
It really "handling text correctly"should be a masters, and I'd sign up in a heartbeat.
struct Vec {
void *data;
size_t len;
size_t cap;
size_t sizeof_ty;
}
I then use a macro to define a new type IntVec {
struct Vec inner;
int ty[0];
}
Using the zero sized filed I can do typeof(*ty) to get some type safety back.All of the methods are implemented on the base Vec type and have a small wrapper which casts/assets the type of the things you are trying to push.
A truly robust C program will generally be much larger than the equivalent Rust program.
Regex searches and code highlight might introduce some hitches due to all of the seeking.
The core data structure (array of lines) just isn't that well suited to more complex operations.
Anyway here's what I built: https://github.com/lorlouis/cedit
If I were to do it again I'd use a piece table[1]. The VS code folks wrote a fantastic blog post about it some time ago[2].
[1] https://en.m.wikipedia.org/wiki/Piece_table [2] https://code.visualstudio.com/blogs/2018/03/23/text-buffer-r...
It also makes way more sense.
It blows my mind that when right-clicking on a file in file explorer, the 'delete' option is hidden in a sub-menu under 'more options'.
And yeah it seems to be missing a few connections but the ones that are there are correct line.h depends on str.h which links str.c which depends on xmalloc.c/h.
But had I been a new contributor to the project I would have found the missing links between modules pretty frustrating.
My guess is that the graph is only good enough to give and overview of what things are dependent on what if I were working on a monorepo and I had to justify to my manager that team B needs to do something for us.
I like the idea though, a lot of direct code to graph tools are too noisy and that tends scares non technical people away.
Might be a bug, so here's the repo. https://github.com/lorlouis/cedit
We ended up not using it in production because the worst cases were absolutely terrible compared to our dumber skippable zstd.
<https://cedardb.com/blog/german_strings/>
You could probably write a C++ implementation based on the article.
Note that it's not all that useful if you don't plan on searching for text based on their prefix. From my understanding, this is mostly a better way to store SStables in RAM/partially on disk if you mmap.
Very interesting blog post about graphemes that parallels my experience writing a terminal text editor: https://mitchellh.com/writing/grapheme-clusters-in-terminals
* Event that is not a proper description of a grapheme
And don't even get me started on regexes
> not updated since 2021