News for hackers. Stuff that matters.
Re:Some Were Meant for C (2017) [pdf] by v_lisivka on Thursday April 25, 2019 @06:10AM (#19746572)
> All the listed weaknesses also have benefits. For instance it is easy to get a substring without need to copy.

To make substring in some other languages, you need to store pointer to beginning of the substring and length of substring.

To make substring in C, you need to store pointer to beginning of the substring and put '\0' into original string.

Re:Some Were Meant for C (2017) [pdf] by johannes1234321 on Thursday April 25, 2019 @06:18AM (#19746618)
> To make substring in some other languages, you need to store pointer to beginning of the substring and length of substring.

Plus a pointer to the beginning, plus a reference counter as the user expects it to manage lifetime. In C this is the user's job. Where they know the life time is guaranteed they can optimize.

Re:Some Were Meant for C (2017) [pdf] by Nursie on Thursday April 25, 2019 @09:56AM (#19748117)
I coded in C for over a decade. Never did I need a reference counter.
Re:Some Were Meant for C (2017) [pdf] by jstimpfle on Thursday April 25, 2019 @11:25AM (#19749116)
No, you store offset + length.
Re:Some Were Meant for C (2017) [pdf] by adrianN on Friday April 26, 2019 @09:39AM (#19757323)
You can't use any of the stdlib string functions if you don't have that \0 at the end though, right?
Re:Some Were Meant for C (2017) [pdf] by jstimpfle on Friday April 26, 2019 @09:44AM (#19757371)
Is there any function you would miss? Of those, which one couldn't you recreate in 5 straightforward lines of code?