|
|
Subscribe / Log in / New account

Tomboy, Gnote, and the limits of forks

Tomboy, Gnote, and the limits of forks

Posted May 5, 2009 20:02 UTC (Tue) by salimma (subscriber, #34460)
In reply to: Tomboy, Gnote, and the limits of forks by liljencrantz
Parent article: Tomboy, Gnote, and the limits of forks

Standard C strings cannot be compared to a string in a higher level language (e.g. Java, Python). No Unicode support, no bounds checking, etc. I agree, though, that compared to Python 3's closest equivalent, byte array, the C implementation will be faster in performance. I doubt you'd be as productive writing string-manipulating code in C, though.


to post comments

Tomboy, Gnote, and the limits of forks

Posted May 5, 2009 20:12 UTC (Tue) by jordanb (guest, #45668) [Link] (1 responses)

Not only that but you'll likely write buggy code. Not even getting into mangling Unicode, there's the problems with butchering any string that contains a NUL character. Also since it's such a PITA to do dynamically allocated strings you'll probably also start imposing silly restrictions on string length just to get things done.

Tomboy, Gnote, and the limits of forks

Posted May 6, 2009 3:30 UTC (Wed) by shmget (guest, #58347) [Link]

String is a very basic problem. basic as in 'used all the time' - not basic as 'easy'.

Yes writing a god string library in C is some work, but you have to do that only once.
And no, you do not have to impose silly restriction.

"there's the problems with butchering any string that contains a NULL character."
Every Mixed CCSID that I know of take great care to avoid binary 0 in any port of a character. (pure DBCS usually avoid it too, except UTF-16, but then the 'unit of work' is a int16_t not a int8_t)

So you are left with dealing with 'string' that actually contain the character NULL... and quite frankly that is practically irrelevant.

Furthermore, a good String library will keep track of size -- without using the C zero-terminated convention -- for performance and memory management reason, so even the irrelevant 'problem' of NULL in a string is actually covered as a side effect....

The whole 'memory management is hard' theme is a red herring. Good design is hard, good coding is hard, yes... but memory management is really a question of disciple and habit, and after a while if become second nature.


Tomboy, Gnote, and the limits of forks

Posted May 7, 2009 20:21 UTC (Thu) by liljencrantz (guest, #28458) [Link]

Agreed. Which is why I very explicitly stated in my original post that when I talked about string handling in C, I did _not_ mean plain C strings. There are _plenty_ of very high performance string libraries for C. Libraries that support Unicode, bounds checking, O(1) complexity for inserting data into the middle of a string, O(1) complexity for creating sub strings and various other very nifty features that often make them _faster_ then C strings, in addition to being safer. And performance-wise, they are a significant win over e.g. Python.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds