Jeff Schroeder on 28 Aug 2001 04:19:06 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: hosers-talk: Duh.


At 02:29 AM 8/27/2001, you wrote:
[snip]
My String class, in order to work with C libs and hardcoded strings,
uses the ByteStream mechanism (which knows nothing of null-termination --
a null character is just another character) and then null-terminates
strings. Consequently, most of the code in the String class proper is
mediating code with the ByteStream to figure out the null-termination.

What I think is funny about my observation is that it's a very good
example of C's "worse is better" philosophy. I mean, compared to something
like Perl, or Visual Basic, C seems morally and philosophically tight,
coherent, and beautiful. But by making the concession to users that
hardcoded strings, ie. "whatever", are null-terminated automatically, you
end up with some curiosities. So it's not as free from special cases as we
might like.

Personally I like C better than VB because it gives you infinitely more control than other languages. But, depending on the application, it makes much more sense to use something like VB or perl. I am dealing a lot with VB and strings and integrating with C right now, and with the pattern matching libraries that emulate Perl functionality, it is very powerful and easy to use (for GUI's, I know about the HUGE memory and processor hits, already - don't mention it!). Even when using both VB and C functions, you get the best of both worlds. Making a GUI is so much easier in VB, and when you interface with C for the real work, you get huge time-saving advantages. There are some pains because the size and type of variables are different (VB booleans are 8 bits with 0 and -1 as false and true respectively!), but on the whole it works quite well (as long as you don't try to do anything ridiculously huge with VB).

Most of this argument is from a business and cost-savings standpoint to get the best work for the least time/money. But I think it is sound. Have you tried using the BSTRING libraries? I have not used them very often, but they seem simple and powerful to use. They emulate BASIC style strings and the libraries are apparently written in assembly for maximum speed. I don't know how they handle NULL charactors, though. Why are you putting a NULL character into a string, if I may ask?

I have no idea if this relates at all to what you are trying to do, but I'm just throwing out random streams of consciousness at this point!

keff