5 reasons why you should NOT write DLLs

Since this subject returns over and over I would like to summarize all that I wrote previously about why you should not write DLLs and should stay with AFL for most of your AmiBroker programming.

  1. AFL is way simpler. Writing DLL plugins in C++ is orders of magnitude more complex and error prone than writing in AFL. It would take you at least 10x more time to write anything in C++ (DLL)
  2. When you write in AFL, AmiBroker protects against out-of-bound array access. When you write in C++ you are out of luck. C++ does not protect you from anything and you are getting crash (access violation) when you go out of bounds
  3. In AFL you don't need to care about declarations and memory allocation. In C++ you have to be very careful about both.
  4. AFL is forward and backward compatible. Plugins may not be compatible under certain circumstances. If your plugin uses CallFunction and the signature of called function changes (for example new arguments are added to the function), AFL is always compatible because it knows that function changed. Your old plugin would not know that and it will call function with wrong (old) number of arguments
  5. Any function calls to DLL are protected by critical section (because expecting non-programmers to write thread-safe, re-entrant code is unrealistic). When there are lots of calls to your DLL the performance will be impacted because other threads will wait on critical section.

So what are DLLs for?

The answer was given here: How to pass a DATE_TIME_INT, instead of a VAR_FLOAT back to Amibroker


Agreeing the all mentioned above, the other one requirement for DLL over AFL is code[Or Idea] sharing without exposing the code. Financial developers may have different ideas to develop trading system and they may realized that with lot of time and work behind it. So if they don't want to expose their code to their users, that AFL is not giving that option for compiling and converting in to a Machine code or IL. That's is the one part we are forced to write DLL over AFL. If AFL provides such feature in the future, that would be very helpful. And really thanks for the very sophisticated and easy to use analysis software.

1 Like

Hiding AFL formula in a DLL is a bad idea. People should never trade the system they don't understand.