3 ms·
One performance issue C has is 0 terminated strings. String processing code is constantly hampered by having to do strlen or the equivalent to find the end of t
by WalterBright 12y ago
One performance issue C has is 0 terminated strings. String processing code is constantly hampered by having to do strlen or the equivalent to find the end of the string. 0 terminated strings also means that 'slices' of strings cannot be strings themselves, a copy must be made.
Of course, a C program doesn't have to use C strings, but so many libraries and APIs do (including the C standard library) that they are unavoidable for most practical purposes.
D eliminates this problem by using dynamic arrays to represent strings. A dynamic array is a pointer/length pair.
- nwmcsween 12y agoPointer, length or start pointer end pointer has overhead multiplied across n strings may even become larger than the strings themselves!
- WalterBright 12y agoOver a decade of experience with this in D shows that it's a significant net win.