[Shootout-list] C++ pidigits

Einar Karttunen ekarttun@cs.helsinki.fi
Wed, 16 Mar 2005 09:06:14 +0200


Brent Fulgham <bfulg@pacbell.net> writes:
> In general, I don't like to use external libraries
> unless they are in wide distribution (or more
> importantly, that they are available as a Debian
> package I can install).

This becomes quite problematic. For every problem there is probably a
library which solves things faster than the general purpose systems in a
language runtime. 

Many languages can call libraries with a C like interface with very
little code. One benchmark where this would be a major performance
altering thing is anything matrix related.. 

Solving benchmarks can become finding the fastest library implementing
the task and then using that. If one language is allowed to use the
library it is not very fair to forbid it from other languages. Which
languages would be permitted to use e.g. lapack or blas? 

Also external libraries have a huge difference to LOC. Haskell would get
many benefits if we used a third party optimized IO library, but I don't
think that would be very fair.

e.g. for matrixes a C++ source could have:

extern "C" {
#include <mymatrixlib.h>
}

and in Haskell

foreign import ccall "createMatrix" createMatrix :: CInt -> CInt -> IO (Ptr a)
foreign import ccall "multMatrix"   multMatrix :: Ptr a -> Ptr a -> IO (Ptr a)
foreign import ccall "matrixRef"    matrixRef  :: Ptr a -> IO Double

Both use a library from a foreign language...

- Einar Karttunen