简体   繁体   中英

Entity Framework - C# or VB.Net

My company is tossing around the idea of using the Entity Framework when it comes out with .NET 4. We are currently a VB.NET shop, but have some interest in switching to C#.

Is there any major arguments for or against such a move?
Does EF with C# hold any advantages in performance, coding ease, etc over VB.NET?

Thanks for your thoughts/opinions!

I actually have an irrational dislike for vb.net if im honest, i much prefer c# syntax, but there is no compelling reasons to switch. They both compile to IL, with very subtle differences and both are equally capable.

I would imagine that the most compelling reason to switch might be that it is easier to find and recruit high quality c# developers than it is vb.

I always say stick to what you are good at. If there is a large learning curve from vb.net to C# it may be risky. I was a vb.net programmer but moved to C#, I didn't find it all that difficult. But if you are working on some robust software that needs daily changes / fixes you may want to stick what you are good at (in this case VB.net).

Here is a nice comparison between both languages.

When you are comparing both languages for the entity framework you won't find much of a difference. If you prefer public sub with matching end subs (more wordy and verbose) then use vb.net. If you like { } and less wordiness then prefer C#.

I hate to tell people not to learn C# because I'll be quite honest, I wish I would of changed from VB.net to C# a long time ago. I like the cryptic like syntax because I have a C/C++ background. I had to deal with VB.net for a while due to some internal applications. So it's preference and you'll probably be quick to implement everything in vb.net. But if your company is willing to let you guys learn a new language and invest in your knowledge then I say go for C# all the way.

I think your biggest issue is not in the difference in performance or capability. I think it will come down to documentation. MSDN will probably provide features in both languages, but the majority of the blog posts, etc will be in c#. These posts may offer real world guidance on best practices, tips and tricks and a host of other information that you will lean on in your development practice and most will be in c#.

With .NET 4.0, VB.NET and C# have the exact same functionality. The only real difference is the syntax. Before 4.0 that was not the case as there were a number of minor differences. However Microsoft has made a push to make the languages the same. Which is going to occur with the release of 4.0.

One of the most compelling differences for me is that C# generally has a more concise syntax. This manifests itself especially with lambda expressions. Although VB.Net now has the same functionality, I find the VB.Net syntax way too verbose.

Eg, if you use the LINQ 'Fluent API' syntax:

C#

var addresses = _users
   .Where(u => u.Name == "scott")
   .Select(u => u.Address)

Admittedly, the syntax can be a little weird at first, but as soon as you're used to it this actually becomes very readable. Compare this with VB.Net:

Dim addresses = _users _
     .Where(Function(u) As Boolean
                return u.Name = "scott"
            End Function) _
     .Select(Function(u) as Address
                Return u.Address
             End Function)

EDIT: Apparently I was misinformed...

The above code is only valid in VB10 (where they added multiline lambda statements), but can be written more concisely as follows:

        Dim addresses = users _
          .Where(Function(u) u.Name = "scott") _
          .Select(Function(u) u.Address)

Apart from the ugly underscores and the Function keyword instead of the => , this is mostly the same. Still prefer the C# syntax though ;-)

If you are primarily a VB programmer, C# can be confusing; all those arcane braces instead of a nice verbose "End Sub"!

For the most part, the languages are otherwise equivalent; both compile to essentially the same IL (although there are occasional differences) and are thus equally performant (for the most part).

Bottom line: it's preference. I prefer C#. You may not.

没有实质性的差异,现在比以往任何时候都要保持VB.NET和C#同步,所以它真的归结为你(或你的公司)的偏好。

取决于您正在使用的团队和技能基础。

C# is the way to go in my opinion. I can code in both, but much rather C#. The .Net world seems to revolve around C#. I think you're company will find more C# coders out there that are better skilled than you would find VB.net coders.

I think either language will work. I prefer c# only because their is more documentation out there in c#.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM