I made a string library from scratch in C.
@valigo14K followers
23,836 views
33 Comments
Comments from the original post on X (Twitter)

@platoff
Вы молодец! Но интересно не это, а то что такой контент в текущее время безусловно для многих интересен, а для кого то вообще экзотика, хотя должно быть наоборот. Контент в котором детей учат считать и рассказывают про «счетные палочки» должен быть на детских каналах, а до взрослых каналов текущая «индустрия» вообще не доросла Вернее так: индустрия уже деградировала до того что смотреть про «счетные палочки» интересно и что-то «новое», дальше двинут совсем в идиотов которые даже на пальцах считать не умеют
12 likes

@valigo
Ну в целом да, это прям основа-основ, но очень много людей её скипают и кидаются сразу формошлёпить. Потом их заменяют ИИшкой, и некоторые, поняв, что произошло, возвращаются к основам. И тут появляюсь я )))
7 likes

@platoff
Да, я и говорю что ты молодец. Чего не могу сказать про «многих» 🙂
3 likes

@WilliamSchaub8
I also believe Pascal got strings correct vs the null terminated nonsense. (it stores the length first and then the string follows)
3 likes

@OmittedVerstand
A trick I also love is xor a ASCII character with space to make it from upper to lower or lower to upper case.
3 likes

@meowthsli
У redis толковая реализация строк в составе, sds, пожалуй, одна из лучших. В любом случае, строки и без сборщика мусора это всегда больно
3 likes

@valigo
Да не, с аренками и стрингбилдерами норм

@nao_mx_nao_20
Yay ill have what to watch during lunch now
2 likes

@entropyreducers
very pascal coded imo
2 likes

@Kknewkles
One time I needed to write a metaprogramming utility(we might've discussed this IRL :D) and at first I thought I'd write the v0 in Python, but then it occurred to me to just clone the exact usage I would want from Python -- and to my surprise, all I needed were 3 functions.
2 likes

@CaptAmericaTx
Very nice, especially the int64_t size. In java (even 64 bit java) the native max string size is hold on a signed int32, meaning java code is stuck with max 2Gb strings, which is tiny for 2026 data needs. Your C code could inspire some Java folks to develop a big string library.
1 like

@mdsiaofficial
Nice
1 like

@VicThorDev6
I started with Tsoding's view library about a year ago and added some utilities for parsing and it's been pretty great (I only wish there was something similar in stdlibc)
1 like

@valigo
I knew that Tsoding has his own string view library, but I intentionally avoided it so I don't spoil the implementation, which is the most fun part for me in this whole side quest :)
3 likes

@TheBalkanHacker
What do you think number of string libraries in C is out there in total... back in the "prime" years of C, it seem like every one wrote their own personal stdlib extension lib. that they used for their projects 🤣 ... strings, dynamic arrays, what else was a must? ( In before Tsoding materializes out of nowhere ). Have to watch this after work!
1 like

@Pitometsu
Emacs!
1 like

@RLeRoux64
Yay!
1 like

@SamProgramiz
The null terminator is just 1 byte, your approach seems unnecessary and overkill with no clear benefits
1 like

@valigo
You don't need to iterate over string every time you need to count it, and you can have many different views into the same character array - so allocation-free substrings
4 likes

@SamProgramiz
What about the additional memory needed to store the count?




