C# and VB.Net?

J

Jon Skeet [C# MVP]

And the latter group typically don't adopt OO-principles. They still view a
class as some module you just put code and som Dims in, they keep on
concatinating strings, declaring their arrays, and don't get why an
ArrayList or a StringBuilder could ever be useful. The think in terms of
variables and don't get the 'reference on stack, object on heap' model and
can't undestand why passing a huge array to a method would be the bad thing.

I don't understand why passing a huge array to a method would be a bad
thing either though. Arrays are reference types - you're not passing a
load of data. What kind of problem are you thinking of?
 
M

Michael S

Mantorok said:
My good lord that's awful, the amount of patchwork being applied to the
already confusing language is just going to make it ten times worse.

I'll give you some more 'ammo' for your meeting:

1. Strict Option Off
You are allowed to turn explicit casting off. This was done to make porting
of VB6 code easier. Also why they gave the language AndAlso and OrElse. The
whole syntax is created for easy-porting-purposes. The problem is that
porting Object-Based code into Object-Oriented code is a dumb idea from the
start. Who would 'port' JavaScript into C++? You don't port stuff like that.
You re-write the code and only port (re-use) the idea and feature, not the
design.

C# was not designed for porting, but to be a clever language. I think it is.

2. No-mans land.
At my work we mostly do Java, C#, C++ and Delphi (which is not really a
no-mans land, as most Delphites knows C++ ).

I say mostly - as sometimes our customers wants and insists on VB.NET. And,
like the dirty whores we are, we are happy to supply such a perverted
service. We hide behind the old - The Customer Is Always Right, as not to
offend whores. =)

However, for projects written in C#, we can always call on a Java or C++
developer to help us out if we are out of girl-power. While having a Javait
in your code, not coding a property Count, but insists on writing a
getCount() method, things are not that bad. Atleast the code is dandy and
written in a good pace. And while it may take her some time before she
fathoms that why she can't seem to find a StringBuffer anywhere, not even in
System.Text, is that it is called StringBuilder in .NET. She might grunt a
bit and may need some help, but she gets the job done.

If the same girl was to venture into a VB.NET project she would be doomed.
How would she know that she can't use And but must use AndAlso to get her
if-statements to work. How would you tell her that there are no braces and
that 'for' meets 'next', 'if' meets a 'end if', while 'while' meets a
'wend'.

Actually, I've seen this happen. But it was a guy and not a girl. And he got
so mad he almost screamed at me in frustration - Get me out of this NOW, or
I'll RESIGN!

3. Visual Basic Sucks So Hard It Bends Light.
This is my E=mc^2 argument. I think VB.NET is a gravity-well. Not really a
black-hole as time doesn't really stop, but it slows down a bit, and as time
== money, it earns you less money. While I don't care so much about money, I
rather see it as doing more work for less result.

While a VBers (or Delphites, like myself) may always claim, - 'I write so
fast in my favourite language, you won't know the difference'; both basic
and pascal are verbose languages and you could go faster. Once you talk
Algol-style languages like C#, C++ and Java fluently, you are quite fast in
doing JavaScript for a browser also.

4. Cognition
Our brains are wired to grasp the world in the following order; type,
identity and value.
For the science of this, please use google. I've written several posts on
this here, so you could always google groups for my long (and quite funny)
example.

Anyways, here is a short example;

int i = 5; //type first, identity second and value last.

Dim i as Long 'Dim is useless, identity comes before type. What is it's
value?
i = 5 'Value is not in context with type or identity.

While few studies have been done and nothing proven (how do you prove this?)
our brains tend to work harder when we code basic and pascal, and spend less
energy when doing the algol-style coding our brains like. Wirth did it wrong
when he designed pascal, while Ritchie just happened to get it right. I
don't think any of them even gave it a thought.

Well, there you have another four reasons for staying away from VB.NET.

Happy Coding
- Michael S
 
G

Guest

Mantorok,
VB.NET is really a first-class member of the .Net family, although I do not
use it myself if I can possibly avoid doing so. I just don't like it anymore
now that I have C#.

The main issue I have with VB.NET is that it brings with it a lot of the
"culture" of the previous Classic VB mentality - and with that, the
sloppiness and potential runtime errors that can come with not setting Option
Strict and Option Explicit to "On" and extensive use of the
Microsoft.VisualBasic namespace - when the .NET Framework BCL proper already
has everything you need. In addition, you might want to mention to your boss
that unfortunately, the Microsoft.VisualBasic assembly is not marked
CLS-Compliant and this can cause problems down the road. I understand,
however, that this has been fixed in .NET 2.0.
--Peter
 
M

Michael S

M. Genuini said:
30 INPUT "CONTINUE ? <Y/N>"; Y$
40 IF Y$ = "Y" THEN GOTO 1O
50 PRINT "BYE BYE"

^_________^

LOL!

Yeah, I kinda expanded my code into exactly that, and got help by the
'teacher'.

He was so very cool. He was this lost nird-hippie-wannabe-left-overs who,
never really got over the political 70ies, and got hooked on computers to
escape from the horribly happy clueless elite 80ies.

Poor dude. And a great man. Sitting on his free time, learning a 8 year old
kid what a boolean is. And types.. X is variant, X$ is text and X# is
number. I guess most coders teach their kids this at even earlier ages
nowadays, but in 1982 this was pretty rare. Where would you even find a
computer in a poor suburb to Stockholm, Sweden in 1982? Bet my mom thought
he was molesting me or something *s*.

While growing up I saw him sometimes, like across the street or in a mall or
in the subway. We would just nod to eachother, but I never spoke to him.
Probably becuase while I learned to code, he became a drunk...

But I would like to meet him again. Guess I have a lot to thank him for...

Anyways, here is the cutie:

http://en.wikipedia.org/wiki/Luxor_ABC80

- Michael S
 
M

Michael S

Jon Skeet said:
I don't understand why passing a huge array to a method would be a bad
thing either though. Arrays are reference types - you're not passing a
load of data. What kind of problem are you thinking of?

My Bad!

I ment huge structs, in loops.

I re-wrote that part a couple of times and wanted to mention value/reference
and also boxing/unboxing. It was not any good, so I erased stuff to get rid
of complex examples, and I guess array just got there and I went along
continuing writing...

Thanks Jon, for making sure people get that passing arrays is not bad.

- Michael S
 
M

Michael S

New here so be kind... :)

We will be. You are most Welcome.
We only hurt veteran posters we know.... and Flamewarriors... and Trolls. =)
"Differences Between Visual Basic .NET and Visual C# .NET"
http://support.microsoft.com/default.aspx?scid=kb;en-us;308470

But with NET 2.0 this article is almost obsolete. And with 3.0 there will be
hardly none.
I've worked in VB6 since 1999 but since being involved in c# projects for
the past 3 years, my first preference is c#.

And so you get in here, posting a link updated in june on a legacy topic,
and then tell us you might have lost your brain since 1999, and then brags
about you getting your rationale back?

Great post!

- Michael S

ps.
Now Nicholas will spank me again for being an a-hole.

pps.
iWeb: I'm not really a bastard. Just trying to be funny. Welcome!
 
M

Michael S

Peter Bromberg said:
Mantorok,
IIn addition, you might want to mention to your boss
that unfortunately, the Microsoft.VisualBasic assembly is not marked
CLS-Compliant and this can cause problems down the road. I understand,
however, that this has been fixed in .NET 2.0.
--Peter

Nice Peter.

This is an important thing. More 'ammo' to Mantorok.

While C# is not CLS-compliant at all, for example being case-sensitive, C#
kinda inspire you to write good clean managed code.

VB.NET devs typically reference the Microsoft.VisualBasic namespace, which
(usually) involves COM and makes the code go out of specs by ISO and ECMA.

A C# dev may not conform to CLS; He might go high on crack, and name methods
with the same name, SoHigh(), soHigh(), SOHIGH(); but I think this never
happens.

C# devs tend to know that you shouldn't expose a public overloaded operator
in a public framework, as C++.NET devs knows they shouldn't sport
multi-inherited class as public.

CLS is not a problem!

I really don't think this CLS-thingy is a problem at all; as coders who know
their code will be used by someone else, typically takes more care in making
it good.

In the meantime, VBers are including stuff from the Microsoft namespace just
to get some VB6 feel into their coding, and by so, will never run on Mono.
While this is seldom a requirement and also seldom a problem, I still get
scared. Not for them doing it, but for not even care..

A reference to Microsoft.VisualBasic is for me a sign (proof) that the devs
are missing VB6 and would rather do that...

Put them on maintainance where they could do some serious (and important)
work, and not on development....

Just my thought.

- Michael S
 
J

Jason Newell

LOL @ "Visual Basic Sucks So Hard
It Bends Light".

I'll have to remember that one.

Jason
 
M

Mattias Sjögren

While C# is not CLS-compliant at all

CLS compliance is not a property of a language, but of the code you
write. You can write CLS compliant and non-compliant code in both C#
and VB.NET.

VB.NET devs typically reference the Microsoft.VisualBasic namespace, which
(usually) involves COM

Involves COM in what way?

and makes the code go out of specs by ISO and ECMA.

Are you saying that you shouldn't use any libraries that haven't been
standardized?

A reference to Microsoft.VisualBasic is for me a sign (proof) that the devs
are missing VB6 and would rather do that...

The Microsoft.VisualBasic assembly is implicitly referenced by the
compiler (because it implements functionality required by the
language) so you don't have a choice.


Mattias
 
M

Michael S

But with NET 2.0 this article is almost obsolete. And with 3.0 there will
be hardly none.

As you know specs by heart, wouldn't this be something you should write
about on your website.. Just an idea...

- Michael S
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

My good lord that's awful, the amount of patchwork being applied to the
already confusing language is just going to make it ten times worse.
Does anybody knows what DLinq in VB.NET looks like?
The syntax in C# is abstract, so who knows what the VB guys will invent to
express it :)
 
G

Guest

As Mattias mentioned, CLS-Compliance is not a "language feature", but a
feature of the code you write.

Some of the things the compiler checks:

Class and member names cannot differ only by case. For example, you can't
have one property named Counter and another named counter. This is important
for cross-language compatibility since VB .NET isn't case sensitive.

Overloaded class methods cannot differ only by out or ref parameter
designations.

Publicly exposed members cannot start with an underscore ( _ ).

Operators can't be overloaded

Unsigned types can't be part of the public interface of a class

My point was that unfortunately, although you can apply the CLSCompliant
attribute in VB .NET, the VB .NET compiler doesn't check for CLS compliance
(at least not in .NET 1.1).

However, I am not sure you must have a reference to the
Microsoft.VisualBasic asembly to write code in VB.NET, so long as you do not
use VB.NET language constructs that require it.

Peter


--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
 
M

Michael S

Jason Newell said:
LOL @ "Visual Basic Sucks So Hard
It Bends Light".

I'll have to remember that one.

Jason

Then I'm sure you'll love this:

http://www.ddj.com/documents/s=1503/ddj0001vs/jan00.htm

Anyways, at work I sit behind a huge whiteboard.

The rule is that anything written may be removed at anytime.

It's for brainstorming and may be used or abused in any way possible (except
humping it, I guess) as long as you clean the board when done (It's
perfectly white, so we really embrace that what you write, you clean up)!

Except for the upper right corner. That is my box. I sport the one above,
but also this:

- Linux Is Only Free If Your Time Is Worthless.

While this is getting less and less true, as Linux is getting 'freindlier',
we are still a small (but an important gang) surrounded by an army of
Java-devs. Now I'm talking about full fledged Java army using open source
whenever they can, and they sure don't care much for Microsoft.

But I defend my island, and some of them (the smart ones, I think) really do
wanna be in our projects...

Actually, things are changing I think. People get bored with J2EE after a
while with having Maving say no to a method +45 lines, fix that, and then
wait his/her turn for merging several kilometer long config-files with 'the
team'.

They go: - What? Tjeesus? What did you just do with that DataSet just now?
Drag and drop two tables, it understands the relation, you build a SQL query
by clicking, then call fill twice and call for typed childnodes. That's
pretty cool!

They can be pretty amazed at a Page_Load in ASP.NET line going:

string sessionId = Request["sessionId"] ?? "";

But when I talk about .NET 3 and LINQ they kinda get lost somewhere. Note
how Java1 and Delphi1 are both from 1995. Delphi managed to get from 1 to 7,
with major language-improvements, before going .NET. Poor Java is still back
at 1995 and the 1.5 version (my bad, it's the 5.0 version) still just fake
generics.

How will they keep up?

Happy Coding, I know I do!
- Michael S
 
M

Michael S

Mattias Sjögren said:
CLS compliance is not a property of a language, but of the code you
write. You can write CLS compliant and non-compliant code in both C#
and VB.NET.



Involves COM in what way?

I don't know. Do you?
Are you saying that you shouldn't use any libraries that haven't been
standardized?

Not at all. I just want to have a stab at VB whenever I can.
You must have seen that I'm not really worried of this.
The Microsoft.VisualBasic assembly is implicitly referenced by the
compiler (because it implements functionality required by the
language) so you don't have a choice.

I didn't know that.

But a funny thing is that I've seen a vb.net-coder, forced to do C#,
reference that namespace the first thing he did. But he's not the brightest
human in the world either, and makes for a poor example.

I think most people in this thread are very good at what they do, regardless
of language. What I'm trying to say is that *most* C# developers are more
interested in 'How It Actually Works', while *most* VB.NETers don't as much.

To turn the question on it's knees:

If you was forced to hire (and keep) 10 coders for a looong .NET-project
(management told you so), and you have 20 candidates fluent in VB.NET and
another 20 fluent in C#. But you are only allowed to intreview 12 of them.
Who would you call?

Did I make my point?
- Michael S
 
D

Doug H

Michael said:
4. Cognition
Our brains are wired to grasp the world in the following order; type,
identity and value.
For the science of this, please use google. I've written several posts on
this here, so you could always google groups for my long (and quite funny)
example.

Anyways, here is a short example;

int i = 5; //type first, identity second and value last.

Dim i as Long 'Dim is useless, identity comes before type. What is it's
value?
i = 5 'Value is not in context with type or identity.

While few studies have been done and nothing proven (how do you prove this?)
our brains tend to work harder when we code basic and pascal, and spend less
energy when doing the algol-style coding our brains like. Wirth did it wrong
when he designed pascal, while Ritchie just happened to get it right. I
don't think any of them even gave it a thought.

Uh, dude, you don't know what the hell you are talking about here. You
don't have a clue about cognition and reading.
That is seriously the worst understanding of cognition and misreading
of cognitive research I have ever seen.

There is research in _computer science education_ (not "cognition")
finding that verbose english-like programming languages aren't
necessarily easier for beginners, but they aren't worse either. Just
like there is actual research showing that "==" vs. "=" is a common
source of errors with beginners, as well as case-sensitivity.
VB.NET is clearly designed to lower the learning curve and be easier
for beginners to pick up. It isn't perfect, but it is much better
designed than C# for beginners at least.
 
M

Michael S

Ignacio Machin ( .NET/ C# MVP ) said:
Hi,


Does anybody knows what DLinq in VB.NET looks like?
The syntax in C# is abstract, so who knows what the VB guys will invent
to express it :)

Very much the same.

All I know is that VB.NET will have the 'select' come before the 'from'
part, just to look more like SQL.
The C# team thought that this would kill the purpose of intellisense. How
can you select from what? where? grouped by? having? ordered how?

Again C# team shows their knack for reality: - SQL is weird, let's do
better, while intact, and give good support to Visual Studio!

The VB.NET team goes: This is not what they are used to. We think our gang
of coders can't learn new things. Let's drop intellisense on the select and
at least they may feel at home. Most of our coders are near braindead
anyways, and use arrows- and page-up/down for one line of code; - They won't
mind...

C# ---->

<----- VB

- Michael S
 
G

Guest

I misspoke.

Even if you remove the references / imports from the .vbproj file, a look at
your test class in Reflector will reveal that, indeed, a dependency on the
Microsoft.VisualBasic assembly has been magically re-created by the compiler,
whether you want it or not. So, its actually worse that I originally stated
from a CLS-Compliancy point of view. Mattias was correct.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
 
M

Michael S

Uh, dude, you don't know what the hell you are talking about here. You
don't have a clue about cognition and reading.
That is seriously the worst understanding of cognition and misreading
of cognitive research I have ever seen.

If you say so, dude!
There is research in _computer science education_ (not "cognition")
finding that verbose english-like programming languages aren't
necessarily easier for beginners, but they aren't worse either. Just
like there is actual research showing that "==" vs. "=" is a common
source of errors with beginners, as well as case-sensitivity.
VB.NET is clearly designed to lower the learning curve and be easier
for beginners to pick up. It isn't perfect, but it is much better
designed than C# for beginners at least.

Oh, but I'm not talking about newbies..
If you are new to things, you think everything is weird and you need help.

I'm talking about people going to work for 8-10 hours a day and try to fix
someone elses code.
You might take a look at what R did with B before they did UML with I....

What Wirth thought when he designed pascal...

dude, please tell me if I am wrong! But don't dismiss me for being a fool. I
am not!

- Michael S
 
J

Jon Skeet [C# MVP]

Michael S said:
As you know specs by heart, wouldn't this be something you should write
about on your website.. Just an idea...

Possibly. However, I disagree with your assertion (if I understand it
correctly) that C# 3.0 will be the same as VB 9.0. Having converged
somewhat, the languages are likely to *diverge* significantly in the
next release or two.
 
J

Jon Skeet [C# MVP]

Peter Bromberg said:
As Mattias mentioned, CLS-Compliance is not a "language feature", but a
feature of the code you write.

Some of the things the compiler checks:

Class and member names cannot differ only by case. For example, you can't
have one property named Counter and another named counter. This is important
for cross-language compatibility since VB .NET isn't case sensitive.

Not quite: *public* class and member names cannot differ only by case.

For instance:

using System;

[assembly:CLSCompliant(true)]

public class Test
{
public static void Main()
{
}

static void main()
{
}
}

compiles fine. Make main() public and you'll get a compiler warning.

<snip>
 

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