正在加载视频...

视频加载失败

I made a string library from scratch in C. Here's how and why Chapters: 00:00 - Intro 00:15 - Why 02:26 - First style - struct 05:16 - Second - Pascal style 06:50 - Comparing approaches 10:20 - single-header details 11:30 - Library implementation tour 15:05 - Splitting strings...

23,813 次观看 • 3 个月前 •via X (Twitter)

33 条评论

Πλάτων 的头像
Πλάτων3 个月前

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

Valentin Ignatev 的头像
Valentin Ignatev3 个月前

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

Πλάτων 的头像
Πλάτων3 个月前

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

William Schaub 的头像
William Schaub3 个月前

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

OmittedVerstand 的头像
OmittedVerstand3 个月前

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 个月前

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

Valentin Ignatev 的头像
Valentin Ignatev3 个月前

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

Mx_paia_19 的头像
Mx_paia_193 个月前

Yay ill have what to watch during lunch now

droug 的头像
droug3 个月前

very pascal coded imo

Kknewkles Wildwision 的头像
Kknewkles Wildwision3 个月前

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.

CaptainAmericaTex 的头像
CaptainAmericaTex3 个月前

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.

chester 的头像
chester3 个月前

Nice

VicThor Dev 的头像
VicThor Dev3 个月前

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)

Valentin Ignatev 的头像
Valentin Ignatev3 个月前

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 :)

GrumpyBalkanSoftwareEngineer 的头像
GrumpyBalkanSoftwareEngineer3 个月前

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!

Netsu🇺🇦 的头像
Netsu🇺🇦3 个月前

Emacs!

Reece 的头像
Reece3 个月前

Yay!

SamProgramiz 的头像
SamProgramiz3 个月前

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

Valentin Ignatev 的头像
Valentin Ignatev3 个月前

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

SamProgramiz 的头像
SamProgramiz3 个月前

What about the additional memory needed to store the count?

William Schaub 的头像
William Schaub3 个月前

@valigo In a memory unsafe language like C knowing the exact size at all times is worth the extra memory to make it easier to work with and avoid mistakes.

SamProgramiz 的头像
SamProgramiz3 个月前

@valigo I thought the null terminator already has that covered pretty well and just 1 byte of memory required, of course you need to run through the string each time but you can then discard the count and not have it floating around, eating up that additional 3 bytes

William Schaub 的头像
William Schaub3 个月前

@valigo working with C strings is very error prone and you also don't account for things like injecting a null into a string from user input, etc. There's a place for C strings but if you want to do fancy string manipulations something like this is far better than 1970s stdlib

SamProgramiz 的头像
SamProgramiz3 个月前

@valigo You make a great point with the data corruption issue. Thanks for explaining, I think the upside is more clear to me

Sλava 的头像
Sλava3 个月前

Единственное что я бы сделал по-другому, это префикс такой же как имя структуры. Почему-то так гораздо приятнее, автодополнение дополняет имя класса, ставишь _ и сразу все "методы".

Valentin Ignatev 的头像
Valentin Ignatev3 个月前

Я думал об этом, но префикс с большой буквы меня смутил, поэтому надо было либо структуру делать с маленькой, либо префикс с большой. Решил пока попробовать вот так гибридно. Если приживется, наверное структурку сделаю string просто

K I L S A 的头像
K I L S A3 个月前

your curiosity i like it

nano 的头像
nano3 个月前

Лень смотреть

irbos 的头像
irbos3 个月前

No jai, disliked

Sid 的头像
Sid3 个月前

Very cool work! Since the split function is allocation free, we don't expect the input string to be tampered with after the split right? Have you considered Zig's iterator approach which just yields the 'String' just split. Caller still allocates if they want to

Reece 的头像
Reece3 个月前

8:14 - Jet?

Valentin Ignatev 的头像
Valentin Ignatev3 个月前

I think it was just a loud car lol

Reece 的头像
Reece3 个月前

🤣 Great video

相关视频

Updated: Vocals & Rap - #성화 #Seonghwa 00:00 Still Here 00:15 Wonderland 00:36 Halazia 00:47 Answer 01:21 Cyberpunk 01:27 Wave 01:37 Utopia 01:50 My Way 02:00 With U 02:16 Be With You 02:54 Star 1117 03:21 Turbulence (야간비행) 03:39 Days 04:26 Promise 04:38 Fever 04:54 Sunrise 05:19 Mist 05:43 Take Me Home 06:11 Better 06:34 All About You 06:43 Aurora 06:55 Blue Summer 07:23 Diamond 07:46 Time Of Love 07:58 Stay 08:07 Desire 08:21 WDIG 08:28 New World 08:35 Dreamers 08:53 Not Too Late 09:03 The Letter 09:19 One Day At A Time 09:28 Dazzling Light 09:40 Light 09:50 The Ring 10:04 Paradigm 10:18 This World 10:38 Bouncy 10:51 Not Okay 11:15 The King 11:23 Inception 11:52 Fireworks 12:03 Limitless 12:19 Precious 12:28 Rocky 12:41 Let’s Get Together 13:07 White Love 13:17 The Leaders 13:27 Crazy Form 13:43 Arriba 13:57 Silver Light 14:06 Dreamy Day 14:26 Matz 15:15 Outlaw 15:23 Twilight 15:31 Dune 15:38 Hala Hala 15:43 Deja Vu 15:50 Horizon 15:54 Say My Name 15:57 Sector 1 16:02 Good Lil Boy 16:09 Don’t Stop 16:12 Still Here (Acoustic Ver) 16:19 Siren 16:31 Guerrilla 16:45 We Know 17:00 Empty Box 17:28 Wake Up 17:40 Dancing Like Butterfly Wings 17:49 Work 18:09 Thanxx 18:26 If Without U 18:45 Shaboom 19:01 Outlaw 19:18 Treasure 19:33 Eternal Sunshine 20:03 Django 20:31 Turbulence Japanese Ver. 20:55 Blind 21:16 Pirate King 21:24 Forevermore 22:00 Birthday 22:11 Deep Dive 22:26 Ice On My Teeth 22:50 Man On Fire 23:10 Selfish Waltz 23:25 Enough

Hwanakin

62,764 次观看 • 1 年前

내가 보려고 모은 #조이 역대 브릿지 파트 모음.zip (Ice Cream Cake~Sweet Dreams) 💚 * 레드벨벳 앨범만 포함했습니다 00:00 Somethin Kinda Crazy 00:05 Take It Slow 00:13 사탕 (Candy) 00:20 Dumb Dumb 00:22 Campfire 00:31 Lady’s Room 00:33 Day 1 00:43 Coold World 00:51 My Dear 00:55 Bad Dracula 00:58 Happily Ever After 01:03 빨간 맛 (Red Flavor) 01:09 여름빛 (Mojito) 01:13 I Just 01:17 Kingdom Come 01:23 두 번째 데이트 (My Second Date) 01:27 Attaboy 01:36 Perfect 10 01:42 달빛소리 01:53 Bad Boy 01:59 Time To Love 02:09 #Cookie Jar 02:13 Aitai-tai 02:20 Power Up 02:23 한 여름의 크리스마스 (With You) 02:30 Mr.E 02:35 Mosquito 02:41 RBB (Really Bad Boy) 02:47 So Good 02:51 멋있게 (Sassy Me) 02:54 Swimming Pool 02:57 Sayonara 03:04 짐살라빔 (Zimzalabim) 03:12 Sunny Side Up! 03:16 Milkshake 03:21 친구가 아냐 (Bing Bing) 03:29 안녕, 여름 (Parade) 03:32 LP 03:41 음파음파 (Umpah Umpah) 03:48 카풀 (Carpool) 03:57 Love Is The Way 04:05 Jumpin’ 04:11 눈 맞추고, 손 맞대고 (Eyes Locked, Hand Locked) 04:17 Psycho 04:24 In & Out 04:34 Remember Forever 04:44 Milky Way 04:52 Queendom 05:00 Pose 05:07 Knock On Wood 05:15 Better Be 05:25 Feel My Rhythm 05:29 Rainbow Halo 05:36 Beg For Me 05:43 In My Dreams 05:48 Marionette 05:50 WILDSIDE 05:54 Jackpot 06:00 Snap Snap 06:08 ‘Cause it’s you 06:14 Color of Love 06:16 Birthday 06:19 BYE BYE 06:22 롤러코스터 (On A Ride) 06:29 Zoom 06:40 Celebrate 06:48 Chill Kill 06:56 Knock Knock (Who’s There?) 06:59 Nightmare 07:03 One Kiss 07:10 Wings 07:21 풍경화 (Scenery) 07:32 Sunflower 07:38 Love Arcade 07:44 Bubble 07:51 Night Drive 07:57 Sweet Dreams

맑음쨩 🍏

20,678 次观看 • 1 年前