Why should "I" use C#

~J~

~J~

Soldato
Joined
20 Oct 2003
Posts
7,558
Location
London
Right, bit of pride swallowing here, but I'm an open minded kinda chap so here goes.

As well as having a full time job (or did have!), I have also worked for myself for the past 15 years. Got a great customer base, they come back for more, and every project has been developed in VBA or VB/.Net. VBA has used the Access backend, VB/.Net projects have used SQL Server.

NEVER had a days complaint, they've worked as required when gone live, I get paid, brilliant.

Yesterday however I was approached by a new potential customer. Their requirement was simple, but they probably won't use my services because their project wasn't going to be coded in C#!

Despite my fair discussions with them, querying them as to why it was so important, the meeting ended with them saying that they have heard so many 'bad' reports of VB.Net that they want a C# coded project or nothing at all!

So...

Why C#? I'd like somebody to give me SENSIBLE answers as to why I should take the week off and learn C# a bit more. I can 'get by' (loops, clauses, methods, etc.) but would need to reach for the manual on things like threading, data calls, etc.

I won't accept "It's a better language", because that's rubbish. 15 years writing software in VB with happy customers and a healthy bank balance will not reflect that. And despite the thoughts of people with **** all knowledge of the industry and a years dabble with it in College/Uni and touting it because it's fashionable it just will just not work with me!

OOP I won't accept, because .Net can handle it beautifully.
Unsafe variables I won't accept, because BY DEFAULT this is now a part of VS2005.
It's easy I won't accept, because everything has a learning curve.

But what I want to know, in a nutshell, is why C#?

Does it make faster executables?
IS there somewhere in it that makes errors/bugs less likely?
Does it open up something like COM that I'm unaware of, therefore making 3rd party addins access the libraries?
Are classes, modules, compiled more optimal?

I'm intrigued?


(PLEASE DO NOT TURN THIS INTO A VB v C# FIASCO)
 
The fact you can only just manage loops, multithreads and other relatively basic operations indicates you don't actually know an awful lot for someone with 15 years experience.. but anyway.

I don't use C#, but my colleagues do. They tell me the resource management is miles better (in terms of efficiency), and the general syntax (accessors etc) is much more friendly and pleasant to use.



P.S. "unsafe variables" is a major indication you don't know anything.. every variable is "unsafe." I don't give a monkeys bum if it's come from VS2005 or from a flat file, it is unsafe, period - every developer worth their salt knows this and does not rely on some IDE to make it "safe"
 
Last edited:
Well the "Get by with" comment was actually referring to C#. Considering C# is only 7 years old, then it's impossible for me to have 15 years experience with it!! Although I do admit, perhaps I didn't make that clear.

The "Unsafe Variables" bit I just think you're been pedantic for the sake of it. There's always an argument on this forum about how C# you can't, for an example, use A=10 without specifically declaring what A is. On VB.Net you can if STRICT is turned OFF.

Not the best reply really is it?
 
The fact you can only just manage loops, multithreads and other relatively basic operations indicates you don't actually know an awful lot for someone with 15 years experience.. but anyway.


I think he meant he knows enough to 'get by' in C# - I assume his VB knowledge is far greater.
 
P.S. "unsafe variables" is a major indication you don't know anything.. every variable is "unsafe." I don't give a monkeys bum if it's come from VS2005 or from a flat file, it is unsafe, period - every developer worth their salt knows this and does not rely on some IDE to make it "safe"

Forgive me if I'm being ignorant but surely if the variable is managed and type safe how can it be unsafe?
 
Because you won't know what's in it? What else could be determined by "unsafe"?

Unless, going by the replies, you mean type strict, then that's a laughable discussion full stop.
 
So, DJ_Jestar, let me give you an example then:

I've just finished a program in VB.Net than attaches into a CNC device and monitors parts scanned (via RFID), saves this unique identifer into a database, and continues until the entire manifest is complete, which then prints a packing note, retrieves the next incomplete job and continues.

So are you really saying that for me to learn:

COM Port reading
Dataset handling
Printing

Would take me an hour to learn? Or are we talking an hour per area?
 
C# or VB a question I hear often. Is C# better, nope, but plenty of elitists think it is. I'm currently a VB developer and me and another colleague are thinking about moving to C#. Why do we want to move to C# because there's seems to be a lot more call for C# developers.
 
C# or VB a question I hear often. Is C# better, nope, but plenty of elitists think it is. I'm currently a VB developer and me and another colleague are thinking about moving to C#. Why do we want to move to C# because there's seems to be a lot more call for C# developers.

There is, but what I can't fathom out is just WHAT the major difference, advantages are! The only thing I can see is that the syntax is more like C/C++/Java which means someone coming from those backgrounds would find it easier to migrate into C#.

I can't see any other practical advantages at the moment other than it's new and people are wanting work done in it. Question is - why?
 
C# or VB a question I hear often. Is C# better, nope, but plenty of elitists think it is. I'm currently a VB developer and me and another colleague are thinking about moving to C#. Why do we want to move to C# because there's seems to be a lot more call for C# developers.
Yeah, I've been a VB/ASP developer for the last 8 years and moving over to .NET I'm looking to get in to C# for two reasons.

Firstly, because there are far more positions available for C# development and secondly because, after talking to a friend in recruitment, C# developers command a 3-4K premium over VB devs.
 
I can't see any other practical advantages at the moment other than it's new and people are wanting work done in it. Question is - why?

I can't see any advantages. One advantage from a company might be if they develop an app in C# and two developers leave, it will most likely be easy for them to get someone in to replace them. Remember managers, etc love new buzz words and C# along with .NET are the buzz words at the moment so they think it must be wonderful.
 
I can't see any advantages. One advantage from a company might be if they develop an app in C# and two developers leave, it will most likely be easy for them to get someone in to replace them. Remember managers, etc love new buzz words and C# along with .NET are the buzz words at the moment so they think it must be wonderful.

I agree 100% with you, the only advantage I can see is it's the latest craze. Like I said, I'm going to swallow a lot of pride and keep an open mind on this one, and open to listen to any 'sensible' reasons.

If I was getting into the business, I certainly can see an advantage of having it under my belt, because as you said, it's new, managers love it, it's a buzz word, so will employ people with the skill.

But once you're in the industry, doing what you do best, proving your worth, what advantage does it have (other than moving employer) over VB.Net?

If it produces quicker executables, then I'd say that was it. If it produced smaller code, I'd point at that. And if someone said "Do a full SOP system in a week" and VB.Net took 1000's of lines more code, dozens upon dozens of testing to ensure it was bullet proof, and C# had controls that had, say, a mask input on every text-enabled control, brilliant garbage collection and no need to create data adapters then I'd point at C# and say "You rock".

But I just don't see a practical advantage at the moment.
 
The fact you can only just manage loops, multithreads and other relatively basic operations indicates you don't actually know an awful lot for someone with 15 years experience.. but anyway.

I don't use C#, but my colleagues do. They tell me the resource management is miles better (in terms of efficiency), and the general syntax (accessors etc) is much more friendly and pleasant to use.



P.S. "unsafe variables" is a major indication you don't know anything.. every variable is "unsafe." I don't give a monkeys bum if it's come from VS2005 or from a flat file, it is unsafe, period - every developer worth their salt knows this and does not rely on some IDE to make it "safe"


The IDE doesn't make it safe. The fact that the CLR manages the memory allocation, casting , type and garbage collection makes it safe. This is regardless of where the code was written. Unsafe code in c# is regioned with an UNSAFE directive. VB.Net on the otherhand cannot have unmanaged code, although it can use pointers.
 
Last edited:
I was always under the impression that .NET code got compiled down to the same quasi-interpreted, sort-of-machine-language thing. The reason MS has several languages you can use with .net (VB.NET, C#, C++.NET) was to allow the widest possible range of devs to be able to pick up .NET and start using. VB guys could use VB.NET, java guys could use C# and c++ guys could use C++.

In the end, I think it all gets compiled down to the same thing. I don't beleive code runs faster if you write it in C# .net over VB.NET or vice-versa.

There are some minor differences - I'm a c# guy and I believe that calling the win32 api is a little easier in C#, but that dosen't mean it's not possible in VB.NET. Therefore, in my opinion, if you know VB.NET fairly well, there is zero point in learning C#. It does exactly the same job in the same way, but has the added disadvantage of not being as familiar. If, however, you wanted to learn Java, but didn't want to change everything at once, C# would be a useful stepping stone of learning about the syntax of java-like languages whilst keeping within the whole .NET way of doing things...

Someone who knows a lot more may come along and squish all that though :)
 
Thanks growse, the kinda response I was looking for :)

Any chance you can give a quick example on calling the WIN32 API so I can see what it's like in C#? VB.Net is a bit 'messy' when it comes to that.
 
I was always under the impression that .NET code got compiled down to the same quasi-interpreted, sort-of-machine-language thing. The reason MS has several languages you can use with .net (VB.NET, C#, C++.NET) was to allow the widest possible range of devs to be able to pick up .NET and start using. VB guys could use VB.NET, java guys could use C# and c++ guys could use C++.

In the end, I think it all gets compiled down to the same thing. I don't beleive code runs faster if you write it in C# .net over VB.NET or vice-versa.

There are some minor differences - I'm a c# guy and I believe that calling the win32 api is a little easier in C#, but that dosen't mean it's not possible in VB.NET. Therefore, in my opinion, if you know VB.NET fairly well, there is zero point in learning C#. It does exactly the same job in the same way, but has the added disadvantage of not being as familiar. If, however, you wanted to learn Java, but didn't want to change everything at once, C# would be a useful stepping stone of learning about the syntax of java-like languages whilst keeping within the whole .NET way of doing things...

Someone who knows a lot more may come along and squish all that though :)

.NET has a JIT compiler, and IL is the quasi-interpreted, sort-of-machine-language thing :)
 
Thanks growse, the kinda response I was looking for :)

Any chance you can give a quick example on calling the WIN32 API so I can see what it's like in C#? VB.Net is a bit 'messy' when it comes to that.

It's quite easy, you just put in the signature of the method you want to use:

Code:
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
internal static extern IntPtr SetWindowsHookEx(int idHook, LowLevelKeyboardProc lpfn, IntPtr hMod, uint dwThreadId);

and then you call it:

Code:
IntPtr wibble = SetWindowsHookEx(0,pop,hWhat,0);

Easy :)

http://www.pinvoke.net is a useful site for giving you what the signatures are for various methods :)
 
If you can code properly in VB.NET you can code in C# given a few days to get used to the syntax.

There really is very little difference. Things you mentioned earlier such as COM Port reading, Dataset handling and Printing are all done the same in C# as in VB.NET except the commands use C# syntax.

That stuff is all based on the libraries in the .NET framework, which is used exactly the same in C# as in VB.NET.

Your client's concerns seem unfounded for a good VB.NET developer. I can understand their concerns as there are some VB.NET developers out there who migrated from VB6, weren't good VB6 developers and have little idea about OO.
If you are competent then VB.NET or C# makes no difference.

That said I don't understand your problem with learning C#, if you are a good VB.NET developer you will pick it up in no time and it makes you a more valuable commodity.


EDIT: If they really are insistent on C# the just code it in VB.NET and use this... http://www.elegancetech.com/CSVB/CSVB.aspx :p
 
Last edited:
If you can code properly in VB.NET you can code in C# given a few days to get used to the syntax.

There really is very little difference. Things you mentioned earlier such as COM Port reading, Dataset handling and Printing are all done the same in C# as in VB.NET except the commands use C# syntax.

That stuff is all based on the libraries in the .NET framework, which is used exactly the same in C# as in VB.NET.

Your client's concerns seem unfounded for a good VB.NET developer. I can understand their concerns as there are some VB.NET developers out there who migrated from VB6, weren't good VB6 developers and have little idea about OO.
If you are competent then VB.NET or C# makes no difference.

That said I don't understand your problem with learning C#, if you are a good VB.NET developer you will pick it up in no time and it makes you a more valuable commodity.


EDIT: If they really are insistent on C# the just code it in VB.NET and use this... http://www.elegancetech.com/CSVB/CSVB.aspx :p

Good post :)

As said, there aren't really many (if any) practical advantages in switching to C#. I personally prefer C# because I find it much nicer to program in and it has a few more features which can be useful (anonymous methods are a big one for me... I was shocked when I discovered VB.NET didn't support them :p ).

Your customer seems just to be misinformed about VB.NET and C# and how they relate to each other; they have (almost) identical feature sets, compile to the same intermediate code, are developed in the same IDE, have the same libraries, and both run under .NET's CLR. The only real difference between them is the syntax and the small number of features that C# has that VB.NET doesn't (and vice versa).

That said, however, since they're so similar, you could very easily learn C# if you are that experienced with VB.NET. Since the biggest task in most languages is not learning the syntax, but learning the libraries, feature sets and idiosyncrasies of the language (which are identical in C# and VB.NET), it'll take no time at all.

It'd probably be worth learning C# since it'd be so easy for a VB.NET developer and, as Haircut said, it would make you more versatile in what you can do. It's also generally held in slightly higher regard by many people, and has the added advantage of being Microsoft's flagship language for the foreseeable future.

Basically, it's up to you, but I'd go for it just because it'd involve so little effort and it's worth knowing as a language.
 
Last edited:
Back
Top Bottom