10
$\begingroup$

I have an API that for an order routing platform that is in visual basic. The maximum frequency or orders to exchanges will be milliseconds, where the underlying systems are expected to be able to process a maximum of 1 order per millisecond.

Generally I would like to write in C++ or Java when I have this level of speed in mind, and have a broad stigma against visual basic for being inherently slower.

But since 1 millisecond is a long time in computer time, is visual basic still fast enough?

The algorithm will be reading information from the exchanges, crunching a few numbers and determining an order to send back to the exchanges.

I am estimating latency of 120 milliseconds, 1 millisecond to do the computational math, and then another 120 milliseconds back to the exchange. or less of course, but I know where the computers are geographically and this is about how long it should take.

I would like to keep the computational time at 1 millisecond, this isn't really a stretch for visual basic on a modern computer correct? (the local machine won't be doing much processing, as it will be fed most relevant data from the clearing firms data feeds)

$\endgroup$
4
  • $\begingroup$ This question is likely too open ended. I am sure the people who can answer you best need to know more about the type of calculations, etc you're doing... $\endgroup$ Feb 8, 2012 at 3:24
  • 4
    $\begingroup$ Unless you're trying to pairs trade across the Atlantic, with a 120ms latency I honestly wouldn't worry too much about sacrificing 1 or 2ms on computation. You won't be even close to being competitive on speed, so you may want to focus on strategies that work within that frequency space. $\endgroup$
    – emsfeld
    Feb 8, 2012 at 17:01
  • $\begingroup$ emsfeld, I'm not going for high frequency trades, and ideally the brokerdealer and clearing firm were located geographically closer, but this is the estimation I have thanks! $\endgroup$
    – CQM
    Feb 8, 2012 at 20:29
  • $\begingroup$ Short answer: yes. I am doing it all day long. Or better: VB is doing it... $\endgroup$ Feb 10, 2012 at 8:53

5 Answers 5

10
$\begingroup$

All .NET languages are perfectly able to compete with the speed of C and even FORTRAN. It all depends on if they are used the correct way.

1) Both Java and .NET have considerable longer startup times than most native app. Therefore, you will have to have the application running and not starting it over and over on request.

2) Memory management is crucial when using managed heaps and if you are in need of reliable peak performance. Make sure, not to allocate large arrays over and over, since this will stress the GC too much and produce larger latencies.

3) Consider using optimized libraries. Some are around for C#/Visual Basic (ILNumerics) and Java (f.e. jblas). Recent tests have shown very good performance for numeric managed algorithms compared to native implementations and other frameworks.

4) Test your implementation and profile it! If you are positive, you could reach the performance goal with a C implementation, you can reach it with .NET as well.

$\endgroup$
5
  • $\begingroup$ I didn't realize this "All .NET languages are perfectly able to compete with the speed of C and even FORTRAN." thanks! $\endgroup$
    – CQM
    Feb 9, 2012 at 15:34
  • $\begingroup$ @user492238 Regarding 2): if I cannot use large arrays, I cannto use .NET!? $\endgroup$ Feb 10, 2012 at 8:55
  • 1
    $\begingroup$ +1 for the ILnumeric link (if I could ... ;) $\endgroup$ Feb 10, 2012 at 8:57
  • 1
    $\begingroup$ @user1194505 You should REuse them. Pooling is more efficient than REallocating. Especially for large(st) arrays. $\endgroup$
    – user492238
    Feb 10, 2012 at 9:03
  • $\begingroup$ @user492238 thanks. I misunderstood your point and agree to 100% $\endgroup$ Feb 10, 2012 at 21:04
11
$\begingroup$

The only way to find out is to try it!

It shouldn't take very long to write some simple code to simulate the computations you plan to do, and run it in a loop.

With current versions of Visual Basic (VB.net), performance should be comparable to Java in most cases because the basic technology (compiling to intermediate code and then running a just-in-time compiler) are roughly the same.

Performance in C or C++ may be faster. Then again, it may not. The only way to find out is to try!

$\endgroup$
1
  • 3
    $\begingroup$ +1 This is the only legitimate answer to a question of is X fast enough. Only the OP can answer that. $\endgroup$ Feb 8, 2012 at 14:00
2
$\begingroup$

Short answer: Yes. I am using it frequently.

The stigma regarding Visual Basic comes from the time, where VB5 was COM based with some dirty language quirks. This time, VB was intended for/ to be used within / in conjunction with Office' macros. .NET substantially changed the technology behind the language as well as removed most 'quirks' regarding usability. It is now on par with C# and all other .NET languages regarding execution speed.

$\endgroup$
1
$\begingroup$

From the computational (math) prespective, VB.net should be able to compete with Java and C/C++. The only possible problem can be the garbage collection (as in Java). Therefore don't forget to set server-type garbage collector and carefully organize/manage your data structures.

$\endgroup$
1
  • $\begingroup$ What would server gc help for? $\endgroup$
    – user492238
    Feb 8, 2012 at 22:59
-2
$\begingroup$

VBA is not useful for complex algorithms, in the sense that 1) coding is not efficient and 2) it has its limitations in terms of available resources on the net. You need to take into account that there are already a large number of institutions active in the high frequency segment, which means that they are your competitors. In order to ensure proper models (and to be faster than they are) you need to have excellent and efficient codes (COMPLEX!) optimized with the input of computer specialists. VBA is therefore a too simple language.

$\endgroup$
1
  • $\begingroup$ VBA is not VB.NET. It's unlikely the OP is asking about VBA $\endgroup$
    – user508
    Apr 14, 2012 at 0:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.