August 2005 - Posts

TechEd Oz (Day 0) It's ALL about the shirts !!

Well here I am live at Tech Oz.  The conferences centre is a really nice layout, the people are friendly, and it's great to see so many Aussie speakers this year. The hotel , Jupiter's is quite nice too, the morning walk just the right length.  But I am a bit disappointed...  Here I am, 6'2" of walking advertising space and still not one T-shirt !!   

it's all about the shirts.

Posted by bill | 2 comment(s)
Filed under:

VB - set to dominate !!

 

Just finished watching another great channel 9 video.  It really should have been two parts, but it's worth watching the whole thing.  The real kicker stuff comes in about 40 minutes or so into the tape.  It's really interesting to hear the talk about dynamic languages with Erik Meijer and of course Joel Pobar.  Erik talks about the spectrum of languages from the fully dynamic such as iron python to the fully static like C++ or C#.  The key to note here is how Erik talks about VB as being the language that does both dynamic and static.  To quote Erik :

" in a year's time people will point at VB as an example of modern language design because it especially allows you to span these two worlds ..."

 

Of course I'd say if people needed another year to realize that, they just haven't been paying attention.  I've talked about it before, how VB is better designed than, say C# for example. VB has led the way with abstractions and declarative programming. dynamic programming too, has always been there.  The importance of this will really come into play when we start seeing the worlds of "data" and "general programming" also begin to meld.

Paul's talk is definitely stirring up a buzz already, with InfoWorld titling their article "Microsoft set to hail Visual Basic 9.0"

 

And even Mitch Denny seems to be getting on the bandwagon too.  I noticed he's listed the VB sessions he plans to attend

I especially like the:

  • Visual Basic Tips/Tricks and Other Advanced Topics (Nick Randolph and Bill McCarthy) wouldn’t miss this one for the word!

     

    Thanks Mitch !

     

    At TechEd next week we can't talk about the Orcas stuff unfortunately, you'll have to wait just a few weeks more till after the PDC.  But there's so much good stuff install with Whidbey, we wouldn't have time anyway smile  One thing's for sure, if you are a VB developer, well life could not be sweeter. 

    If you are a C# developer, well it really is time you started learning VB properly.  A lot of you guys say you can code in VB, when truth is you can call methods when it's the same as C#, but you haven't really learnt the intrinsic beauty and elegance of VB.  It's a hard journey for some of you, but you have to start some time.  VB is clearly going to be the language of the future.  So join Mitch, and come see some great VB talks.. It's bound to be lots of fun.

     

     

  • Posted by bill | 5 comment(s)
    Filed under: , , ,

    Important TechEd advice from MapPoint

     

    going to TechEd Oz ?   Staying at Jupiter's cassino ?  Well you should look at the good advice on mappoint

     

     

     

    That's right folks, the police beat on Hooker blvd 

     

    http://maps.msn.com/map.aspx?C=-28.033695044301485,153.42928911641718&L=AP&A=1&S=800,740&PN=1767474874&P=%7c80c1de%7c&TI=Broadbeach%2c+Queensland%2c+Australia

     

    Funny thing is none of the other map services call it Hooker Blvd . 

     

     

     

     

     

     

     

     

    Posted by bill | with no comments
    Filed under:

    boxing of nullalbe types (changes since Beta 2)

     

    Last night I was chatting with Corrado Cavalli about the nullable type changes since Beta 2.  He was kind enough to run some test code for me using the August CTP.

     

    The changes to the boxing behaviour mean that when a generic nullable type is boxed, if the nullable type .HasValue is False, then the boxed variable becomes an actual null reference.  If the value is not null, then it can be directly cast to the underlying type or the Nullable type.  for example:

     

    Sub Main()

        Dim x as New Nullable(Of Int32)

        BoxTest(x)  'call 1

        x = 42

       BoxTest(x)  ' call 2

    End Sub

     

    Sub BoxTest(ByVal value As Object)

      If value Is Nothing Then Debug.Print "value is Nothing"

      If TypeOf value Is Int32 Then Debug.Print "value is Int32"

      If TypeOf value Is Nullable(Of Int32) Then Debug.Print "value is Nullable(Of Int32) "

    End Sub

     

    The above test would print out "value is Nothing" in the first case which is when HasValue = False.  In the second case when the nullable type has a value, it prints out both "value Is Int32" and "value is nullable(Of Int32)"

     

    So the good news is this simplifies the code a lot.  The INullableValue interface which was introduced in .NET 2.0 purely for Nullable(Of T) to be able to be used from non generic methods is now no longer needed, and hence it's actually been removed.  Alas poor InullableValue.. R.I.P. smile

    So code that would have looked like:

    Sub BoxTest(ByVal value As Object)

      If TypeOf value Is INullableValue Then
         If CType(value, INullableValue).HasValue Then
             ...
         End If
      End If

    Now just becomes:

    Sub BoxTest(ByVal value As Object)

        If value IsNot Nothing Then

     

    And the other nice bit now comes into play, that is , being able to treat the boxed nullalbe type like it's internal type.  That means you can treat a Nullable(Of Int32) the same as an Int32.  So if for example today you already have code that deals with a value as Object, and you then determine it's type, checking for intrinsic types, well the good news is that code will work with the nullable types without any modification. e.g.

     

    Sub WriteValue(ByVal value As Object)

       If value Is Nothing Then return  ' early exit

       If TypeOf value Is IConvertible then

          Select Case CType(value, Iconvertible).GetTypeCode

                 Case Typecode.Int32

    ...

                 Case Typecode.Byte

    ...

    etc...

     

    So that code will work fine with nullable types.

     

    The big disappointment I have with the approach taken though is that although the Null checking has been made simpler, the value type semantics has been broken, and hence information is lost.  When you define a Nullable(Of T) type, such as Dim x as New nullable(Of Int32), even though the nullable type has no value at this point of time, it does have an generic parameter type information.  So we have a null value AND information as to the type of the non null value.  It's the inner type information that is lost when boxed, as a null reference (Nothing) has no type information.

    So to me, although I can see some goodness in these changes, it still feels like a hack.   If I want to have null values while preserving the type information, I have to use generic parameters throughout. 

    Posted by bill | 2 comment(s)
    Filed under: ,

    + verus &

     

    The other day I saw someone not too familiar with VB get confused over whether they should use + instead of & or not. So, I'll try to explain....

     

    & is the String concatenation operator.  If it is String concatenation you are trying to do, it is the operator you should use.  If either operand is not of type String, Char or Char(), the operand once converted to String is used.  The conversion for intrinsic types has special handling, but basically it calls the ToString for intrinsic types as well as for custom types.  Hence 1 & 2 will return a string "12".

     

    + is the addition operator.  When both operands are String, Char, or Char() or any combination there-of, then the + operator does String concatenation.  But it is not limited to that, it also does mathematical operations, etc. . Mathematical operations are given precedence over String concatenation, so 1 + "2" will return 3, as will "1" + 2, but "1" + "2" will return "12".   Obviously  code such as 1 + "2" requires Option Strict Off , where implicit conversions are allowed. If Strict On semantics are used, no conversions other than the implicit conversion of Char and Char() to String are applied

     

    So the key points to remember are :

    • & will implicitly call ToString on the operands if necessary.  It behaves exactly the same whether you compile with Strict On or Strict Off.
    • + will behave differently depending on whether Strict On or Strict Off is used. It will only perform String concatenation if both operands are String, Char, Char() or a combination there-of, in other cases it will attempt to do addition .

     

    You can of course use + with Strict semantics and when dealing only with String, Char and/or Char() it will work the same as &, but for other types, it requires you to do the conversion to string. So a blind equivalent of & is CStr(operand1) + CStr(operand2).

     

    So the long and short of it, is use & when you explicitly want to do String concatenation.  No doubt some of you are saying well why have + for strings then ?  The answer of course lies in dynamic programming needs, where you do want/need two explicit operators, e.g: 1 + "2" versus 1 & "2". 

    Posted by bill | with no comments
    Filed under:

    How they built Virtual Earth (via Dr Neil)

    How they built Virtual Earth

    Check out this video on how they built Virtual Earth. Too funny.

    Posted by bill | with no comments

    No wonder Geoff is having a hard time finding a VB dev ..

     

    well apart from the fact that VB developers are in huge demand as most are already gainfully employed (versus those homeless elvis impersonators), I think Geoff might be asking the wrong question or expecting the wrong answer ;)

     

    I read Geoff's "answer" to the difference between GET and POST, and my "response" was to fall asleep, wake up and reply "next candidate please" <bg>.   sure Geoff was technically correct, but where was the relevance ?  I want an answer that is relevant, not some friggin RFC synopsis.  What answer would I expect ? well something like  ...

     

    You can use both GET and POST, there's pro's and con's to both approaches.  GET is basically just a URL, so the user can save that as a favourite, it can show in their history, and they can usually navigate back and forward without having to re-submit the form.  These can be good in some scenarios, but bad in others, depending on the design.  One major drawback of GET, is that it has a finite limit, 1024 chars I think, but that may have just been a known bug in IE.

    POST on the other hand, doesn't have that limit on the data being sent back, but it doesn't haven't the ability to save as a favourite etc.

     

    Now that's not a technical RFC bore me to death answer, it's an answer though that shows me they know why GET and POST is relevant.

    Oh, and if they said "HEAD... isn't that Bill's blog", well an instant HIRE !!!

     

    :)

     

    UPDATE :  the actual maximum length for a URL is 2083 chars and max path is 2048 chars in IE.

    Posted by bill | 1 comment(s)
    Filed under: ,

    Rob Teixeira's blog moved

    Seems like only a couple of months ago.. oh wait it was.. that I posted that Rob was blogging.. So what's he do.. he moves his blog.  Now I was holding off on posting this, so at least he should be settled in before moving again

     

    Rob's new blog is there   ,   RSS

    Posted by bill | with no comments
    Filed under:

    Blog birthdays...

     

    Oh dear, I missed my blog's birthday.... It's now a bit over a year old.  The only reason i noticed was Paul (Who, BTW, is responsible for me blogging ) talked about his blog's birthday, and Geoff also posted about his blog's birthday.

    Interesting, well on a tangent, I also got an email from Susan, where "some person" said when speaking of the blogs on msmvps ". But it seemed most of those I clicked on were hopelessly out of date ".  Hmmmpppphhh is what I say to that   Personally I like blogs that post, say once a week,...  Quality not quantity.  Take for example say Robert Scoble's blog.. Okay sure sometimes there's some interesting stuff in there, but it's a lot of entries to wade through.  Reality is, if you post 5 or more entries every day, I'm not going to have time to read your blog, at best I might skin the subject line.

    So what got me thinking on this slight tangent was just the co-incidences of events, and Paul's blog entry talking about the history of blogging.   I still remember some years ago when Robert was working for Dave Whiner, and discussions we had in some funky little newsgroup about it. ( I think that "ramp" has now gone).  Funny how most people, myself included, thought blogging was like a public diary, very very extrovert ....

    But since then blogging has filled different niches.  I only really read technical blogs, so I am in fact oblivious to what else is going on in the world of "Dear diary's".  But in the world of technical knowledge and sharing, I think blogs are one of the most useful sources of information.  with the aid of search engines like google, blogs can  be one of the most useful sources of information..  No wonder google ranks them first.

    So congrat's to Robert for sticking with it.  Without doubt his passion for blogging (or is that a passion for being an extrovert ?) has helped blogs grow inside MS, and hence helped add substance to technical blogs, such as Paul's and Geoff's.   

    I don't think we are there yet though, there's really to much "noise", not enough consolidation, no smart sharing/filtering.  so for many people, people who don't have time to wade through it all, well much will slip by.  Hopefully one day it will be more of a collective kind of sharing.. oh, no, I said "collective"...  I can see the slashdot picture of Bill G already   Except in this collective, to keep the noise levels down, we might have to unplug Scoble   oh, dang, that's right MS did that long long time ago... maybe that just goes to show Blogs truly are viral... Enjoy smile

     

    Posted by bill | 1 comment(s)
    Filed under:

    late bound conversions with generics !

     

    I got  a note in my inbox today from Cameron Beccario, letting me know his blog has moved (new rss here).  Cameron has been busy in Japan (hopefully NOT pigging out on whale meat), having managed to learn Japanese, he's now working there.  Anyway, Cameron said I might be interested in his latest blog entry, and he was right :)

     

    Cameron does touch on a couple of "interesting" issues, such as conversions with generic types.  Cameron's  approach works well in the second scenario he shows, one where you don't necessarily have full control of the code. (I'm assuming that the AddRow method has to convert the string to a DelimetedPair(Of L, R)).

    But where I would argue against this, is in the output.  It is FAR FAR preferable to call ToString rather than try a conversion. The basic reason is, that op_Implicit (Widening) and op_Explicit (Narrowing) conversions, are all Shared (aka static for those that are semi-colon retentive).  And Shared methods should generally not be used where the type in question is not sealed (not marked as NotInheritable or not Structure) .  There are exceptions to that, sure, but I still think that using interfaces is preferable, and ideally you should use instance methods.  So where Cameron had :

     

       Shared Narrowing Operator CType(ByVal Value As DelimitedPair(Of L, R)) As String
            'TODO: Error checking.
            Return _
                LateCType(Of String)(Value.m_Left) & _
                Delimiter & _
                LateCType(Of String)(Value.m_Right)
        End Operator

        Public Overrides Function ToString() As String
            Return CStr(Me)
        End Function

     

    That actually should have been the other way round.  That is, the CType operator method should have called the instance method, not the instance method calling a shared method.

      Shared Narrowing Operator CType(ByVal Value As DelimitedPair(Of L, R)) As String
             Return Value.ToString()
      End Operator

      Public Overrides Function ToString() As String
            Return _
                Me.m_Left.ToString & _
                Delimiter & _
                Me.m_Right.ToString
      End Function

     

    Okay, so at this point, we've just removed the late binding calls, because we have the framework where all things derive from object, and hence have the .ToString method

     

    I still like the LateCType method Cameron came up with, but like this, I would also try to avoid it ;)  And definetly try to avoid using shared methods on instances.  It's always preferable to use that isntance and hence call an instance method, not a Shared method.

     

     

     

     

     

     

     

     

     

    Posted by bill | 1 comment(s)
    Filed under:

    query comprehensions ?

     

    Oh, Paul is such a tease !!  

     

    People will be asking what are "query comprehensions", what are "object initializers", and what's this really cool dynamic programming that VB's getting that C# isn't ?

    Well I'm not allowed to tell ya, at least not till after PDC.  I think it's because if those script kiddies got wind of what VB has planned they'd be either crying or rioting in the streets (or both).    We all remember that shameful commotion some folk made when they saw how cool E&C was in VB.NET.  We certainly don't want to encourage more of that.  So if you think you might be one of those folks who gets envious of all the cool stuff VB.NET Orcas will have, don't be upset, you too can be part of the next wave, just brush up on your VB.NET skills today :)  Oh, and you might want to catch Paul's session at PDC ...

    Posted by bill | with no comments
    Filed under: , ,