keyword with in C#

  • Thread starter Thread starter Nicholas Paldino [.NET/C# MVP]
  • Start date Start date
N

Nicholas Paldino [.NET/C# MVP]

Elder,

It was determined that with doesn't add anything to the language in
terms of readability (this is an opinion of the language designers). Also,
"with" was used as a performance enhancement in VB, but in .NET, the
mechanics are different, and the performance benefit is no longer there.
Finally, given C#'s C/C++ heritage, those languages do not have a "with"
statement, so this influenced the decision as well.

Hope this helps.
 
hi, everyone,
i would like know why c# doesn't have the keyword "with", such as vb does?

Thank u so much;;
 
Is it me, or was this topic beaten to death already this week? (Oct-28 and
Oct-29 to be specific, so it wouldn't have been too hard to see if the
question had already been addressed)

<sarcasm>

People, could we limit the "why isn't C# more like VB.NET" questions to just
one pert week? PLEASE!!!!! <bg>

For future reference please see the following Q & A:

Q: Why doesn't C# have (or do) <* Insert favorite VB feature here *> like
VB?
A: Because, C# is not VB!

</sarcasm>


Brian W
 
Ill never code VB and Ill never do webwhore stuff.

Id rather do COBOL.

VB = da piss
 
I've many times examined the IL and the final x86 instructions of code made
with "with" in VB.NET and it would appear that there are some optimizations,
at least in the sense, that it assigns a pointer to a register and then the
following uses of the with do some pointer magic with that register, as
opposed to if I don't use the with, every use of the object causes it to
fetch the pointer and then do some pointer magic. It appears there is an
optimization.

"With" is not a pure vb thing, as almost everyone thinks. It's also in
JScript. Though the syntax of it in JScript is horrible, it doesn't use the
preceding . (dot). It's never obvious when looking at the code. In VB,
I've never had a problem with a "with". It does indeed add readibility to
the code, an opinion no C# programmers share (probly because they aren't
used to the grammer and they are so think on thinking "its a VB thing and I
avoid all VB things.".

My opinion is if you don't like/want "with" in C#, then plea with the
language designers to get rid of the "using" statement as well.

But the language must evolve, as does all other languages must evolve.
Keeping features out of one just because they exist in another (one you
don't like) is not a good enough reason to keep it out.

I've read the papers from the C# developers explaining why they left it out
and quite frankly, I've come to the conclusion that they won't do it because
they are too lazy to add it in and because too many C# programmers feel it's
a "VB thing" and despise it not based on any lack of merit. Everytime I've
seen the argument, they are quick to point out something to the effect of
"keep it in VB". They should say something to the effect of "keep it in VB,
JScript, and JScript.NET". Because it's not just in VB.

This topic has been pounded to death. I've written lengthy dissertations on
the topic.

I'm primarily an assembly language, C++ programmer who makes a living doing
VB, who is good in C# and can do Java. Of all the languages I've worked
with, I don't get "stuck" with any particular one. Each has its merits and
its place and proper use. Just another tool in the toolbox. I don't mind
language evolution. But I wouldn't fight toothe and nail to keep a feature
out of a language just because its in an other language I don't want
anything to do with.


Thanks,
Shawn


Nicholas Paldino said:
Elder,

It was determined that with doesn't add anything to the language in
terms of readability (this is an opinion of the language designers). Also,
"with" was used as a performance enhancement in VB, but in .NET, the
mechanics are different, and the performance benefit is no longer there.
Finally, given C#'s C/C++ heritage, those languages do not have a "with"
statement, so this influenced the decision as well.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Elder Santos said:
hi, everyone,
i would like know why c# doesn't have the keyword "with", such as vb does?

Thank u so much;;
 
Shawn B. said:
I've many times examined the IL and the final x86 instructions of code made
with "with" in VB.NET and it would appear that there are some optimizations,
at least in the sense, that it assigns a pointer to a register and then the
following uses of the with do some pointer magic with that register, as
opposed to if I don't use the with, every use of the object causes it to
fetch the pointer and then do some pointer magic. It appears there is an
optimization.

"With" is not a pure vb thing, as almost everyone thinks. It's also in
JScript. Though the syntax of it in JScript is horrible, it doesn't use the
preceding . (dot). It's never obvious when looking at the code. In VB,
I've never had a problem with a "with". It does indeed add readibility to
the code, an opinion no C# programmers share (probly because they aren't
used to the grammer and they are so think on thinking "its a VB thing and I
avoid all VB things.".

My opinion is if you don't like/want "with" in C#, then plea with the
language designers to get rid of the "using" statement as well.

Which using statement? I don't like using aliases, but I do like the using()
statement, please qualify your statements fully.
But the language must evolve, as does all other languages must evolve.
Keeping features out of one just because they exist in another (one you
don't like) is not a good enough reason to keep it out.

I've read the papers from the C# developers explaining why they left it out
and quite frankly, I've come to the conclusion that they won't do it because
they are too lazy to add it in and because too many C# programmers feel it's
a "VB thing" and despise it not based on any lack of merit. Everytime I've
seen the argument, they are quick to point out something to the effect of
"keep it in VB". They should say something to the effect of "keep it in VB,
JScript, and JScript.NET". Because it's not just in VB.

This topic has been pounded to death. I've written lengthy dissertations on
the topic.

Yes it has, and its certainly not needed in C#, it was barely needed in VB
or JScript, it is, at this point, just a syntax feature that doesn't provide
much simplicity(and potentially could cause breaking simplicity, if used
badly)
I'm primarily an assembly language, C++ programmer who makes a living doing
VB, who is good in C# and can do Java. Of all the languages I've worked
with, I don't get "stuck" with any particular one. Each has its merits and
its place and proper use. Just another tool in the toolbox. I don't mind
language evolution. But I wouldn't fight toothe and nail to keep a feature
out of a language just because its in an other language I don't want
anything to do with.


Thanks,
Shawn


message news:[email protected]...
Elder,

It was determined that with doesn't add anything to the language in
terms of readability (this is an opinion of the language designers). Also,
"with" was used as a performance enhancement in VB, but in .NET, the
mechanics are different, and the performance benefit is no longer there.
Finally, given C#'s C/C++ heritage, those languages do not have a "with"
statement, so this influenced the decision as well.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Elder Santos said:
hi, everyone,
i would like know why c# doesn't have the keyword "with", such as vb does?

Thank u so much;;
 
Back
Top