News for hackers. Stuff that matters.
Re:“People who implement new and improved interfaces always ... by throwaway000002 on Friday September 11, 2015 @04:00PM (#10205849)
Have there been any serious attempts at an alternate string library interface for C, perhaps even an total redo of the standard C library with decades of hindsight?
Re:“People who implement new and improved interfaces always ... by WalterBright on Friday September 11, 2015 @04:36PM (#10206037)
The main difficulty with strings in C is caused by arrays decaying to pointers whenever passed to a function.

My article about it:

http://digitalmars.com/articles/b44.html

Re:“People who implement new and improved interfaces always ... by joveian on Saturday September 12, 2015 @06:21PM (#10209592)
I just recently discovered that modern C actually has syntax for forcing sized arrays as function arguments. You can do:

foo(size_t n, char arr[restrict static n])

The static qualifier here means "no really, I actually want the compiler to complain if the passed array isn't the size indicated". (because C doesn't have enough different meanings for the word "static" :( ). I haven't seen this in the wild yet or checked if gcc and clang actually implement it usefully, but it seems like it could be quite useful.

Re:“People who implement new and improved interfaces always ... by mzs on Friday September 11, 2015 @04:27PM (#10205997)
There have been /many/ attempts. Here's a link to a comment on the sds from redis post (yet another alternative string library) that links to a nice overview of a number of alternatives:

https://news.ycombinator.com/item?id=7191509

I've used Ustr before, all of them have pros and cons depending on what you are needing.

Re:“People who implement new and improved interfaces always ... by throwaway000002 on Saturday September 12, 2015 @04:33PM (#10209262)
Thanks mzs for that great reference to an old HN comment. Appreciated!

The volume of string libraries only suggests how crucial core library design, often an afterthought, is to programming language design. The language itself encourages idioms, and it's for the core library to harness these idioms into a robust, cohesive, comprehensive toolbox for common tasks.

Re:“People who implement new and improved interfaces always ... by vezzy-fnord on Friday September 11, 2015 @04:14PM (#10205918)
Custom string libraries for C are plenty. Pretty much all large C projects accumulate extensive libraries of utility functions, and string processing is a common one to abstract.
Re:“People who implement new and improved interfaces always ... by ExpiredLink on Friday September 11, 2015 @04:34PM (#10206028)
A string library may mitigate but cannot solve the problem. In C you always need to take allocation/deallocation into consideration.