I Heart Strings

Strings.

Well, I guess I am the killjoy bastard, I frankly don’t know why people so much enjoy String.
When you have to deal with UI ok, use strings.
In a previous job, one rewarded architect choose to use xml/soap/kinf of communication. the main reason put forward, was human readable. Woo, an guess what it was communication over an SSL layer. So i wonder to which kind of human these kind of communication are dedicated.

So People understand string, give them string; computers understand binary give them binary.

Some people try to talk with dogs, and pets. it doesn’t work but they still do it and find it fun and cool. I was hoping IT world was a bit more reasonnable…

Peace,

I have found C# String.Format to be incredibly useful, but a major bugbear for me is bad error reporting if I make a mistake in the format. Things go distinctly awry if your code is off the UI thread, IIRC.
But of course - you may just attribute that to bad programming!

String.Format…woooonderful stuff, I agree. What’s even better is being able to specify your formats in the web.config for greater maintainability.

IE:

Name: {0} {1}

can easily be changed to:

Name: {1}, {0}

…if you put the format string in the x.config. I’m a huge fan of stuff like this.

Python even has an operator for string formatting:

brian = (“Bring”, “out”, “yer dead!”)
european_swallow = “%s %s %s” % brian
african_swallow = " ".join(brian)

arthur = "Bring out %(possesive)s %(state)s!"
brian = { state: “dead”, possessive: “yer” }
european_swallow = arthur % brian

If there’s one thing I don’t like about the whole class of formatting strings in C is that you loose all forms of type safety while using it. Yes a compiler like GCC (too my knowledge the only one atually) still performs type checking and gives you warnings (which I always turn into errors) when you have type mismatches… But still, I like an approach like Boost.Format’s much better (i.e. you don’t loose the type safety of the language).

Some people try to talk with dogs, and pets. It doesn’t work but they still do it and find it fun and cool. I was hoping the IT world was a bit more reasonable…
SIT! SIIIIT… STAY… Now, Output! Good code.
Aw no, the damn thing just recursed all over the stack.

@Giel: he’s not talking about printf (which does have type-safety issues), he’s talking about .NET Strings. All .NET objects derive from Object, and Object implements a .ToString() method, which means that all types can be converted to a string. Which, as I’m sure Jeff would agree, is beautiful.

Argh, this sort of thing drives me crazy. There’s a Sniglet called asterexasper (if I recall correctly), that is defined like this: When a sentence has an asterisk in it but the corresponding footnote doesn’t exist.

This article contains an asterexasper in this sentence: Regular expressions, for example, are themselves strings, as is SQL.*

So what WAS the footnote suppose to be, huh?

That asterexasper bugged me too, so I invented my own footnote. :slight_smile:

*Well, the concrete syntax is anyway. Of course you could argue that the language itself is defined by its abstract syntax, and is more of a tree than a string.

That asterexasper bugged me too, so I invented my own footnote. :slight_smile:

*Well, the concrete syntax is anyway. Of course you could argue that the language itself is defined by its abstract syntax, and is more of a tree than a string.

The .NET (and Java) string classes look so good because C strings (bstr, tstring, wstring, const char*, wchar*, etc.) are so durn ugly.