Re: What has managed code achieved?
On 2008-10-21, Scott M. <s-mar@nospam.nosp amwrote:
>
I don't know how you can make that statement when different VB 6
applications had object references scoped differently. I could just as
easily say that most applications did have module scoped object variables.
In those situations, you (the developer) were required to manage the
object's lifetime and by association, any external resources used by that
object.
>
You make it sound as if it was an onerous task on VB6 developers to manage
object lifetimes. It was not. Almost all applications probably use a mix of
scope - but, the only time that setting a value to nothing really had any
meaning was if that object was scoped at a level that would preclude it from
immediate cleanup (module scope, circular references, etc). This is true in
VB.NET as well (except the part about circular references). A module level
reference will live for the lifetime of the application - unless you as a
developer do something to signal to the gc that you are done with it. And
that something is set it to nothing.
All you are doing is persisting the old myth that you must do object cleanup
on all objects in vb6, which is utterly false.
Just as a developer need do nothing with local values in VB6. Using is
syntactic sugar to ensure that non-managed resources get released in a timely
fashion. Something one didn't have to think about at all in VB6, since
reference counting ensured determinsitc finalization of objects - hence
automatic cleanup.
The downside of course to reference counting has more to do with performance
then anything else.
Not really. I love .NET and managed code - but, GC does not really change the
way that we managed object lifetimes in respect to VB6, except to make it
slightly more difficult, because now the developer has to be more aware of the
objects they are using - do the implement IDispose?
What GC and managed code buys us is more about performance and code saftey. GC
is faster then ref counting - in other words, object allocation/deallocation
is much faster ina GC system.
--
Tom Shelton
On 2008-10-21, Scott M. <s-mar@nospam.nosp amwrote:
>Scott - most of the time explicit managment of references was not
>necessary in
>VB6 either. About the only time that setting an object reference to
>nothing
>amounted to anything is if the object was a class or module level value -
>which is about the same as VB.NET. In VB6 local variables were
>automaticall y
>claimed when the method exited - well, assuming there wasn't a bug in the
>underlying COM objects implementation :)
>>
>--
>Tom Shelton
>necessary in
>VB6 either. About the only time that setting an object reference to
>nothing
>amounted to anything is if the object was a class or module level value -
>which is about the same as VB.NET. In VB6 local variables were
>automaticall y
>claimed when the method exited - well, assuming there wasn't a bug in the
>underlying COM objects implementation :)
>>
>--
>Tom Shelton
I don't know how you can make that statement when different VB 6
applications had object references scoped differently. I could just as
easily say that most applications did have module scoped object variables.
In those situations, you (the developer) were required to manage the
object's lifetime and by association, any external resources used by that
object.
>
object lifetimes. It was not. Almost all applications probably use a mix of
scope - but, the only time that setting a value to nothing really had any
meaning was if that object was scoped at a level that would preclude it from
immediate cleanup (module scope, circular references, etc). This is true in
VB.NET as well (except the part about circular references). A module level
reference will live for the lifetime of the application - unless you as a
developer do something to signal to the gc that you are done with it. And
that something is set it to nothing.
All you are doing is persisting the old myth that you must do object cleanup
on all objects in vb6, which is utterly false.
In .NET, using Using, the developer need not do anything.
>
>
syntactic sugar to ensure that non-managed resources get released in a timely
fashion. Something one didn't have to think about at all in VB6, since
reference counting ensured determinsitc finalization of objects - hence
automatic cleanup.
The downside of course to reference counting has more to do with performance
then anything else.
This is one aspect of what working with managed code buys us.
way that we managed object lifetimes in respect to VB6, except to make it
slightly more difficult, because now the developer has to be more aware of the
objects they are using - do the implement IDispose?
What GC and managed code buys us is more about performance and code saftey. GC
is faster then ref counting - in other words, object allocation/deallocation
is much faster ina GC system.
--
Tom Shelton
Comment