views:

283

answers:

4

I have a home-spun 2000 lines VBScript script, that has become progressively slow with each additional code I add. It was created as a private debugging aid and now that it has become really useful. I want to polish it and ship it along with our product.

I thought I could speed it up by compiling it and making it an EXE. Furthermore I want to have a user interface for my tool, which might be possible once I use the extra libraries that the compiling platform might give me. I'm also considering extending the script by calling Win32 functions for whatever missing functionalities I require.

I have VB 6.0 or I can buy an external compiler. But I also need the created program (not the compiler itself) to run fine in Windows Vista. What are my best options?

+4  A: 

I would recommend downloading Visual Basic Express Edition (http://www.microsoft.com/express/vb/) and port your tool to VB.Net. However, that approach has one drawback - your program will be dependent on .Net. For the most part that shouldn't be a big problem, as by now most machines should have .Net 2.0, still it's better to keep it in mind.

I would stay away from VB6.0; however, aside from VB.Net I don't know any other good Basic compilers you could use.

Franci Penov
+4  A: 

There's probably more to the slowness than just the fact it's being interpreted. There are probably various optimisations you could make to it to make it faster. Try finding which parts of the code slow it down the most and try to speed them up.

Depending on what the code does VB6 could be fine. If it'll be dealing with natural text/filenames, then it would be better to use VB.net, 'cause VB6 doesn't support Unicode well.

But I get the feeling that even after compilation, it could still be slow, because compilation will only make it run faster, but not more efficiently.

Vincent McNabb
A: 

It's hard to say without knowing more of what the program is doing or how much data it's processing.

I agree with Franci - VB6 is no longer sold or supported so VB.Net would be the way to go for compiled code. (Express is free.) VBScript is not very much like VB.Net, so that might be a good bit of work to port unless it's all WMI or LDAP queries or something like that.

I would start out timing things to see where your bottlenecks are. Unless you're doing tons of looping and multi-level function calling you're probably stuck on external calls.

wscript.echo "Begin: " & Time
tStartTime = Timer
'... do stuff ...
tStopTime = Timer
wscript.echo "Elapsed time: " & tStopTime - tStartTime

Cheers

+2  A: 

Well ... there are a number of "good" BASIC compilers out there:

are the ones that come to mind immediately. Quite a few are listed on the mindteq site. (Jabaco is particularly interesting - VB6 re-expressed in Java. I've fiddled with it, and it looks very promising!)

But getting back to VBScript compilers, they do exist .. sort of. What they do is tokenise the code and put some kind of wrapper around them. Whether they run any faster is moot.

boost