InfoQ

News

No More Underscores in VB 10

Posted by Al Tenhundfeld on Apr 08, 2009

Community
.NET
Topics
.NET Framework ,
Language Design
Tags
Visual Basic.NET

Visual Basic 10 will have an improved compiler that makes underscores optional for most line continuations. This represents a significant change for VB, traditionally a line-terminated language. The Visual Basic team has an in-depth explanation of Implicit Line Continuation.

VB 1-6 and VB.NET (7-9) used the carriage return as a statement termination token, similar to the explicit semicolon ";" in C#. By moving to an implicit termination token, Visual Basic language readability will be greatly improved, especially when writing multi-line LINQ queries.

Dim dates = from d in listOfDates _
		where d.Year > 2009 _
		select d _
		distinct _ 
		order by d

Could become:

Dim dates = from d in listOfDates 
		where d.Year > 2009 
		select d 
		distinct  
		order by d

The VB team explanation mentioned above covers specific cases where implicit line continuation is not supported:

We don’t capture every scenario. Given our cost and time constraints around the feature, we tried to capture the most common cases that would provide the most bang for the buck. We also avoided the ones that just led to problems. Here are some examples of problems you could have if we had decided to allow implicit continuation anywhere. I take these from some analysis that Lucian Wischik (also on the VB compiler team) did on our grammar:
With y
	A=x
       .xfield
End With
If we allowed implicit continuation before the ‘.’ we would have problems knowing what the period belongs to. For example, it could be interpreted as:
With y
	A=x.xield
End With

Or

With y
        A=x
       .xfield
End With

Channel 9 also has an excellent interview with Tyler Whitney, a developer on the Visual Basic compiler team.

Huh? by Steve Macdonald Posted Apr 9, 2009 7:59 AM
Re: Huh? by Al Tenhundfeld Posted Apr 9, 2009 10:01 AM
Re: Huh? by Jonathan Allen Posted Apr 11, 2009 9:23 PM
Re: Huh? by Al Tenhundfeld Posted Apr 11, 2009 9:30 PM
Re: Huh? by Jack Singleton Posted Apr 9, 2009 1:22 PM
Re: Huh? by Steve Macdonald Posted Apr 9, 2009 5:50 PM
Re: Huh? by Jonathan Allen Posted Apr 11, 2009 9:19 PM
Re: Huh? by Jonathan Allen Posted Apr 11, 2009 9:27 PM
I Like It by Casey Joyce Posted Apr 9, 2009 11:09 PM
  1. Back to top

    Huh?

    Apr 9, 2009 7:59 AM by Steve Macdonald

    This makes me really glad I finally bit the bullet last year and switched from VB (since VB 1.0) to C#.

    What could be more confusing than a line termination scheme that only applies some of the time?

    Phase out VB. Keep C# lean. Bring Ruby and Python fully into .Net

  2. Back to top

    Re: Huh?

    Apr 9, 2009 10:01 AM by Al Tenhundfeld

    That was my first impression also. If you watch the Channel 9 video, it seems less heinous, though still a little mysterious.

    But if they want to go this route, why not just make VB have an explicit terminator, like ";". Yeah, it breaks backwards compatibility, but the upgrade process would be a fairly trivial text replace.

    And it's time for VB to lose some of its cruft. If you're programming in VB.NET without Option Strict, you're doing it wrong, IMO.

  3. Back to top

    Re: Huh?

    Apr 9, 2009 1:22 PM by Jack Singleton

    Although, Ruby and Python both have a "line termination scheme that applies some of the time"... ;)

  4. Back to top

    Re: Huh?

    Apr 9, 2009 5:50 PM by Steve Macdonald

    Heh. Good point. I'm not a Ruby or Python programmer, but that's good to know!

  5. Back to top

    I Like It

    Apr 9, 2009 11:09 PM by Casey Joyce

    I like the new syntax and I think the VB team has done a good job to eliminate the scenarios that would be ambiguous. The improved readability and aesthetics are worth it.

  6. Back to top

    Re: Huh?

    Apr 11, 2009 9:19 PM by Jonathan Allen

    Although, Ruby and Python both have a "line termination scheme that applies some of the time"... ;)


    As does many variants of SQL.

  7. Back to top

    Re: Huh?

    Apr 11, 2009 9:23 PM by Jonathan Allen

    And it's time for VB to lose some of its cruft. If you're programming in VB.NET without Option Strict, you're doing it wrong, IMO.


    Wait a second. If you are working with COM, using Option Strict is downright painful. (Though not as bad as C#.)

  8. Back to top

    Re: Huh?

    Apr 11, 2009 9:27 PM by Jonathan Allen

    What could be more confusing than a line termination scheme that only applies some of the time?


    I know!

    Having lines broken at random like they are in C#. Then spending weeks arguing over coding conventions, only to repeat the argument every time a new team member is hired.

  9. Back to top

    Re: Huh?

    Apr 11, 2009 9:30 PM by Al Tenhundfeld

    OK, you're right. I try to avoid working directly with COM; so it's not on my mind.

Educational Content

Brian Marick on 4 Challenges and 5 Guiding Values of Agile Software Development

Brian Marick takes us through a quick tour of the most important values and challenges to adopting Agile successfully (they aren't the typical challenges and values we hear in the community).

Are You a Software Architect?

The line between development and architecture is tricky. Does it exist at all? Is an ivory tower actually needed? There's a balance in the middle, but how do you move from developer to architect?

Agile – A Way of Life and Pragmatic Use of Authority

The word 'authority' sometimes produces an allergic response in hard-line agilists. Freedom and authority – both are bad if misused and both are good if used in right spirit for a noble cause.

Getting Started with Grails, Second Edition

"Getting Started with Grails" brings you up to speed on this modern web framework. Companies as varied as LinkedIn, Wired, and Taco Bell are all using Grails. Are you ready to get started as well?

Using ITIL V3 as a Foundation for SOA Governance

Those familiar with only ITIL V2 often scoff at the thought that ITIL could serve as a governance framework for SOA. With ITIL V3, the focus of the framework shifted towards service-orientation.

Adrian Colyer on AspectJ, tc Server and dm Server

SpringSource CTO Adrian Colyer discusses AspectJ, SpringSource's dm Server and tc Server products, OSGi and Scrum.

Adam Wiggins on Heroku

Heroku's Adam Wiggins talks about Rails, Background Jobs, Add-Ons, Ruby, and how Heroku manages to work around Ruby's inefficiencies using Erlang and other languages.

SOA as an Architectural Pattern: Best Practices in Software Architecture

For Grady Booch the foundation of a good architecture is patterns, SOA being just one of many patterns. In this Second Life presentation, Booch attempts to bring more clarity on what architecture is.