Software Development

My move from VB.NET to C#

Justin James confesses why he stuck with VB.NET for so long rather than moving to C# and reveals how life has been now that he's taken the plunge.

Over the last few years, I've been ashamed that I stuck with VB.NET rather than moving to C#. I know... it is completely irrational. To be frank, I never could justify moving to C#.

C# simply did not have any features that VB.NET did not have that I needed -- until the release of .NET 3.0. With that version, C# had LINQ and closures, and VB.NET did not; this was corrected in .NET 3.5 and Visual Studio 2008. Well, I've now made the jump.

Why I took the plunge

In December, I started a new job and a new project. (Ironically, my new employer is a VB and VBA shop that is making the leap to VB.NET.) The project isn't terribly fancy; it involves making modifications to a CMS system that we have licensed. It's written in C#.

Don't get me wrong -- I've been able to read C# for years. The .NET documentation has all samples in VB.NET and C#; lots of magazines use C# for examples, and so on. It helped that I worked with Java from 2001 – 2002, and I have tons of experience in other C-style languages. However, I didn't feel knowledgeable enough to actually write anything in C#. After all, modern mainstream languages are a lot more in-depth than older languages; the breadth of operators, constructs, etc. in C# is many times what C, Perl, Pascal, etc. have. (There is a reason why I think it's tough to become a programming expert!)

At a certain point, I began to feel bad about not using C#. In my experience, the more experienced .NET developers highly favor it; I felt left out of the Big Boy's Club. Additionally, I would recommend C# to people and yet not use it myself even though I saw some advantages to it over VB.NET. How hypocritical! Plus, it seems like most high-class programming publications almost exclusively use C#. In fact, I can't remember the last time I saw VB.NET exclusively in a publication. So while I couldn't justify the move, I felt a bit guilty about it.

Getting my feet wet

So now I have made the jump. I would love to be able to say that I read a great book and wrote a recipe organization application, but that would be a lie. I learned it by rolling up my sleeves and getting dirty. It took me a day or two to get used to the transition. Once in a blue moon I will do something dumb, usually involving a quotation mark (a C-style language that uses double-quotes strings feels wrong to me). But over all, it was not too bad.

The really sad thing is that I know I am good at learning new languages. I learned VB.NET on my own in an hour or two; I learned Perl by staring at some code for 30 minutes, and so on. I don't know why I kept putting off moving to C# -- maybe I am getting too old, and I feel like I've lost my mojo, or maybe it is the lack of time. Whatever the reason, I sure came up with a lot of excuses.

If you doubt whether you can move to C#, you can do it. C# is no more complex than Java, and it only feels more complex than VB.NET because it uses symbols where VB.NET often uses full words. The hard part is learning the .NET Framework. Conceptually, VB.NET and C# are very similar; they are statically typed (assuming you turn on "strict" and "explicit" in VB.NET like you should), compiled, object-oriented languages. Both VB.NET and C# support nearly identical feature sets. And if you have any familiarity with a C-style language (particularly Java), you will feel right at home.

So come on in… the water's fine!

J.Ja

About

Justin James is the Lead Architect for Conigent.

135 comments
cartmit
cartmit

"VB.NET and C# are very similar; they are statically typed"

rtorres
rtorres

C# is to fancy for me with its curly braces, VS doen't even put them for you. I tried it and can't get used to it at all. Anyway they both work the same under the same roof (.NET Framework).

techrepublic
techrepublic

It's about time! Glad you didn't just "get your feet wet" but decided to just "jump right in" the deep water. Welcome to "The Big Boy's Club"! :-D

george-barna
george-barna

"Learnt VB.NET in an hour or two..." Yeah....right :-)

gna10.10.1986
gna10.10.1986

I am not a very experienced programmer. I have learned C++, Java, and VB.NET. This article made me think of C# as something I want to start learning!

mental
mental

You learned Perl in 30 minutes? Hah-hah-hah-hah! You're a huge blow-hard, bald-faced liar.

lianne.franklin
lianne.franklin

What about the move from C to C# ?? I have been programming in C & ESQL/C for many years, and recently Perl, but never C++ or Object-Oriented programming styles. I need to quickly come up to speed in OOP, C++ and C# on a complex assignment. Any recommendations on books?? I'm about to register for an online course -- Introduction to C# programming, offered by University of Waterloo. Any other recommendations would be very much appreciated!!

setivi
setivi

2 hours to learn C#? That's too much of self aggrandizement. It's just like saying you got computer science degree in 1 year. Get off the pot!

Jaqui
Jaqui

since I do NOT have the .NET framework available to start working with it. [ for starters ] since the .NET framework is bloated as all hell and should not be used until that is fixed. since I only use open source and C# is proprietary. [ as is Java, VBA, VB.NET and just about every other language you named. ] yes, Sun still has the core of the Java language as proprietary code base, making it a no go as far as any TRUE open source user is concerned.

sborsher
sborsher

I was just about to start looking into writing a C++ call compatible dll in VB, wrestling with all that casting; but this article has changed my mind into just diving into C++. Very timely. Thanks.

brian.kiser
brian.kiser

When I read statements like, "I learned Perl by staring at some code for 30 minutes", I can't help but laugh. To real programmers, this sort of statement is pretty funny, because we know how long it takes to really learn even the fundamentals of a language. It varies, but it's a lot more than 30 minutes for just about anyone. :)

Justin James
Justin James

I can't vouch for earlier versions, but VS 2008 is just as happy to put curly braces into C# as it is to put any other language construct into VB.Net. J.Ja

Justin James
Justin James

If you already know C++ and Java, the ideas and syntax will feel familiar, and if you already know VB.Net, you already know the .Net Framework. You should be fine with C#! J.Ja

Justin James
Justin James

Let me put it this way: if you are already familiar with C-style languages (as I was), and was looking at a decent Perl program (as I was), then yes, you can learn enough Perl in 30 minutes to start to maintain and extend that program (which is what I did). Sorry if you don't beleive me. J.Ja

Tony Hopkinson
Tony Hopkinson

already. C# syntax isn't going to cause you any real problems. Managed code, OO, windows event model.... See if you can get an OO book though, or maybe a a bit more of a novices's book on C#. I thoroughly recommend a NET framework book as well, otherwise you'll be swimming through a sea of jargon. Something that no one told me when I moved from DEC C to Delphi on windows about OO, is it essentially codifies good design practices, such as encapsulation. When you learn it, you almost get the impression from some it sprung new made from Zeus' head or something. It didn't it came out slightly cleverer (and much less busy :D ) C coders who thought there's got to be an easier way than this....

Tony Hopkinson
Tony Hopkinson

Emabarassing, I mean like what took so long? If you already knew C, and C++, were familiar with things like closures and lambda functions, could already program and you knew the .net framework, what's left to learn? C# didn't cause me any problems at all, still bumping into my .NET ignorance, but the thing is so big, I doubt that will change.

alaniane
alaniane

about learning the syntax of the language and not all the intricacies of the language. It took me less than a week to learn how to write basic Cobol programs; however, I have yet to learn all of the intricacies of Cobol. It's easy to learn that a Cobol program is divided into four major divisions and where and how to declare the variables to be used in your program, but knowing how to write Cobol on a particular platform or how to access particular libraries requires more time to gain experience. That's why I don't consider myself a Cobol programmer even though I've written some programs in Cobol and I know how to read a program written in Cobol.

Justin James
Justin James

I've been working in C-style languages for years, including a year with Java which is conceptually and syntactically quite similar. I've been *reading* C# for years in help files, magazines, and so on. 2 hours from "sitting down with existing source code, having never written a line of C#" to "effective at extending and writing new code in a basic manner" is quite reasonable under those circumstances. J.Ja

SnoopDougEDoug
SnoopDougEDoug

Since you never used VB in the first place, why the rant? You seem to post this in every thread where any Microsoft product is discussed. You absolutely have the right to not use any product you wish. I'm just tired of the negativity when most of us are trying to learn something. doug

Justin James
Justin James

How did I know you'd have a response like this? :) Actually, C# does not have to be proprietary, there are open source implementations of it (Mono), but even then, I know that your language preference doesn't go in that direction anyways. J.Ja

Justin James
Justin James

Brian - I have to disagree. If you are familiar with a C-style language, staring at some code in a different one is sufficient to be up and running at a basic level of competancy. Will you understand it like an expert? Nope. But if your goal is to maintain existing code, maybe add a few simple routines in, etc., yeah, 30 minutes is enough to get you going. I should have qualified that statement with, "to the point that I could maintain and extend code". I certainly do not think that 30 minutes to a few hours is too little time to reach that level of competancy is *most* languages for an experienced programmer. Of course, some exceotions will always be out there... C, despite the simplicity of its design, is hardly self-explanatory (let alone self documenting), and requires concepts which are not easy to glean from looking at it. Likewise, assembly works at a level that is too foreign to most programmers for them to "get" it just by looking at it. There are plenty of other examples out there (any functional language comes to mind, Python) too that we can think of. But again, that time frame is more than enough for a decent programmer to pick up VBA/VB.Net/VBScript/SB 6, or Perl/PHP (practically the same language), or JavaScript or Java/C# (very similar), or Pascal/Delphi. In fact, the only big leap there is for a strictly VB/BASIC person to look at C-style, simply due to the use of semi-colons as statement delimiters, and the heavy usage of symbols instead of words. J.Ja

mbundy
mbundy

I too am getting tired of comments like this. I have been programming over 30 years and still get stuck on little things for days, much less learning an entire language in 30 minutes! When I read things like this I disregard the entire content of the message.

Izzmo
Izzmo

more like 35 minutes.

lianne.franklin
lianne.franklin

I believe you... Learning perl is very easy if a) you know C, and b) you have existing sample programs. And I guess if c) you have the O'Reilly Programming Perl book (although their examples are pretty lame). It depends on what you're trying to do. I wrote my first perl program very quickly, but it wasn't too complicated, and perl was well-suited to the task. Since then I've made some significant extensions in amazingly small amounts of time. I love it!!

jslarochelle
jslarochelle

I used "Pro C# 2008 and the .NET Platform" (APRESS). It is not perfect and it is a large book (1331 pages) but it covers the .NET framework basics fairly well. The chapters on "Building Multithreaded Applications", "Understanding CIL and the Role of Dynamic Assemblies", ... If you have programmed in other languge the main obstacle is the .NET framework (the platform) not the C# syntax. JS

Justin James
Justin James

Tony's completely right about this. Most books *do* assume OO knowledge, and a lot of that is because in the last 10 or so years, just about every school started teaching OO, and the majority of non-VB coders (important qualifier there) already moved to OO before C# was released. The C# syntax will feel a bit less complex, due to not having to deal with pointers, and the code will feel a touch "vacant" because you won't be sticking "malloc()" everywhere. The .Net Framework itself is where the real learning occurs for *most* programmers working on "typical business applications". I really can't speak to any books per se, I tend to jump right in with writing code and hitting F1 as I get stuck, but that is a really bad way of learning conceptual concepts like OOP. J.Ja

Justin James
Justin James

... up against a few silly little things, really. Like trying to figure out the practical difference between "int" and "System.Int32" (none), and such. The "==" threw me too a number of times, and learning to NOT use ' for string quoting like I expected was odd. But yeah, 2 hours it was to really get moving with it. J.Ja

Justin James
Justin James

It all depends on what you mean by "learn". In some ways, I was *still* "learning" VB.Net when I switched to C#, many years later. I am sure that years from now, I will still be learning aspects of C#. Things like the details of inheritance in certain circumstances, or the particulars of partial classes, or how to use anonymous methods in certain areas that I have been using delegates for, and so on. But to sit down and write the code that I need under typical circumstances? Yeah, 2 hours is about right. J.Ja

DukeCylk
DukeCylk

You know, I know this whole conversation is really pointless as people will do what they will do, and the fact of the matter is that there are ten fold more programmers and developers than there were ten years ago, and the same can be said for the previous decade (at least I think so, if you count all the poeple who aren't really programmers but are probably just executive assistants and coordinators and teen agers and hacks like me), and the fact of the matter is that alot more developers and content are needed, hence all the free development software. My point is that VB .Net is not going away as some suggested above, and I can find more examples of any type of code you can imagine in VB. Finally, I have yet to find a place where I absolutley needed to use a different language other than VB - as in could not be done. And I can look at any C# code and quickly figure out how to do it VB - maybe not the exact same results, but I can get the results my customer needs. This is a funny conversation; it just won't go away. I remember being made fun of some 7 years ago by some hard core C guys and was told if I needed that type of Visual IDE that I should be using a real programming language like Delphi...whatever, I'm sure Delphi is a good language and has a great following, but its following, right or wrong, pales in comparison to VB. I see no logical reason other than appeasing a customer or just being able to say to someone who doesn't know any better that I can program in C# so that they will retain my employ. If you can do it in C#, I can do it in VB.

Jaqui
Jaqui

is that it is maybe just beginning to support .net 2.0 last time I looked at it, a 4 hour battle to install it and it still was not functional. and mono is the clone of VB rather than a .net clone. so until MS releases the sources for the entire .NET framework, it's a no-go for me.

a69105
a69105

I think what you meant to say was that you "spent 30 minutes learning some Perl", not that you "learned Perl in 30 minutes" You're shallow technical babble is transparent to those of us who are actually in the "Big Boy's Club" that you speak of - and trust me, you are very far from making it, and probably not even of the proper material in the first place. Your follow up statement, including the assertion that PHP and Perl are practically the same language, doesn't help your case, but only further exposes your gaping ignorance, at which the wise would suggest that the pupil talk less and listen more, but except for the fact that apparently it's the ignorant neophytes who write the articles on Tech Republic.

Justin James
Justin James

Yeah, the .Net Framework is a monster. It's helpful. It's great. But it's a monster. I've been using it since 2002 and I am constantly learning new items in it. That being said, C# is a fairly deep language once you start peeking into the corners of it. I think that once you get to the point where you are working with delegates, anonymous functions/classes, closures, etc. on a fairly regular basis, it means that you turned some sort of corner where you are not just using it to glue items from the Framework together, but you are actually writing code of your own. Another landmark event, implementing IDispose. I didn't touch IDispose until a few years ago, because I wasn't doing anything that major. Now I use it on a regular basis. Implementing the default enumerators is another good example of things that separate someone writing "glue" code and someone writing a lot of fresh code. It's when you start peeking into these dark corners of functionality that you realize how deep a language it. Some languages just don't have this level of detail. Indeed, some of the most powerful languages out there, like Lisp and Smalltalk, are powerful *precisely* because it takes very few language features to get work done. I may explore that topic in the future. :) J.Ja

jslarochelle
jslarochelle

...out there for the language agnostic to capitalize on. For example many of the title in the "Head First" collection use Java. The "Head First Pattern" is a perl. It really teaches the most useful patterns in a way such that you will remember them and know how to use them. I'm evaluating the Head First "Object=Oriented Analysis & Design" book to see if we could build a course based on it at work and so far I think it is really good. This point is also true of other languages. For example one would be crazy not to read Bertrand Meyer's "Object Oriented Software Construction" because the language is Eiffel. Another example is concurrent programming (there is a lot of talk about multithreading these days). Doug Lea's "Concurrent Programming in Java 2nd Edition" is still one of the best book on the subject even if you are not a Java programmer because most of the language constructs are fairly easy to map from Java to CSharp (one exception being the volatile keyword). I guess the most important point here is that the biggest obstacles in moving to an OO language is not the language syntax but OOP and in the case of CSharp the .NET framework itself. - JS

Justin James
Justin James

Yeah, at $50 a book, I do not have a single IT book that I've paid for. I find their utility so limited so often that I won't spend my own money on them. Well, not entirely true. There are a handful of books which I found quite useful (O'Rielly's "HTML: The Definitive Guide" comes to mind), but I didn't have to pay for them anyways. those language/framework "Reference" guides feel too much like someone just printed the F1 documents, for example. A lot of other books are just screenshots with lengthy descriptions of the screens of all of the wizards & dialogs in the app. And too few books have any information on what to do when things go wrong, which is the time when I need help the most. :) J.Ja

Tony Hopkinson
Tony Hopkinson

But I picked up. C# 2005 and .NET 2.0 and they did the job just fine. There could be better books out there, but I've certainly had worse and usually they are my first port of call, for windows books. When you are talking $50 a pop, a book you can't use is irritating.

Justin James
Justin James

I have never been happy with a Wrox title, even before 2005. Maybe it's just the particular books I've tried to read. Overall, I feel like they don't give me anything that F1 doesn't, so I'd rather save the $50 and just hit F1. :) O'Rielly seemed to take a nosedive a while back, but the last few of their titles I have gone through seem to be back to their traditional level of quality. The only MS Press book I've read was their old book for the MCSE "Networking Essentials" course, which was an awesome primer on networking. J.Ja

Justin James
Justin James

Yeah, a Java tutorial, if it explains OO well, would be a good resource, good suggestion Doug! J.Ja

butchthechemist
butchthechemist

I have not been satisfied with most of the books I have purchased from Wrox press since around 2005. I go with an O'Reily Learning XXXX Title first, or even something from MS Press. I don't even consider Wrox titles anymore.

Tony Hopkinson
Tony Hopkinson

The thing is if you buy any intermediate to expert refence on these languages, OO is a given. They'll explain how to do polymorphism in X but not why or even what it is. Many moons ago when I switched to Delphi, I got OO pretty quick, but OO was sort of new then. The windows event model though, which was a given in the books, took me 'ages' to pick up, as most of my work had been main frame batch processing.

Tony Hopkinson
Tony Hopkinson

I nearly wrote an XML parser, ffs ! A good .NET rule, if it's a fairly basic everyday generic operation, it's in there. Can be a bit hard to find from the help on occasion. A decent book (WROX would be my pick) to get a sense of it, will help you ask the right question, here, google or of F1.

SnoopDougEDoug
SnoopDougEDoug

I almost think an 00 newby would be better off starting with Sun's Java tutorial. After all, the basic languages are very similar. Once you get past the IO section, switch over to using C#. Don't forget you can download a free version of VS2008 for C# from Microsoft. I install it on all of my other computers in case I want bang out some code on other than my main dev box while it's doing a build. doug

Justin James
Justin James

You think mixing Pascal and C# is bad, for a while I was working with VB.Net and VBA on the same project. The "elsif" thing kept killing me, and the utter lack of a "contains" method on VBA collections infuriated me to no end... J.Ja

Tony Hopkinson
Tony Hopkinson

Often at the same time if (a=b) then { b := 1; } :( :( Braces and, remembering empty parentheses for method calls with no parameters. Delphi is name then type in a declaration.... That stuff I consider trivial, though possibly because I've done a fair bit of coding in two languages. Try doing Fortran and VB6 side by side, with the occasional foray into Perl, that will sort you out. If you switch regular and often you can keep it straight in your head, though obviously you'll be a bit slower. Trying to concentrate on one then other, seems to actually make you less productive, because the syntax goes on auto pilot and then you find you've just invented Deltran or somesuch.

Tony Hopkinson
Tony Hopkinson

where are my screen wipes. ROFL I did some QuickBasic once upon a time and a fair bit of Turbo Pascal. Delphi was my tool of choice until I picked up C#.

stempy
stempy

Such as Unload, and End. I think I preferred Turbo Basic to VB6

Tony Hopkinson
Tony Hopkinson

of a garbage collector as far as I understand it. Even more aptly named than the one in .NET. Variants are OO, well I've seen very bad OO in other places so maybe... As far as I know the only threading you could do in VCB6 was by creating a COM object and instantiating it in another thread capable environment. No language support for it whatssoever. A colleague of mine more comfortable with VMS, shouted me over one day, He'd written a little utility in VB, and his application refused to close. It kept popping up you must do this before you close dialog. He was instancing a class, and then calling various of it's methods from the GUI. In most of the logic paths, it set the instance to nothing. Others set the Done property to true. In the OnCloseQuery handler, he checked the Done property of the instance....

jck
jck

i can understand about the built in components...not all that great. But, did VB6 actually have "garbage collection" in MS terms? I thought that was an implement of .NET. And, I thought you could do thread control in VB6 SP6. Again, I may be wrong. I only ever did threading in VC++5. Yes, Variants were bad practice. But, a variant was just an overloaded generic variable class. It was OO!! lol The worst thing about .NET that ever occurred was MS's lame attempt at the "upgrade wizard" to update your code from VB6 to .NET. I still don't think it works to this day very well. Oh well...thanks for sharing that.

Tony Hopkinson
Tony Hopkinson

The syntactic fudges such as Load mylabel Dim Label my label = new label() Dim Label mylabel set mylabel = new Label() continuation lines. But the killers for me, were Object based not object oriented. Massive over reliance on variants No threading The cross your fingers garbage collector. The built in components were naff. MS extras such as MSChart and MSFlexgrid were written my muppets. I probably wouldn't notice that much change myself as I wrote decent code, had to fight the IDE and the compiler to do it though, and that's what made it the worst. What really powerful tools in VB? About the only bit I rated was the ease you could integrate COM into your apps. The rest of it was cookie cutting wizards.

jck
jck

What kind of things did you find to make it the "worst coding environment"? I used VB5/6 for over 6 years. It was not bad at all, at least compared to other programming environments I'd used previously (programming utils on IBM anyone? lol). And, I didn't see huge changes from 6 to .NET other than some interface changes, re-naming or making updated objects that did the same as old ones (e.g.- MsgBox vs MessageBox). Of course, I never got into doing really powerful tools in VB. When I needed to write a hard drive cleaner or something, that was done with VC++ 5 (in 1998-99). Gotta love IRPs. lol

Tony Hopkinson
Tony Hopkinson

Technically though it was a pile of crap. I did two years of VB6, it's without doubt the worst coding environment I've seen since. Saying that if I was doing a CRUD app my first choice would not be C, :p VB.NET however is not VB6 (thank F888 for that !). Any programmer who can't, with reasonable ease change languages is one of the glorified clerks VB6 was designed to create. I'm pretty sure the only reason for VB.NET was to lure VB6 houses over. Most of them went for the 'upgrade', and then discovered how different VB.NET was. I remember the howls.

Jaqui
Jaqui

what I needed was to have .net framework support for aspx pages. it's useless. a windows server required for them.

Justin James
Justin James

Yeah, Mono is problematic for me as well, for much the same reasons. I've not even thought of trying to install it, it seems so far behind on feature set and support that it did not seem worthwhile *for me*. I suppose for someone looking for a Java alternative (which I don't think is what you want :) ), it is a possibility. J.Ja

Justin James
Justin James

For me, when I had to pick up PHP, it was a short jump because I was coming from Perl. PHP was originally a Perl module (which explains its many "Perl-isms"), so it took an extraordinarily short period of time to reach "able to maintain PHP" status for me. I think that there is a definite correlation between "simple" languages and "powerful" languages. It takes something like a few pages to explain the entire syntax of Lisp, for example, and how to use it, and hundreds of pages of how to leverage that simple syntax. the same for Perl, PHP, JavaScript, C, etc. Languages like Java, VB.Net, C#, and so on, tend to add more and more constructs onto the languages that perform specific tasks. For example, Perl has the simple "XYZ || die("Error message")" concept... if it can't do "XYZ", it performs the "die". that same syntax can be used to string all sorts of different things together. Current languages have a dedicated "try/catch/finally" system for the error handling, and an entirely different system for each of the other usages of the "operator1 || operator2" syntax. On the one hand, the simple but powerful languages require little learning, but a lot of experience to know how to use them most effectively. On the other hand, the complex but weak languages take a ton of learning to memorize all of the constructs, but little experience in them to get it right. To put it another way, "IntelliSense" would blow up on Perl, but it does great on VB.Net, C#, Java, etc. Or to put it yet another way, in powerful languages, you learn all of the operators and language built-ins in a day, and spend years figuring out new ways to use them, and in weak languages, it takes years to learn every defined function in the language, but minutes to fully understand how to use each one. I'll be blogging about this in a few week. :) J.Ja

stempy
stempy

Due to similarities with C's syntax, PHP is fairly easy to pick up, however there are significant differences to warrant more time in learning PHP. Thats the nice thing about PHP, it looks simple but is quite powerful and contains some great features and approach to building web apps. I do understand though how you say learning the core parts coming from C.

alaniane
alaniane

language to learn if you've done C/C++ programming. A few years back, someone called me over to look over his PHP script to find a bug. I had never seen or written PHP code before then, but I had little trouble follow the script's logic and finding the bug becuase I was already quite familiar with C. There maybe some nuances to PHP that are different from C, but basically if you can program effectively in C then learning PHP or Perl is not that difficult.

Editor's Picks