-
Notifications
You must be signed in to change notification settings - Fork 590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Late binding #219
base: master
Are you sure you want to change the base?
Late binding #219
Conversation
Switching Scripting.Dictionary to late binding.
Mac support
Surely this should be a compilation option? |
I don't agree with this PR, it has a horrible effect on performance. Late binding can be hundreds of times slower than early binding. The solution to the naming conflict is not to introduce sloppy performance problems, it is to not use ambiguous names, that is use the library name prefix. Here is a quick test that shows how bad late binding can be: Sub Test()
Dim T As Single, O As Object, I As Long, D As Dictionary
T = Timer
For I = 1 To 10000
Set O = CreateObject("Scripting.Dictionary")
O.Exists "key"
Next I
Debug.Print Format(Timer - T, "0.000")
T = Timer
For I = 1 To 10000
Set D = New Dictionary
D.Exists "key"
Next I
Debug.Print Format(Timer - T, "0.000")
End Sub Output:
|
Afraid this is a naive approach. Second, name conflict are not always solved as easilly as you think (immagine the nightmare on project with million of lines of codes and more dependencies than fingers on your hands and feets), impacts can go from minimal (easy case) to hundred of days of work (nightmare case). Finally, name conflict is only one of the issue provided by early binding, version conflict is probably the worst one (remember that developers have no controls on end user computers). |
I have been using this module for years. In the past only for small data structures because it was unusable on some computers because it was too slow. Converting the same dictionary to JSON on my computer and a few other ones would take 1 second, but there were 5-6 computers on my company where it would take 15 minutes. After upgrading to one of the latest revisions (I don't remember which one, I think there were improvements on how the buffers are managed) all of a sudden it became fast on all computers and I have finally started using it also with large data structures. Switching from early to late binding would force me to abandon this module again and go back to my personal tricks to solve performance problems. The test in my previous post has only 10000 calls to one method. I often have data structures that require much more method calls, late binding would make this module unusably slow and I would need to go back to my old contraption (or keep my branch with early binding :) ) True, name conflicts are not always solved so easily, but declaring the namespace is most of the time the first thing to try and the most likely to succeed (at least in my experience). True, readability is very important, and both True, producing the expected behavior is very important, and I can assure you that hiding behind late binding is the last resource and should only be used to when different computers could have different and incompatible versions of the same component, and the add-in uses only methods that are compatible across all the versions. But a |
I think that, as far as possible, any changes to the existing behaviour of modules should be driven by options, the existing behaviour remaining the default. In this case, to avoid a compiler error, we need to use conditional compilation. I hope we can agree that I propose:
and then in
This is backwards compatible and allows full flexibility for Windows users. No code modification is needed if the project properties are used. |
Suggestion to switch the library to Late binding to prevent known issues with Early bound libraries (type names conflicts).