Paul Vick and Erik Meijer - Dynamic Programming in Visual Basic

Play Paul Vick and Erik Meijer - Dynamic Programming in Visual Basic

The Discussion

  • User profile image
    If i understand this will allow you to write something like this:

    (this assumes you a have a person, and a form1 with a textbox)

    In other words you can incorporate runtime results back into sourcecode - effectively eliminating the need for things like a select case block(in certain situations).  Of course you would have to validate, or limit the value of, the textbox.text to insure the existence of that member in the calling type.

    am i making sense?

  • User profile image

    The changes they have made to VB.NET allow you to take advantage of dynamic programming without having to write a ton of System.Reflection code and turning Option Strict On or having to turn Option Strict Off.

    Writing System.Reflection code and turning Option Strict On to do dynamic programming in VB.NET requires writing a lot of code every time you want to do something dynamic.

    Turning Option Strict Off lets you do dynamic programming, but you lose the benefits of compilation, taking performance hits (runtime type resolution) and reducing the ability of the compiler to detect coding errors.

    Oh and trying not to be rude here, but maybe next time have someone familiar with dynamic programming and VB.NET do the interview.  That way, you can spend more time in the interview actually showing what improvements they made to the new version of VB.NET to enable better dynamic programming and not spend so much time educating the interviewer on why it is important.

    Unless that was the intention, in which case, ignore my advice.  I guess I was expecting a 300/400- level video, not a 100/200- level one.

  • User profile image
    Much of this looks pretty "old hat" to even a halfway experienced VB 5 or 6 programmer - but I think that's the idea.  A lot of what .Net does is introduce C programmers (if only through C#) to many things they've missed in the past that Classic VB had.

    I doubt turning off Strict eliminates strong typing, I believe that point was made.  What it does is allow late-bound operations in addition to early-bound ones.  This would actually improve the productivity of the programmer, because using the bulky explicit reflection approach requires a great deal more source code to be written and debugged in cases where dynamic object use is desired.

    Clearly late binding has costs, including performance penalties.  That's why one doesn't use it except where warranted.  A sort costs resources too though, but you don't forego sorting just for that reason.  Instead you avoid sorting lists that are properly ordered to begin with.  Perhaps an oversimplification but the same concept, more or less.

    It is good to see how .Net is working to integrate the best things from both programming worlds, as well as extending some of these concepts even further.
  • User profile image
    Ken Levy
    Hi JChung2006. I was the interviewer (Ken Levy, VS Data Product Manager) and I have many years of experience with dynamic programming and know in depth what it is all about. But for the interview, the goal was to educate views on what dynamic programming is, what the benefits are, and why developers should care - all in the context of Visual Basic today and tomorrow. So yes, it was totally designed to be a 100/200 level video/interview/demo and not an advanced one. We can consider doing an advanced dynamic programming Ch9 interview in the future. Feel free to list what features (examples) you would like to see demos of, what questions you would like asked, etc.
  • User profile image
    I have a web based internet game. I need someone to build me a random dice roller to add to it. If your a programmer and know how to build a simple random dice roller, send me a email and I'll send you all the details. You can check my game out at;  my email address is;  I'm not looking for a freebie! I'll pay the right person.
    Thanks, Greg
  • User profile image

    Ken, thanks for the reply.

    I guess the funny looks Paul and Erik shot you at some of your questions at the beginning of the interview gave me the impression that they thought the talk was going to be an advanced talk, too.  Once you guys got on the same page though, the interview went better.  I viewed the video before the downloadable version was available so I couldn't skip ahead to the parts that interested me.  That's no one's fault.

  • User profile image
    Please, do not allow the person who conducted this interview to ever interview anyone again. Never. Thank you.
  • User profile image
    Interesting. It's too bad all this stuff isn't going to be in VB.NET 2005.
  • User profile image
    I don't know how others feel - but to me this interview was embarrassing (almost painful) to watch.  Between Paul Vick fumbling around basic reflection code and the terrible interview questions that needed to be re-routed by the interviewees, what should have been a pretty straightforward feature demo came unglued several times.

    Unfortunately, this probably served to perpetuate the stereotype that VBers are not the sharpest knives in the drawer.  (Compare this video to the recent Anders/LINQ interview, for instance.)

    As someone who uses VB & VB.NET (as well as C#) for a living, here's hoping that we'll see a better representation of VB in future Channel9 videos!  Although I guess it's hard to complain - this content is free after all…

  • User profile image
    Ken loves the word "dynamic".
  • User profile image
    Who did this interview? Embarassed

    His questions were so painful!!!  This is really cool stuff, but it comes off pretty clumsy when you have a terribly uninformed interviewer.  Do a little homework before the interview please!
  • User profile image
    Ken Levy
    The goal of the interview was to educate people on what dynamic programming is and what the benefits are, for those who do not already know what it is - so the questions were asked in a way that someone might ask if they did not know or care about dynamic programming but should if they knew more about it. If someone has experience or knowledge of dynamic programming already, then they may be a little frustrated with the introduction level questions asked. I have noticed that most of the people here adding comments who have negative feedback do not include their email or blog in their profile and are posting anonymously. It would be useful for some people to post what questions they would have liked to have heard asked in the interview or what additional topics were covered for future related Channel 9 interviews.
  • User profile image
    This looks like something that would be good for contract first sort of situations where you don't what the object will be or where it comes from but you want to assume some base structure or functionality.
  • User profile image
    My quip says that this video shows that VB.NET is "responding" to some of the features of Python. This video pushes Channel9 to the edge... a very rough cut... all of us developers need better speaking/presenting skills...
  • User profile image
    Ken, try not to take the negative criticism too much to heart.  Scoble makes it look easy, and interviewing is not easy.

    Some advice:
    1. Keep your questions short and simple.  The most common mistake rookie interviewers make is talking a lot.  The interview is about the people being interviewed, not the interviewer.
    2. Have some fallback questions.  You shouldn't script all your questions, but if lulls develop, have something to ask to resume the flow of conversation.
    3. Ask Scoble and other experienced interviewers for advice on interviewing.

    I took a look at Erik and Paul's blogs.  One of them mentioned not being able to cover XLINQ in these videos so maybe you could talk about XLINQ and VB.NET in a future video.  Talk to Erik and Paul about topics that make sense to cover in future videos.  They're the domain experts, not you or me.
  • User profile image
    "The goal of the interview was to educate people on what dynamic programming..." - Ken Levy

    It was? Did the 2 guys know that?

    They were just demo'ing and you kept injecting such weird
    questions, that they didn't answer and kept looking at you
    You didn't even sound like a coder to me, and when I read
    that you do a lot of Fox Pro I was stunned. Your Fox Pro
    videos are great and you sound really intelligent, but it
    seems with VB, that you are not that experienced, so you
    come off...ah, less than polished.

    Let your subjects speak! Just sit back and let the tape roll
    until they look to you for the next subject.
  • User profile image
    Ken Levy
    Hey JChung2006 , thanks for the detailed comments and feedback. Your points are very well taken and useful for my upcoming efforts, I will be sure to apply them going forward. I record a video later this week with a member of the VB team on the new Code Snippets in VB 2005, which also applies to other areas of VS development. For the XLINQ topic, I'm thinking of a topic combining XLINQ in VB and the topic of XQUERY, showing and discussing the relations and differences between them in usage, code, etc. The two people to interview would be Erik Meijer (XLINQ) and Michael Rys (XQuery).
  • User profile image
    JChung2006 wrote:
    Ken, try not to take the negative criticism too much to heart.  Scoble makes it look easy, and interviewing is not easy.

    I've never met scoble but I know:

    He reads above 1500 RSS feeds every day.
    He spends 14 hours a day in outlook (yea, he's reading RSS feeds).
    He wants every piece of software MS makes, his washing machine, jeans, and car to all have an RSS feed (I guess 1500 feeds a day isn't enough for him!).
    He wants to read his washing machine on his bic pen RSS reader.
    He loves MS, his job and reading RSS feeds, oh he loves his wife too.
    He has a somewhat obnoxious laugh, espesially when he is the closest one to the mic!

    All kidding aside Robert Scoble, keep up the good work with Channel9!


  • User profile image
    I thought Ken did a nice job on a tricky feature. A feature that has lotsa man hours in it, but the programmer wouldn't even have to know about it beyond "it just works".

    I do have a performance question. Let's say you go the reflection route, and the performance is X. Now if I go the late binding route, the VB compiler is just doing reflection behind the scene, right? So my perfromance is still X?

  • User profile image
    Dear all new friends...

    first i want to apolygize if i'm wrong entering room Tongue Out, because i'm a very-very new beginner.

    to all friends, i want to ask :
    I develop an application using Microsoft Excel 10 Object Library in Microsoft .NET environment, But it's not fully succesful Perplexed in many operations that i've done are success (e.g opening file,assigning cells, operating formulas, saving to file etc) except quitting/closing the EXCEL object.

    because,while my application was running, i opened the task manager i still saw EXCEL proccess running there fiuhhh... it drive me crazy [C] .. whereas i add the (XL.Workbooks.close and XL.quit) line everytime i've done using the object

    does anyone experience that problem and know that problem? please let me know... Big Smile

    thank u so much
    God Bless U All

    Ferry Avianto
    PT. Aisin Indonesia
  • User profile image

    We want Chris & Ari and the Head!

  • User profile image

    Now, that i see this type of programming, i could think to stay a couple of years more with This type of examples helps to contruct Object Oriented clases, same as Java (familiared with).

    I could see a scenario were this type of declaration , would help you to define a runtime type of variable, and prevent exceptions, threads that will conduct to a system crash.

    Now the other things that boders me is that, vb wont be around, cause we all know that csharp it´s a better language.

    Do you see this as an alternative?

    I am from Mexico,  excuse my spelling. (No time for editing)

  • User profile image

    The extreme latebinding was and is still missing from VB.Net and it's good to know that the next release (after 2005) will have this feature. This feature is available in Visual Foxpro since it's origin.

  • User profile image
    Although a long video, it touched on a topic with which I have been able to get very little support.  On my current project, I have a great need to call methods and variables dynamically... and researching to find out how to do this via reflection has been, to put it mildly, a pain.  It seems that the VB world consists of two levels of programmers:

    A)  Those who know reflection backward and forward and all the technical mumbo-jumbo about how the compiler works.

    B)  Those who do not know anything about reflection.

    In my experience, it seems that A) and B) cannot and do not know how to converse with each other in plain English.  I think A) was just born that way, for they often fail to know how to instruct others in their godly ways.

    As it was, I ended up using stuff like:

    CallByName(Me, "Method" & integerVariable, CallType.Method, parametersArray)

    just to call:
    Method2(param1, param2)
    or Method3(param1, param2, param3)

    I took me about 7 full pages of written dialouge back and forth between about 20 so-called "experts" to discover even this!

    With the next release, I hope that this becomes an easier task.  I am excited about things such as:


    as well as the dynamic interface options.

    Although this info could have been relayed in about 5 minutes, I really appreciate you approaching the subject in "real English" terms!

  • User profile image
    I'm writing a fairly large (~25k lines so far) VB program which works with Excel, and I haven't been able to figure out the best way of dealing with the fact that differed versions of Excel have different interfaces. I can either use interop for the oldest version of Excel or I can late bind. Both seem to work, but I don't know if there's a significant difference in efficiency, compatibillity with future versions of Excel, or some other way.

    ' any thoughts?

  • User profile image
    I just really don't see this as a great feature. I mean they act like if we don't have this dynamic typing then we have no way to do this without reflection. Well god forbid we define interfaces for objects so that we can access different objects that don't share heirarchies. At least if we use Interfaces and pass our objects into a method that defines the parameter as the interface type then if someone tries to pass an object that doesn't support that interface then we get an error at compile time. Just defining parameters as object types could result in a lot of runtime errors in complex programs. This sort of thing should be used sparingly IMO. While there are some times when these features could come in handy, you really need to look at the problem and ask yourself whether this feature is making your code easier to write or whether you are making your code more robust. A lot of the time doing the right thing and doing the easy thing are completely different.
  • User profile image
    What I was hoping to see here was a interactive programming shell like Monad but with Visual Basic syntax instead of the rather cryptic perl like syntax,  VB might have some potential here, but instead what I saw scared me.  Please take that compiler away from them before they hurt someone.

    The first poster mentioned the possiblility of something like:


    Ouch! this feature is a hackers dream.  External data should be assumed to be untrusted the last thing you want to do is blindly execute whatever the user types in. 
    For example say your textbox is on a web form and the web application has access to a database that with a little insider knowledge or trial and error he uses the web applications credintials to connect to the local database on the web server and deletes some data such as.

    New SqlCommand("Delete * from CustTable", New SqlConnection(...).ExecuteNonQuery()

    After deleting all your customers (and all cascading relations) you'll probably get an exception such as the method or property 1238 (the result of executenonquery ie number of records deleted from the table) on person does not exist.  Even if this were perhaps a query from some xml meta data about person object the application must be extreamly careful to ensure that whatever gets evaluated in the () is safe to execute.  Assuming you knew what it was you were executing between the () they why not just put it there if you don't know what will be in the () then you probably shouldn't be executing it.  It might be useful in some ad-hoc one off scripting such as and administrative WMI query or something like that but I would never ever use it in a production code.

    - Kurt

  • User profile image
    Oh joy. Only 2 more versions of dotNet to go before we're capable of writing VB6 code. What progress that is! Plus, all that wait and we'll still have crappy dotNet performance. "dotNet... like running from the internet, no matter what!"
  • User profile image
    Dear Paul, This video was amazing indeed. If it is possbile to demonstrate more about using the INTERFACE in order to get the intellisense of dynamic classes, I would appriciate that. Nice work again to you and Eric, the language genius not geek:D
  • User profile image
    Bad design for an app imo. We've all heard of spaghetti code. What you're describing is far worse. It's uncontrollable spaghetti that's slopping all over the floor... but, then again, VB.Net is basically so, as long as you have a 10ghz PC with 1 terabyte of ram, you *way* get decent performance from a .Net app.
  • User profile image
    You *way* should obviously read "You *may*"

    I'm not giving up my fully compiled, native code enviroment until it's ripped out of my hands. I have no interest in joining the Open Source market... which, is exactly what apps are that are written in dotNet. It doesn't matter if you spend 5 grand on an obfuscator (needing such a tool is ridiculous, in itself) your code is free to anyone that owns a tool such as Remotesoft decompiler

    ...and, I find it disgusting that tools like this are available, especially since their opening line says "Think your code is safe, think again"

    Quick... someone find a similar tool for VB6. Ain't gonna happen.
  • User profile image
    Hi!! nice to meet u name is David from Malaysia. i have gone through your dynamic programming and its really amazing!!

    For your infomation, i am beginner in learning visual basic 6.0 and i have a problem  in  coding for  how  to  get  the  value  of  "d" in the equation below by using VB6.0??? lets say:


    Am i going to use the looping in VB6.0  to loop up untill d is equal 0?..but how to display the value of d when equation is =0?? i really need ur help...and i am really happy to hearing from you soon..thanks.
  • User profile image
    Here is a program that runs as a client, and strictly uses only Smiley late binding. If there is no late binding in VB we could have endured a hell lot of problems. 

    Thanks to Microsoft and VB team providing this in VB.

    This is a very useful feature, but why is not supported in CF?

Add Your 2 Cents