D'Arcy from Winnipeg
Solution Architecture, Business & Entrepreneurship, Microsoft, and Adoption

All I want is a bloody 'With/EndWith'!

Monday, February 6, 2006 1:46 PM

<rant>

So I'm on a C# project right now, and actually am really enjoying working with the language! It's not the nasty beast I thought it would be, and the semicolons are growing on me. I ran into a bit of a snag the other day when I needed to check a value to see if its numeric. Hmmm...no IsNumeric function in C#. After asking around, I was pointed to a few different solutions like the parsing method of the integer data type or using a regular expression (which is what I went with).

Today, I wanted to use a with/endwith statement. Hmmm...not showing up in the intellisense. So I Google, sure that I'm just not using the right syntax (case sensitivity is something to get used to as well). I dig up the article below:

http://www.gotdotnet.com/team/csharp/learn/columns/ask.aspx#with

It explains that there IS no with/endwith construct within C#. Really. Now, I can accept this, since the reason there are different languages goes beyond different syntax to different features as well. But the explanation as to why they didn't include it got my blood pressure up.

Reason 1: Small or non-existent readability benefits.

Totally disagree with this one. With statements DO make the code MORE readable, cleaner, and less messy looking. Now, that's all a matter of opinion, but the statement the author makes that "I won't go as far to say that teh with statement makes code less readable, but some people probably would" does nothing but widen the divide between VB and C# devs. I'm sure alot of VB devs would agree with me.

Reason 2: Increased language complexity.

I can accept this. If they felt that the amount of work that would be required to put it in was too great for the ability to not type an object name a few times over, that's fine. The VB team did have to add extra things to make VB work with it, but hey: they DID it. If the C# team doesn't want to/can't because of fear that it would just screw up the progress of C#, that's fine though.

But then came reason 3...the most ludicris thing I've ever read...

Reason 3:Because C++ has never had a with statement, and C++ devs don't have a problem with not having it.

I thought we were talking to C# developers here, not C++. And in fact, there's probably a greater chance that a VB developer would have to jump into C# before a C++ dev would. So why not cater to your two main markets: C# devs and VB devs that have to straddle the fence?! VB people would LOVE to have access to the same constructs in C# as they would in VB, but to say that the DESIGN DECISION was based on how C++ people felt? Wow. Is there that great a divide between the language teams?

Ok, I'm done.

</rant>




Feedback

# re: All I want is a bloody 'With/EndWith'!

Couldn't agree more. I was stunned when I found out, also coming from a VB background. It's one of the lamest excuses for not bothering to include a construct I've ever heard. It's almost as lame as the redundant 'break' statements in 'switch' blocks.

What got me even more annoyed was finding out that the recommended getaround of the lack of 'with' by many C# devs is to declare one-character-named objects as mirrors of the longer-named object, and use THEM to perform multiple actions with the longer-named object.

HOW... DUMB... IS... THAT...

They refuse to support this elegant, clear, structured construct (don't forget it'd be indented properly):

with oftenLongObjectName {
.doOneThing();
.doAnotherThing(.property);
.property = "value";
}

They'd rather force people to do this:

RandomNameSpace.Blah.Yadda.Foo.Bar.LongObjectType o = oftenLongObjectName;
o.doOneThing();
o.doAnotherThing(o.property);
o.property = "value";

And they wanted C# to be an 'elegant' language... 2/23/2006 7:41 AM | Hugo

# re: All I want is a bloody 'With/EndWith'!

I love how C++/java folks now using C# go absolutely ga-ga over 3rd party background compilation and when they see it they MUST have it and start waving the flag that this is what makes C# better than VB. VB has had it since what 4? (that reminds me... Bill Storage worked on MS's first Intellisense system for what ... VB5?).

C++ folks never ever ever would even look at VB. Those same folks would never ever look at the VB.Net IDE so they just don't know what is there that should be in C#. Meanwhile VB folks - who it seems have to be blilingual far more often - see the lacking in both sides and are ridiculed for it.

Here's the thing VBers: do what the ReShaper people did, say "wouldn't it be great if the C# IDE did [fill in the blank with an Explanation of the VB IDE feature and never ever ever let it slip that it was already part of VB's heritage as a trend-setting Development Productivity TOOL]" 1/14/2007 9:40 AM | smith

Post a comment