IssueRaiser

What do people get out of pedantic rants such as this?

What do people get out of pedantic rants such as this? Anyone who's written anything in C is quite aware of the issue here. And then there's this gem: "...If the source string is 5 characters long, and the target is a 1024-byte buffer, and you set n to the size of the target, strncpy will copy those 5 characters and then fill all 1019 remaining bytes in the target with null characters. Since all it takes to terminate a string is a single null character, this is almost always a waste of time. Ok, so that's not so bad. CPUs are fast these days, and filling a buffer with zeros is not an expensive operation, right? Unless you're doing it a few billion times, but let's not worry about premature optimization." Does he think languages with built in String types have some magical optimization juice that make string operations fast? How long does it take to instantiate a new String object, run it's copy constructor, blah blah. Any C programmer looks to avoid these types of situations.

Posted by JustSomeNobody on Jun 1, 2015, 2:47 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.6,000 issues0 comments

pricing (Other)

What do people get out of pedantic rants such as this?

JustSomeNobodyJun 1, 2015, 2:47 PM

What do people get out of pedantic rants such as this? Anyone who's written anything in C is quite aware of the issue here. And then there's this gem: "...If the source string is 5 characters long, and the target is a 1024-byte buffer, and you set n to the size of the target, strncpy will copy those 5 characters and then fill all 1019 remaining bytes in the target with null characters. Since all it takes to terminate a string is a single null character, this is almost always a waste of time. Ok, so that's not so bad. CPUs are fast these days, and filling a buffer with zeros is not an expensive operation, right? Unless you're doing it a few billion times, but let's not worry about premature optimization." Does he think languages with built in String types have some magical optimization juice that make string operations fast? How long does it take to instantiate a new String object, run it's copy constructor, blah blah. Any C programmer looks to avoid these types of situations.

Comments (0)

No comments yet. Start the discussion.

Comment on this issue