C# developers going back to vb.net

G

Guest

Jon, et. al.,

#2 wins the day!!! New engineers need external discipline until they are
experienced enough to know when they can bend the rules. Syntax, RAD, and
features aside, I'm investing in the new folks and want them to develop good
habits.

Many thanks,
Roger

:
 
C

Cor Ligthert [MVP]

Jon,
5) The language is smaller, and thus easier to learn. You need to learn
the .NET framework, of course, just as you do in VB.NET - but without
all the extras which are basically there for backwards compatibility.

The first part of this sentence is something I don't dare to write because
of the reactions that will be, when I write it. (I had written it in a
message and than decided to take the message from Tom Dacon to overcome
needles discussions)

Except that the extra's are not only for compatibility. However, the impact
of those extra's are almost the same as you write about the extra's from C#.

:)

Cor
 
J

Jon Skeet [C# MVP]

Cor Ligthert said:
The first part of this sentence is something I don't dare to write because
of the reactions that will be, when I write it. (I had written it in a
message and than decided to take the message from Tom Dacon to overcome
needles discussions)

Except that the extra's are not only for compatibility. However, the impact
of those extra's are almost the same as you write about the extra's from C#.

If the extras aren't just there for compatibility, could you explain
why they *are* there? There are plenty of VB.NET functions which have
identical functionality to "normal" .NET framework methods. Why have
redundant functions other than for the sake of compatibility?

C# has a very *few* "extras" which are syntactic sugar (lock and using
are the primary ones which come to mind). It has a couple of operators
such as typeof(...) which give compile time safety and efficiency. It
*doesn't* have reams of functions built into the language like VB.NET
does.
 
C

Cor Ligthert [MVP]

Jon,
If the extras aren't just there for compatibility, could you explain
why they *are* there? There are plenty of VB.NET functions which have
identical functionality to "normal" .NET framework methods. Why have
redundant functions other than for the sake of compatibility?
Exactly as you wrote, "plenty of" not all and it is even a minority,
however I don't think that this C# newsgroup is the right place for that,
maybe we can discuss this sometime when this question comes up again in the
"General" newsgroup.

(I try to use consequent 'methods' by the way, using 'functions' is for me a
kind of backward compatibility with Excel.)

Cor
 
F

Frans Bouma [C# MVP]

Roger said:
Well, a lively discussion, that's for sure.

As a conciencious manager getting ready to embark on a GUI
development project I would like to launch my developers on the best
path and platform. This is "blank sheet of paper" development and
primarily new grads. They will accept whatever language I place in
front of them, and, unfortunately, I haven't been able to gleen much
from this conversation on which of the two would be best. (I won't
go too deaply into my programming background other than to say that I
still prefer assembly language - protected, unprotected, object
oriented, ... it's all op-codes).

Anyway, I want to get my newbies started on the right path. Is there
REALLY a difference between the two? Will I hit a dead end with one
or the other? When I read the code snippets, they look structurally
identical - is this not the case? Is VB.NET more like C# than it is
like VB6?

You're in the C# newsgroup, so I wouldn't expect an answer like "Use
VB.NET!" ;).

VB.NET 1.x (on .NET 1.x) has some shortcomings compared to C#, they
corrected that in the upcoming .NET 2.0 / VB.NET 2005. You don't always
run into these either, but they're there (no operator overloading, no
ability to use implicit conversion methods etc.).

That said, for the productivity of the team, I'd use the language
which appeals the most to the majority of the developers. Even if they
never used VB.NET nor C#, it still can be important, because it might
be they think in the mindset of a C# programmer or a VB.NET programmer.

FB

--
 
F

Frans Bouma [C# MVP]

I never thought the day would come I would say anything in favor of ...
VB, but here it goes ;) ->
Aside from those, I would suggest using C#, for the following reasons:

1) As it was designed specifically for the .NET framework, it's more
closely aligned to it. It doesn't have a load of legacy quirks -
about the quirkiest it gets is in the switch statement. Compare this
with the various oddities of VB.NET which are basically there for
backwards compatibility, for instance the String "Nothing" handling.

still, the VB.NET select case statement is IMHO more powerful. I find
the C# switch statement the most lamest version of a switch statement
you could possibly design, for the sole reason that it has:
- lame 'break' statement which is completely redundant (no fall through
supported)
- because of no fall through, you have to use 'goto'. So, using
spagetti with goto is preferred over having fallthrough.. I don't get
it.
- VB.NET's select case has range filters for the case clauses, which
are very powerful.
3) It uses more standard terminology than VB.NET - null, internal etc.

Isn't this subjective?
There are specific things you can do in C# that you can't do in
VB.NET (just as there are some the other way round, as shown above)
but these aren't generally very important - unsafe code is very
rarely useful to most people. Operator overloading can occasionally
be nice, but it's more that it's great on some of the system types
(TimeSpan, DateTime) than that it's important to be able to overload
yourself.

I disagree. For starters, implicit conversion operators are VERY
important and you're probably using them every day without noticing
them, but you can't use them in VB.NET (or you have to use the dreaded
op_Implicit...)

Also, operator overloading is underestimated a lot as well. For
example, I've managed to create a 'linq-ish' language with operator
overloading alone to create typed, compiletime checked filters for my
O/R mapper, a few other O/R mappers like genome and I believe also db4o
use similar constructs.

I find it a pity that C# doesn't allow you to define your own
operators as well, because there are just a few operators to overload.
So while I can do:
IPredicate f = (CustomerFields.CompanyName=="Microsoft");

It's harder to create a simple construct to write a subquery filter as
the operator(s) required aren't definable like 'IN'. (with C# 3.0, this
ofcourse changes).

Frans

--
 
F

Frans Bouma [C# MVP]

Cor said:
Jon,

Exactly as you wrote, "plenty of" not all and it is even a minority,
however I don't think that this C# newsgroup is the right place for
that, maybe we can discuss this sometime when this question comes up
again in the "General" newsgroup.

Dont backtrack now, show the list of stuff which ISN'T there for
backwards compatibility and stuff added deliberately to the language to
make it 'better'

FB

--
 
C

Cor Ligthert [MVP]

Frans,
Don't backtrack now, show the list of stuff which ISN'T there for
backwards compatibility and stuff added deliberately to the language to
make it 'better'

If you challenge me, I don't like to show it here, there as I wrote there
are better places for that.

See almost all converting methods, they do more than only function as a
wrapper around the parse or convert.

See especially some date methods, which surely extend the Net functions.

There are as well inbuilt financial methods and mathematical methods which
are not as that in the Net.

http://msdn.microsoft.com/library/d.../vblr7/html/vaorivbruntimelibrarykeywords.asp

Be aware that I was agreeing with Jon that some are redundant, in that case
I use the Net methods, while I absolute do not use methods which use the one
as indexer because that confuses me, by instance the vb collection. Most of
the ones active in languages.vb newsgroup have the idea that the
vb.collection should have been placed in the visualbasic compatible
namespace. Not unlikely that you are confused by it, that the compatible
namespace is a separated namespace.

Of course can you can make all those methods yourself. However, I started
with only very few instructions and could do everything. I tell often that
I only need an If, a branch conditional, an add and the possibility to shift
to negative to be able to do everything. However, don't ask me how much time
that takes.

Cor
 
K

Kevin Spencer

I find
the C# switch statement the most lamest version of a switch statement
you could possibly design, for the sole reason that it has:

As much as I love C#, this is also one of my pet peeves, and I certainly
don't see the logic in it. It doesn't make C# any "safer." It reminds me of
the sort of thing that VB does to prevent developers from accidentally
creating logical errors. The "break" statement should stay, but the "no
fall-through" rule is monumentally stupid.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
 
J

Jon Skeet [C# MVP]

Frans Bouma said:
I never thought the day would come I would say anything in favor of ...
VB, but here it goes ;) ->


still, the VB.NET select case statement is IMHO more powerful. I find
the C# switch statement the most lamest version of a switch statement
you could possibly design, for the sole reason that it has:
- lame 'break' statement which is completely redundant (no fall through
supported)
- because of no fall through, you have to use 'goto'. So, using
spagetti with goto is preferred over having fallthrough.. I don't get
it.
- VB.NET's select case has range filters for the case clauses, which
are very powerful.

Yes, VB.NET's select is indeed more powerful - although it's really
only the equivalent of

if (...)
{
}
else if (...)
{
}

as far as I know. Does it use the same switch/case IL construct
(whatever that is - I haven't looked into it) that C# does where it's
able to?
Isn't this subjective?

No, I don't think so. Look at the terminology the CLI specification -
it talks in largely C#-friendly terms such as "this" and "null" rather
than "Me" and "Nothing".

Plenty of other languages use the concepts of "this" and "null" too -
how many others use "Me" and "Nothing"?
I disagree. For starters, implicit conversion operators are VERY
important and you're probably using them every day without noticing
them, but you can't use them in VB.NET (or you have to use the dreaded
op_Implicit...)

That's why I said that it's great on system types, but that you rarely
need to write your own operator overloads.
Also, operator overloading is underestimated a lot as well. For
example, I've managed to create a 'linq-ish' language with operator
overloading alone to create typed, compiletime checked filters for my
O/R mapper, a few other O/R mappers like genome and I believe also db4o
use similar constructs.

I find it a pity that C# doesn't allow you to define your own
operators as well, because there are just a few operators to overload.
So while I can do:
IPredicate f = (CustomerFields.CompanyName=="Microsoft");

It's harder to create a simple construct to write a subquery filter as
the operator(s) required aren't definable like 'IN'. (with C# 3.0, this
ofcourse changes).

Personally, I think that when you get into too many operators and
implicit conversions, the code becomes very hard to read. Just my
experience of C++ though...
 
J

Jon Skeet [C# MVP]

Kevin Spencer said:
As much as I love C#, this is also one of my pet peeves, and I certainly
don't see the logic in it. It doesn't make C# any "safer." It reminds me of
the sort of thing that VB does to prevent developers from accidentally
creating logical errors. The "break" statement should stay, but the "no
fall-through" rule is monumentally stupid.

I'd go the other way. Falling through has proved buggy in many, many
C/C++ programs. I'd go for implicit breaks and still avoiding falling
through - or possibly have an explicit "continue" if you want to fall
through, to make it obvious that it's not just an omission.
 
C

Cor Ligthert [MVP]

Jon,

This is not cricket.
All those language derive from C. You probably know more which use "this"
and "null". VBNet derives from standard Basic, I doubt if the amount of
users in these two environments are very much apart from each other.

I don't agree with your 'if', however don't find it worthfull to argue with
you about that in the context of this thread. (Has nothing to do with you
personally)

Cor
 
K

Kevin Spencer

I'd go the other way. Falling through has proved buggy in many, many
C/C++ programs. I'd go for implicit breaks and still avoiding falling
through - or possibly have an explicit "continue" if you want to fall
through, to make it obvious that it's not just an omission.

I guess it's just the Libertarian in me. I prefer to take responsibility for
myself. And the falling through is so convenient.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
 
J

Jon Skeet [C# MVP]

Kevin Spencer said:
I guess it's just the Libertarian in me. I prefer to take responsibility for
myself. And the falling through is so convenient.

It's very occasionally convenient in my experience, but I *have* had
bugs where I've fallen through accidentally.

I like the language to try to stop me from shooting myself in the foot.
 
J

Jon Skeet [C# MVP]

Cor Ligthert said:
This is not cricket.
All those language derive from C.

Really? Here's a small sample of the languages which have a "null"
concept:

Delphi
CIL
Perl
C
C++
Java
JavaScript
SQL
COBOL

Do you really want to claim that *all* of those derive from C? Even
VBScript has Null!
You probably know more which use "this"
and "null". VBNet derives from standard Basic, I doubt if the amount of
users in these two environments are very much apart from each other.

Which Basic do you mean by "standard Basic"? I've used at least 5
different versions of Basic, and VB is the only one I've come across
with "Me" and "Nothing".

For me, however, the most important thing is that the .NET framework's
standard terminology is to use "null" and "this". Look at the libraries
- do you see DbNothing, or the IsNothingable or IsNothing property? Do
you see it talked about in the spec? Where is
"NothingReferenceException"?

VB.NET is the language which sticks out here, IMO.
I don't agree with your 'if', however don't find it worthfull to argue with
you about that in the context of this thread. (Has nothing to do with you
personally)

<shrug> Any time you feel like discussing it, I'm open to it.
 
B

Bruce Wood

That's why I said that it's great on system types, but that you rarely need to write your own operator overloads.

I find I need to write my own operator overloads just about as often as
I need to create my own value types.

Which, I admit, isn't very often, but I found it odd that VB.NET
allowed me to create my own value types but not overload operators. At
least they fixed that in Whidbey.

(In passing, I can't help but point out that this article on operator
overloading in VB.NET;

http://msdn.microsoft.com/vbasic/wh...y/en-us/dnvs05/html/vboperatoroverloading.asp

has an example of creating a complex number _class_. Now why on earth
would anyone want a complex number reference type...?)
 
S

Steve Walker

In message <[email protected]>,
Bruce Wood said:
http://msdn.microsoft.com/vbasic/whidbey/default.aspx?pull=/library/en-u
s/dnvs05/html/vboperatoroverloading.asp

has an example of creating a complex number _class_. Now why on earth
would anyone want a complex number reference type...?)

A good question; surely it should have value type semantics. However, I
found the same kind of thing in my own code today; a Money class, rather
than a Money struct. It's got a reference to an instance of Currency and
a quantity:double.

I've got a Thing which has a property of Amount:Money. Thing has a
static Empty:Thing property which returns a new instance of
EmptyThing:Thing. EmptyThing is a private inner class. Thing overrides
Equals to say that two Things with the same ID are equal. EmptyThing
initialise its ID immutably to -1 so that always Thing.EmptyThing ==
Thing.EmptyThing. I specifically didn't want a shared static instance of
EmptyThing because some of its properties *are* mutable. This convention
works well, the pattern is repeated throughout the system and there is
code within the DB access layer which treats an ID of -1 as dbnull. I
think a single magic number per system isn't too bad :blush:)

There's a custom webcontrol which takes a collection of Thing and
generates a table displaying a row for the details of each Thing, with
Save and Delete buttons. It also inserts a row at the end which displays
an instance of EmptyThing with an add button.

[Off topic, any comments on this architecture?]

The issue I dealt with today was a request that the empty row be
initialised to the values of the row before it, because usually all of
the Things in a collection had most of the values the same. So I added a
Mimic(Thing thingToCopy) method to Thing which copies the properties of
thingToCopy to the instance which it is called upon (I wanted
specifically to modify the instance of EmptyThing, which creates a whole
new worry for me about the id==id equality test, but ignore that for
now). At which point I noticed [getting back on topic] that Money was a
reference type, and that setting this.amount = thingToCopy.amount would
potentially cause problems if I changed the quantity or currency of
amount.

So, back to Bruce's complex number, why did I originally code something
with obviously value-type semantics as a reference type? I like to think
that I'm reasonably conscientious and careful about this kind of thing,
and I've understood the difference for as long as I've been using C#. I
can only imagine that when I wrote the code, at the back of my mind, I
had the concept that value types were for optimisation of performance
rather than for representing things which really do have value
semantics. If I'd thought about it the choice would have been obvious; I
obviously didn't. Java developers must have to put up with not being
able to do this properly all time, .NET developers should be able to
make the right choice.

I'm slightly ashamed to say that I didn't change Money to a struct, I
created a new instance of money with the quantity and currency from the
instance I copied. I did this because I didn't want to track down any
other references to the class which relied on reference-type semantics.
I suppose the question this whole thing poses is whether the emphasis on
the function of value types has been skewed away from their role in
modelling a system and towards their use for performance purposes; have
we spent too much time arguing over whether or not scenarios induce
boxing when we should really have been thinking about whether an entity
was correctly modelled by a reference or value type? Also, I don't
recall any way of differentiating the two in UML; surely this is an
analysis decision, not a coding technicality?

What do you think?

Worth a new thread to discuss?
 
G

Guest

Actually, I think that it would unprofessional to comment on my style of
writing or language versus the actual content. That might make you an MUP,
and as you already figured out, UP stands for unprofessional.
Second, if you don't understand the content while others did then your
problem is not with me, it is in you, maybe you need more training sessions,
check it out.
Finally, learn to reply to the content or don't reply, unless you want your
name to be published every were and that would keep you holding your MVP!

This is my first unproductive post on any forum, but I couldn't help myself
because you've invited me to start hating you and I accepted it!
 
C

Cor Ligthert [MVP]

Adam,
Actually, I think that it would unprofessional to comment on my style of
writing or language versus the actual content.

Can you tell me where I wrote that in my reply to Kevin? I will be probably
the last one who not completely agrees about that with you. In fact it was
Kevin who did that.

My reply had nothing to do with your style of writing it had to do with the
fact that Kevin gave me the idea that he had not even read your message and
therefore was only trolling my reply to you.

In my opinion are there some things in the content of your original answer
that makes that probably not much people will read it after they have seen
this starting sentence.

AFAIK is C# the only language derived from C++.

I had read your message completely and had the idea that I understood
everything you wrote. I had the idea that most maybe came from your hart but
is not based on much investigation

Therefore I gave you the link to Wikepedi, I assume that you would not be
glad when I was only copying the content of that in a message.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top