VB 10 thoughts …

Paul Vick has started the conversation about VB 10 features and thoughts.  Off the top of my head in no particular order here’s some things I’d like to see in the language:

  1. complete Optional parameters
    Optional parameters are one of my favorite features but there’s a couple of problems with them. First you can’t overload by only optional parameters, so it’s hard to impossible do any versioning with them. And second, you aren’t allowed to specify the default value for Structures other than the intrinsic ones. I think both these fixes are reasonably easy and allow for optional parameters to be used as a real code simplification. Sadly too often we see a set of overloads that don’t indicate what the other parameter values are, and make the choice of values passed to constructors limited. Optional parameters are great in these situations.
  2. dynamic identifiers, interfaces and operators
    a nice way to call methods, indicating the the call is dynamic (“latebound”) including truely dynamic methods where the method name is not supplied till runtime (e.g. CallByName), duck typing, and a way to mark standard operators as being dynamic, e.g ~+, ~= etc, would truly provide strict typing where needed and dynamic typing where needed.
  3. pointer support
    There really should be no reason for VB not to be able to do pointer operations.
  4. inline comments
  5. improvements in casting
    First I’d really like DirectCast to have an alias of Cast. DirectCast is ridiculously verbose.
    Second, instead of writing x = Cast(y, z).somemethod , I’d like to have the code flow more forward rather than having to decided up front to cast y you could continue the flow from y,e.g x = y.CastTo(z).somemethod.  You could probably achieve this with extension methods.
  6. multi-statement Lambdas
  7. iterators
    although LINQ statements where possible are preferable

There’s a lot of other thins I’d like to see, but most of them involve the IDE so I’ll follow up on some of them in other posts. I wonder what other folks would like to see in the language ??

This entry was posted in 491, 5162, 5726. Bookmark the permalink.

6 Responses to VB 10 thoughts …

  1. Speednet says:

    VB is my favorite language, so I appreciate your blog entry!

    I’d like to see the equivalent of the C# yield operator, which is great for enumerations. You can accomplish the same thing in one line of VB, but talk about verbose!

    Here are other things I want:

    – pre- and post-increment operators (“++” and “–“, before and after a variable)

    – multiple assignments in one statement, like a = b = c = 1, but with VB it would probably have to be something like a := b := c := 1, since the = sign means equality.

    – multiple initializers on one line, such as Dim a As Integer = 1, b As Integer = 2 *or* Dim a, b As Integer = 1 (which would make both a and b equal to 1) *or* Dim o1, o2 As New List(Of String)

    – Overloaded strongly typed versions of IIf().

    – Another overloaded constructor of the SqlCommand object which specifies command string, connection, and COMMAND TYPE (which would be a great time-saver for stored procedures).

    – Another overloaded Add() method of the Parameters collection in a SqlCommand, which allows me to specify (param name, SqlDbType, Length, and DIRECTION), which is great for Output and Return parameters (the only overload that accepts Direction currently makes me specify like 10 pages of arguments).

    – An overloaded version of SqlCommand.ExecuteNonQuery() which will automatically open and close the connection, so I can do it in 1 line rather than 3 (and keeps the connection open for as little as possible).

    It’s a great language already, these are just some thing I can think of to make it a tiny bit better.

    -Todd

  2. bill says:

    Hey Todd,

    + pre and post operators I think I’d pass on. I’ve seen their usage make code hard to read. Given Vb’s For var = low to high Step n… Loop, I don’t think you really need ++ as much as you do in C style languages.

    +multiple assignment is good. How about a syntax like :
    (a,b) = 1

    +IIF, that’s already fixed in 2008 with the new If operator. (search my blog posts for examples)

    + Overloaded SQLCommand etc. Again in 2008 you can use object initialisers, which let you call New then specify properties after:
    Dim cmd As New SqlCommand(“sp_GetCustomers”) With {.CommandType = CommandType.StoredProcedure}

  3. Bob Bingham says:

    Ack! No ++ or –. I’ve seen those make code mighty confusing.

    Bill, what sort of pointer operations?

    A big YES on optional parameters!

  4. bill says:

    Hey Bob,

    I was mainly thinking of bitwise operations on integral value types, such as bitmap manipulation or similar. It’s the main thign that makes VB.NET “lesser” when it comes to XNA, other than Microsoft’s marketing that is ;)

  5. Jim Wooley says:

    I second the request on iterators. True, you can do a number of those with LINQ, but LINQ itself relies on iterators (see in particular the implementation of Where).

  6. Henn Sarv says:

    VB Language feature request:

    in common syntax is usefull to have following

    ::= [;]

    the main idea is to add to the syntax optional semicolon allowed at the end of any statement :)

    this allows most code examples to be change to equal between C# and VB

    similar simplification is in SQL where ; is optional at end of statement (now since 2005 sometime mandatory

    With bests
    Henn

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>