FIX Protocol in Haskell (was Re: [Haskell-cafe] Talking to Java from Haskell?)

Daniel Cook danielkcook at gmail.com
Fri Jul 9 11:33:45 EDT 2010


> 1)  How stable/defined is FIX?

Not very.  There are several protocol versions, various vendors have
their own custom message types, there are service packs released
fairly regularly updating the protocol for new message types, etc.

> 2)  How large of a subset of FIX do you use?

I will be using a relatively small subset of the available FIX
messages, and my subset will change a lot at the beginning but then
stabilize.

> work overall.  If FIX has only one canonical implementation, changes
> frequently, or you'll only use a small portion of it, then b) would
> likely be simplest.

FIX has one canonical open source implementation (actually 2, but
they're the same program ported to C++ and Java).

Another option is to use Haskell's FFI to wrap the C++ implementation.

QuickFIX is designed exactly the way you *wouldn't* design it to make
interop with Haskell easy.  The API is based on callbacks to a class
which one extends.  The C++ uses lots of templates, and the .h files
are full of macros.

On the plus side, the program has a .idl, and is already SWIG-wrapped
for C#, Python, and Ruby.  Do you (or anyone) have experience wrapping
highly stateful C++ programs with Haskell FFI?  Are there examples
around? (Xmonad comes to mind, but I don't know if X11's API is C or
C++ ..)

I think I'm going to have to recreate the various message types in
Haskell's type system anyway.  Given that, maybe I should simply use
Haskell to implement a small, clean, extensible subset of this
protocol (what I need).  I can then test it heavily against the
QuickFIX implementation.

Opinions?

-- Dan


On Fri, Jul 9, 2010 at 2:31 PM, John Lato <jwlato at gmail.com> wrote:
>> From: Daniel Cook <danielkcook at gmail.com>
>>
>> Hi,
>>
>> Someone has written a large Java library (QuickFIX/J) which speaks a
>> gnarled, ugly protocol (FIX).  There don't appear to be any FIX
>> protocol libraries in Hackage.  I need my Haskell program to talk to a
>> 3rd-party system that only speaks FIX.
>>
>> Should I:
>>
>> a) Reimplement the protocol directly Haskell?  (This appears to be non-trivial)
>>
>> b) Wrap the Java library with some code to use a lightweight message
>> queue (zeromq) to send messages to my Haskell program?  (This would
>> require essentially re-implementing an abstracted subset of the the
>> protocol into 0MQ messages)
>
> I think you need to answer these two questions to make a decision:
>
> 1)  How stable/defined is FIX?
> 2)  How large of a subset of FIX do you use?
>
> If FIX is relatively stable or has multiple (non-C) implementations in
> current use, and you'd be using a large-enough subset, then I expect
> implementing a Haskell implementation would be the smallest amount of
> work overall.  If FIX has only one canonical implementation, changes
> frequently, or you'll only use a small portion of it, then b) would
> likely be simplest.
>
> Another option would be to expose hooks to your Haskell program
> through the FFI and have it called by Java.
>
> John
>


More information about the Haskell-Cafe mailing list