magellan90


i've been asked an opinion on number-crunching using algorithms - the question was whether c++ or vba was more adaptable and effective. i have used vba to construct algorithms in excel and have no technical knowledge of c++ to really evaluate the difference. essentially we're looking for conversion speed from mass data input.

thanks for any response.




Re: algorithms vba or c++

Ji Zhou ¨C MSFT


Hi,

I am moving this thread to VBA forum, which is more appropriate than VSTO forum, for your question. Hope you can get an answer here.

Thanks

Ji







Re: algorithms vba or c++

ke wenzel

Hi magellan90,

In almost any circumstance c++ is going to execute faster than vba, however the efficiency of your algorithm is probably more important. Also, if you don't have an technical knowledge of c++, then you will have to deal with it's learning curve.

As far as being "adaptable and effective", it depends on a lot of things. If you are using MS Excel for your mass data storage, then your code development will be faster and easier if you use vba, and depending on your project, this may be more important than the algorithm's runtime speed.

KW





Re: algorithms vba or c++

magicalclick

Yeah, C++ will always be faster because it is closer to machine level, but you have to manage memory yourself. You will have to allocate and deallocate memory yourself. A lot of times you will run into memory leak (didn't deallocate) or worse lose of data (deallocate too early) if you are not careful.

And just like the guy said, it mainly depends on you. For example, sorting, you can have horrible O(n^2) or the optimized O(nlogn).

I would like to add one more point since you are asking VBA instead of C++ step-child C#. If you are using Excel, you will avoid OS Security. It makes deploying the program really easy because any regular user can run it. Of course you have to be careful Excel virus as well, but I don't think there is enough Excel virus out there to care.

Besides that, excel spreed sheet is a visible data storage and a lot easier to use Excel's own functions. Like sorting just use Excel's own sort. A lot of functions are already there, just using code to call them. Like Excel's Replace All is probably faster than you can make anyway. And you can even treat the sheet as DB table and perform SQL table merge, quite crazy.

Anyway, in short C++ is high performance but hard to manage. If you want to try something faster than VBA, at least try C# first because you don't have to deal with memory allocation.