tags:

views:

125

answers:

6

Hi All,

I am not sure if this is a dupe. I came across this Switching from VB.NET to C# - any advice for learning C#?

My case is the reverse. I would be moving from C# to VB.Net. To be more precise, I would be moving from C# 3.0 to VB 10.0 (.Net 3.5 to .Net 4.0). I am initially planning to use a C# to VB converter to cope up with the syntax.

Any other suggestions is highly appreciated.

A: 

I have nothing against VB.Net (from time to time I work in it) but this sounds like a seriously career limiting move. I'm guessing you find C# too difficult and are just a beginner. My advice to you is to stick it out, it will get easier. There are waaayyy more C# .NET jobs around over VB.NET ones.

That said, the easiest way to figure out the equivalent syntax (and probably the cheapest) is to write stuff in C#, then load up the compiled assemblies in Reflector and siwtch the language to VB.NET. It won't always be a perfect analog, but it will give you enough hints to get started.

edit: I have never inferred or stated that vb.net is inferior; in some areas it is superior (xml literals etc.)

edit: it appears this answer is not relevant as the poster is having this switch forced upon him. I assumed it was a choice.

-Oisin

x0n
Why is it a career limiting move? I think its a huge bonus to be competent in both C# and VB as both have their benefits. There are several SO questions listing the unique features of both languages (check out TextFileParser in VB - comes in handy in lots of scenarios, and while its not C# native you can still use it without issue! Never would have discovered that without reading the SO 'Hidden Features of VB.Net' question). Limiting yourself to one or the other is really teh career limiting move imho.
Moo
@moo my assumption is/was that the poster is a c# beginner. Like I say to kevin, I am not saying it is inferior - in some ways it is superior to c# (xml literals etc) - i am fairly fluent in both. It's just when I see someone asking for help to learn vb.net, I assume they are new to both languages. Vb.NET is not hard to learn.
x0n
@x0n : I am not a C# beginner. I have worked with C# for 7 years. never really got a chance to work in VB.Net except for some POCs projects.
Yogendra
@yogendra - ok, I stand corrected. I just rarely hear of people asking for help in vb, coming from a c# background. It's really not that different, as others have stated.
x0n
"load up the compiled assemblies in Reflector and siwtch the language to VB.NET" **seriously**? If I caught someone doing this and committing the result to sourcecontrol at work, there'd be words had. These words "re-write that code so it actually takes advantage of the language, rather than being a machine translation". Reflector's good, but it's not *that* good
Rob
@Rob - this is just to learn the equivalent syntax (as was asked), not a production code migration strategy for god's sake...
x0n
+6  A: 

OReilly have a very old (circa 2002) book that covers the differences between the two languages, with an eye to converting between them - I used it last year for switching from C# (3.5) to VB 9 (job required it for some aspects and maintaining old projects) and it was a great starting point so its still quite relevent!

http://oreilly.com/catalog/9780596003197

Moo
+4  A: 

According to MS (I heard this from the MS project manager for VB.NET), the number of programmers for C# and VB.Net are roughly the same. So if you believe him, it is not really a career limiting move.

C# and VB.Net are moving into a co-evolving cycle. The main difference between the two will primarily be the language syntax, and not their capabilities. There will always be small differences, like I can't see VB.NET forcing the use of semi-colons, and I can't see C# having automatic statement terminators. Pretty much anything you can do in C# you can do in VB.NET now.

My advice to learn it is to sit down and try and learn the syntax. It's not like switching from C# to F# where there are fundamental differences in approach. If you find yourself thinking, "Man I could do this in C#," Chances are, with .Net 4.0, you can do it in vb.net....now if you only knew a qa programming board you could ask about how to do something in vb.net by giving a C# example..... :)

Kevin
@kevin "the number of programmers for c# and vb.net are roughly the same" is not equivalent to "the number of jobs for c# and vb.net are roughly the same." - and i never inferred or stated that vb.net is inferior; in some areas it is superior (xml literals etc)
x0n
Never implied that you did, but if the number of positions for VB.NET programmers is the same, then one can infer that the number of positions are roughly the same too. What I meant is that programming VB.NET is not like programming COBOL where there are an ever number of shrinking jobs.
Kevin
@kevin I take it you meant "the number of programmers for" in the earlier part of that comment; with this is mind, I say that I don't agree. IMO, when Microsoft state the number of VB.NET programmers, they most likely include ex VB6'ers who are literally a stone's throw from picking up the language anyway. Many of us MS peeps cut our teeth on VB3/4/5/6 for windows programming as such count for a vote. Marketing.
x0n
Nope, he clearly meant the number of VB.NET programmers. I thought the same thing too, but he clarified what he meant. It came up, because we kind of asked what MS's position on VB.NET was. He said they kind of intended for C# to entice Java programmers, and VB.NET to entice VB6 programmers to moving to .NET, and like I said, the number of users is roughly the same.
Kevin
+1 Here's some links to support you. Lisa Feigenbaum, a Microsoft PM in the .NET Managed Languages Group, said (in this video interview June 2009) there are slightly more VB.NET developers than C#. http://www.infoq.com/news/2009/06/Future-VB.NET Here's a March 2010 blog post explaining the coevolution strategy by the Product Unit Manager for Visual Studio Languages http://blogs.msdn.com/b/scottwil/archive/2010/03/09/vb-and-c-coevolution.aspx
MarkJ
@markj, @kevin - Interesting stuff but the jobs sites are still chock full of C# jobs, without significant presence for vb.net. I don't know what this means exactly in terms of cardinality of programmers, but it speaks volumes for career limiting moves if you were to ignore c#.
x0n
@x0n my curiosity leads to if VB.NET programmers place their jobs in different places. Maybe most of those jobs aren't placed on tech boards etc. It's just a thought, I don't know one way or another, but it would be interesting to find out.
Kevin
+3  A: 

I don't understand why there's such debate about VB.Net vs C#. Yep, C# does require fewer keystrokes. But it compiles to exactly the same bytecode.

I usually program in VB.Net as that's what most of the projects I work on are already in. But I don't have a massive problem reading or writing C#. Obviously there's a few little syntactical nuances between the two (which I quickly adjust to) but I don't see any reason why a developer can't be equally proficient in both.

I think C# is more prevalent because the old school 'proper' programmers are more comfortable with the C style syntax whereas people who got into it late and have maybe come from a VBA background prefer VB. I think there's a degree of snobbishness around the whole issue.

I personally prefer having my loops identified with End If and End While and Next rather than } and } and }. But I also like the terseness of C#.

All in all - they're effectively the same. And as for C# being harder I don't really get that. It's purely a syntax issue.

El Ronnoco
actually in many areas - for equivalent features - it does NOT compile to the same bytecode; events and event handlers are a good example.
x0n
This is perhaps the case - I must admit I'm not an expert on the CIL or how it is generated. But for the workaday stuff of loops, routines, passing objects, arithmetic and logic I think there is no significant overhead in terms of size or performance.
El Ronnoco
Charles Boyung
@Charles That is essentially what I'm saying. By old school I don't necessarily mean "old" - I mean those who have come from a more 'pure' programming background. People who fall into programming as part of their jobs (ie writing macros for Excel) will naturally tend toward VB as it is more readable and less intimidating - Even though it's doing the same thing.
El Ronnoco
@Charles - That is a little elitist (education comment). I'm not sure how true that is either. however...@El Ronnoco - I do think that in general that more and more hiring managers think that C# programmers = better than VB.Net programmers. You can just look on the job boards to confirm that the majority of positions open are for C#. Just my opinion.
Jeff V
@Jeff - That's based on my own personal research both into various schools (helping my nephew pick one) and interview candidates. Not elitist at all - based on 100% facts. You can't argue that an accredited software engineering program at a well regarded school is the same quality education as a computer science program at your local tech school, can you?
Charles Boyung
@Charles you are right that a college offers a different education than a tech school. But than someone that goes to Harvard gets a different education than someone that goes to a state school. I guess what got my panties in a bunch was the lower quality programs comment ;) Your point is well taken though!
Jeff V
+1  A: 

The best way to learn a new language is to immerse yourself in it and try not to compare it to any other language you already know. IMO you would be better off taking good examples of VB code and trying to understand them, using a conversion tool to convert to C# if you get lost in the syntax. Trying to write code in C# and convert it VB will always produce substandard code and will slow your progress to learning a new language.

Languages are just tools we use to get the job done, some are easier to understand than others, some produce more elegant code, some have a higher perceived status than others. These days the framework is more important than the syntax of the language you're using. Iif you stick around in programming for long enough your toolset will change and you will either have to change with it or get stuck doing the same old thing day after day.

IME people who are language evangelists are not as smart as those that are language neutral, and regardless of how popular a toolset is now, you don't know what is going to be popular in the future so having the ability to learn a new tool is very important if you wish to persue a career in programming.

fivebob
+1  A: 

It's not perfect, but this code translator may help you in the initial transition. If you are absolutely lost as to how to write something, write it in C# and then stick it in here. This thing has saved my ass more than a few times.

http://www.carlosag.net/Tools/CodeTranslator/

Ender
@Ender : Does it work with newer versions of .Net ? My concern is the translator may not work with the new features.
Yogendra
@Yogendra - That's a good question. Now that you mention it, I realized I haven't used it since .NET 4.0 became available.
Ender