Skip navigation.

Taming DataList With a Custom AdapterAll recent postsConnecticut Code Camp Follow-up

Craving For Language Expressiveness

What I’ve been missing in C# for years is expressiveness. For example, which construct is more natural?

if (collection.Count == 0) ...
if (collection.IsEmpty) ...

Some steps were already taken in 2.0, which is the case with string:

if (s != null && s != "") ... // the 1.x way
if (!string.IsNullOrEmpty (s)) ... // the 2.0 way

In both cases the latter construct is much more readable and natural. It’s closer to the human language.

What I’m really looking forward to are extension methods in 3.5. Can’t wait to have a way to augment some of the blandness. I’m also wondering when we’ll start seeing commercial or open source “extension packages”. It’s enough to look at Python or Ruby, for example, to really start craving for expressiveness.

To me, it’s not even about verbosity. I don’t mind it because I hate guessing what’s behind cryptic names (again, as in Python or Ruby). A Fluent Control Container, for example, may look a bit verbose at first sight, but it’s way better than the rut of instantiating controls one by one and stuffing them with properties.

This just in

Whoa! I may have my wish granted sooner. End of this month? ScottGu for, uuummm, president!

Comments

Comment permalink 1 Kent Boogaart |
I kid you not, this is from an email I wrote earlier today to colleagues:

=========================
NOTE #6

if (str.Length == 0)

is better than

if (str == string.Empty)

And similarly:

if (string.IsNullOrEmpty(str))

is better than

if (str == null || str == string.Empty)

WHY?: string.Equals() executes significantly more instructions than accessing the Count property, even when the string is empty. A string.IsEmpty property would be nice, but that hasn't been added yet (but you could add one yourself in .NET 3.5 using extension methods).
=========================

Freaky!

I, too, am looking forward to extension methods. Hopefully the community will standardize on sets of extension methods for common stuff. Otherwise, one project will use str.IsEmpty, another str.IsBlank, another str.ThereAintNothingToSeeHere etcetera.

Alright, gotta go practice my ESP . . .
Comment permalink 2 Milan Negovan |
LOL! Oh man, it's almost as if I was reading your mind.

Emails and Notifications

Would you like to be notified when somebody responds to this post?  Would you like to have these comments emailed to you?

TrackBacks

Sorry, TrackBacks are not allowed.

Submit your comment

Please enter only text since all HTML tags except hyperlinks will be stripped. Hyperlinks will become live links. Any comments with flaming or offensive language will be deleted. Be courteous to other posters. Thank you.

Your name (required):
Your email (optional):
Your site's URL (optional):
Enter this number
Type in the number above:
Comment (required):