What's the list of new language features in Visual Basic 10.0 and C# 4.0? (Lisa Feigenbaum)

Published 23 December 08 01:57 PM

This post is in response to a question we received in the blog comments last week. It's often difficult to study future versions of VB and C#, and figure out what's the same and what's different! Therefore, I've put together a chart that shows both the VB 10.0 and C# 4.0 feature lists together. (VB 10.0 and C# 4.0 are the language versions that will be included in the Visual Studio 2010 release.) One thing you may notice is that the lists look very much the same! That is part of our efforts to ensure that whichever language you are using, you will have the same functionality available to tackle your development tasks.

image

 

by VBTeam
Filed under: ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# What’s the list of new language features in Visual Basic 10.0 and C# 4.0? (Lisa Feigenbaum) | Coded Style said on December 23, 2008 5:18 PM:

PingBack from http://www.codedstyle.com/whats-the-list-of-new-language-features-in-visual-basic-100-and-c-40-lisa-feigenbaum/

# cyclone_dll said on December 26, 2008 12:51 AM:

The "Implicit Line Continuation" makes vb not like vb ,but like C style language.

In this case,

How about supports to write Unsafe code?

and we need use XNA in VB.

# tox said on December 27, 2008 7:38 AM:

I agree to cyclone_dll, an implicit line continuation is unnecessary as it makes it not BASIC anymore and we can achieve the same thing by using the line continuation operator.

Besides we rather need some important language extension:

a) A lazy ternary operator. The IIf function is a pain-in-the-arse surrogate.

b) Support for emitting the sizeof opcode, be it safe or unsafe, because sometimes I need the size of a value type.

c) An equivalent operator for default(Type) in c# because sometimes I need the default value of a generic Type.

d) Support for direct converting between char and integer types because calling the VB style functions is very, very slow and annoying.

These things are, in my opinion, much more important than messing around with the language paradigms like line continuation.

# ljw1004 said on December 27, 2008 8:46 AM:

(a) "If(b,x,y)" is the lazy ternary operator. It means "if b then x else y", and only evaluates x if b is true, and only evaluates y if b is false.

"If(x,y)" is the coalesce operator. It means "Dim $t = x : if not $t is nothing then $t else y". It works for nullables and reference types. It only evaluates y if x is nothing.

(c) "Nothing" is the exact equivalent for default(Type). "Dim x As IntPtr = Nothing" is the same as default(IntPtr) is the same as IntPtr.Zero. Incidentally, the null reference is the default for all reference types.

(d) I'm curious what you mean by "very slow"? Dim x = AscW("a"c) is exactly as fast as the C# code "int x = 'a';"... they both produce the same IL.

(b) Could you spell out for me in a little more detail, please, even if you did know the size of a value type, how would you use it in a safe manner?

# tox said on December 28, 2008 8:45 PM:

a) x and y are evaluated, because Iff is a function, then both results are passed to the function Iff and one of them is returned. That's not what I call lazy evaluation.

b) Maybe I want to calculate the needed memory of an array to present it to the user or to make decisions for the creation of look-up-tables.

c) See the difference between c# and vb.net code:

void c<t>(t h)

{

   h = default(t);

}

translates to

.method private hidebysig instance void  c<t>(!!t h) cil managed

{

 // Code size       9 (0x9)

 .maxstack  8

 IL_0000:  ldarga.s   h

 IL_0002:  initobj    !!t

 IL_0008:  ret

} // end of method Form1::c

Sub c(Of t)(ByVal h As t)

   h = Nothing

End Sub

translates to

.method public instance void  c<t>(!!t h) cil managed

{

 // Code size       12 (0xc)

 .maxstack  1

 .locals init ([0] !!t VB$t_generic$S0)

 IL_0000:  ldloca.s   VB$t_generic$S0

 IL_0002:  initobj    !!t

 IL_0008:  ldloc.0

 IL_0009:  starg.s    h

 IL_000b:  ret

} // end of method Form1::c

d) But what about:

Dim Val as Short

.

.

Dim Val2 as Char = ChrW(Val)

This makes a call to a function.

In C# it's simply:

short Val;

.

.

char Val2 = (char) Val;

# ljw1004 said on December 28, 2008 9:41 PM:

(a) "If" is the lazy operator. "IIf" (two Is) is the function.

Give me a few days to think about the others...

# cyclone_dll said on December 29, 2008 3:24 AM:

"if" is a new operator in vb 9,it use short evaluation,and can be used like this:

"' When the divisor is 0, IIf causes a runtime error, but If does not.

divisor = 0

Console.WriteLine(If(divisor <> 0, number \ divisor, 0))

' Console.WriteLine(IIf(divisor <> 0, number \ divisor, 0))

". tox ,you can see it in MSDN.

I agree to tox,and here is additional opinions:

a) Use "#Region .... End Region" in method block.

b) A vb style multi-line comment like " /* .....*/" in c#.

# El Bruno said on December 29, 2008 6:40 AM:

Really cool post !!!

Bye from Spain

# sicual said on December 29, 2008 1:55 PM:

Why are there so many VB6 developers although the last VB version dates back to 1998?

Because VB .NET is far too complex! Don't introduce more language features or you never get the VB6 programmers to migrate to VB .NET.

# Daniel Walzenbach said on December 29, 2008 5:28 PM:

Sicual,

Thanks for your comment! My name is Daniel Walzenbach and I’m a PM on the Visual Studio team. As we’re always interested in feedback from our customers I’d like to know what you’re missing in VB.NET to like it/switch from VB6? If part of your answer is “less complex” can you qualify/quantify this? What are you missing? What would you like to see? If you don’t want to post publicly you can also write me mail at daniel.walzenbach(at)microsoft.com.

Thanks!

  Daniel

# Greg said on December 30, 2008 12:02 PM:

An automatic way to convert VB.NET to C# and C# to VB.NET would be nice since we want to standardize on C# and migrate all of our VB.NET code to C#.

# Sicual said on December 30, 2008 1:35 PM:

Hi Daniel,

Which language should you use: C# 4.0 or VB .NET 10.0?

If I’m looking at the posted feature list then I believe that they are equal. They have different keywords and syntax but that’s it. So we have two equal competing programming languages for .NET.

In my opinion the languages are mostly used by:

1. Small Basic: Hobby programmer who wants to learn the basics of software development.

2. Visual Basic 6: Half programmer and half domain expert who wants to write small software tools that helps him and his colleagues to handle their domain more efficient.

3. C#: Professional software developer who writes large enterprise applications, frameworks… (But often lacks of the in-depth domain knowledge)

I see VB .NET just as a replacement for C# - same features, same power and the same complexity. In my opinion VB .NET should have been the simplified version (less features) of C# so that VB6 developers have a chance to move to the .NET Framework.

What I do not need are language features that help me to save some lines of code but don’t give me any added value.

* Auto-Implemented Properties: A colleague asked me recently about this C# feature: “I see that I’m able to save some lines of code but where is the value stored of the property?” Maybe this feature uses some advanced concept like the DependencyProperty. I had to look at the generated IL code (in Reflector) to understand how this feature works.

* Implicit Line Continuation: Here I have to agree with cyclone_dll. It’s not worth to change this behavior.

* Statement Lambdas: Great feature but I think it is understood only by highly skilled developers.

A personal feature wish: I agree with Greg. Conversion between VB .NET and C# code would be great.

# Diego Cattaruzza said on January 2, 2009 5:35 AM:

I can contribute with this:

   Dim i As Integer = 65

   Dim s As String = Char.ConvertFromUtf32(i)

   Dim v As Integer = Char.ConvertToUtf32(s, 0)

   Dim c As Char = Char.ConvertFromUtf32(i)(0)

But I agree that it should be fine a Char costructor with an integer parameter and viceversa.

I don't understand the new implicit line continuation, in the sense I don't figure how distinguish when a line is new and when it is continued, or when it is finished. I wait for the new VB, to judge.

# marco.ragogna said on January 7, 2009 4:33 AM:

* Auto-implemented properties

Yes! It's only sugar but I like it

* Implicit line continuation

Could be nice but if it cost a lot in terms of development I would abandon it.

Instead please consider another feature that C# has gained with the last release and VB.NET does not have: Anonymous Multiline Delegates

Without this feature it is not so trivial translate a useful piece of code/class written in C# into VB.NET.

What do you think about it? Any possibility to see in next release?

# Dustin Campbell said on January 7, 2009 8:29 AM:

marco: Thanks for your feedback! The "Statement Lambdas" listed is indeed the same as C# anonymous multilne delegates.

# Angus McDonald said on January 8, 2009 6:36 PM:

I'd love to see statement lambdas released in a VB9 patch as this seriously prevents us from using nearly any TDD tool easily.

For those of us into ALT.NET and using VB.NET codebases it is a pain to be told that tools only support C# because they need to use lambdas to keep the code readable/usable.

Waiting another year for this means my dev team either gets a year further behind our competitors using C#, or we bit the bullet and move everything to C#, leaving VB altogether ...

# VBTeam said on January 9, 2009 6:28 PM:

Hi Sicual,

It's true that the functionality in VB.Net and C# is similar. Therefore you should use the language that is most natural to you, based on your background (in BASIC or C-style languages), and based on your stylistic preferences (for example: the same features are often implemented differently between the two languages, the IDEs give a different feel, etc.).

Lisa Feigenbaum

Program Manager

Visual Basic

# CJ said on January 12, 2009 3:45 PM:

Auto properties, multi-line lambdas, implicit line continuation...bunch of new good things to look forward to. Thanks! Of course the sooner the better :-)

# Termékinformációk fejlesztőknek said on February 13, 2009 3:08 PM:

[Nacsa Sándor, 2009. január 20. – február 12.] Komplett fejlesztő környezet Windows kliens és web alkalmazások

# Teaching the old dog new tricks... said on February 17, 2009 11:14 AM:

One of the things I do as part of my job is teach courses on WPF and Silverlight 2.&#160; The courses

# Paul said on March 21, 2009 6:28 PM:

Still no Unsafe code blocks in VB. The glass ceiling STILL exists!

# Regnwald said on September 23, 2009 4:55 AM:

Lisa

What a waste.

There is NOTHING, absolutely NOTHING to tempt me to buy VS2010, anymore than there was way back in 2002.

Just a lot of wrapping paper hiding the APIs and making the environment actually slower and less powerful. This applies especially to graphics.

I need a book! How about " How to get around in VB.NET" but with the"In" heavily crossed out

Ron

# yelinna said on October 15, 2009 10:10 AM:

Yea CJ, I agree with you! So many new features, I need time to learn them!!

Leave a Comment

(required) 
(optional)
(required) 

  
Enter Code Here: Required

This Blog

Syndication

Page view tracker