[Haskell-cafe] Re: binding to C libraries on Windoww

Andrew Coppin andrewcoppin at btinternet.com
Mon Dec 7 16:37:28 EST 2009


Jeffrey Scofield wrote:
> I think the real cultural difference is that you aren't a user, you're
> a prospective Haskell developer, as others have said.  Developers
> pretty much have to install tools (like compilers and preprocessors)
> and have to work with source code.
>   

And I have no problem with needing to install a Haskell compiler. If I 
had to install a seperate C compiler to make FFI to C work, that 
wouldn't seem unreasonable either. (As it happens, GHC has a C backend, 
so the C compiler just happens to be there already.) What does seem very 
weird is having to turn my Windows box into a psuedo-Unix system in 
order to write native Windows programs.

> Traditionally, Unix *comes with* thousands of tools that are useful
> to developers.  Windows traditionally came with none, at least
> none that I was ever able to find.
>   

True. By default, Windows assumes you are a clueless user, not an expert 
developer.

> Since many of the traditional Unix tools are available free, it
> makes sense that somebody would want to port them to Windows
> *for doing development*.  It's not so much a Unix emulation as
> a solution to the lack of native Windows tools.  Of course this
> makes sense especially to somebody who has gotten used to
> the Unix tools (such as myself).  I would never try to *develop*
> seriously under Windows using just what comes preinstalled.
>   

You can't develop anything with just what's preinstalled. (Well, unless 
you could writing batch scripts...)

Generally, if you want to develop C or C++ applications on Windows, you 
install MS Visual Studio. It gives you the compiler, linker, dependency 
management, and a whole bunch of other stuff. You typically wouldn't 
install gcc, ld and Automake. (Unless of course you were specifically 
trying to port existing Unix code, obviously.)

The thing is, if you're a C programmer on Windows, and you want to write 
(say) a program that talks to an Oracle database, typically what you'd 
do is install Visual Studio, download the Net8 client DLLs and header 
files, compile your application against the Net8 client header files, 
link everything, and when your program runs, it dynamically loads the 
Net8 DLLs and does its work. But it seems that if I want to talk to 
Oracle from Haskell, I'm expected to find the *source code* to the Net8 
client and *compile it from source*. This is highly unusual for Windows. 
(I wouldn't be surprised if Oracle haven't even released the source code 
for their Net8 libraries...) It just isn't the way Windows usually works.

Even without VS, if I'm working in C, all I really need is a compiler 
and a linker, and I can build an executable program that talks to 
Oracle. But with Haskell, it seems I need to be able to actually build 
the Net8 client from source - which, depending on how those sources are 
written, is likely to require an entire build system (Automake, a VS 
project, whatever). It's a much bigger undertaking than just compiling 
the few source file I personally wrote and linking a few bits together.

> This is not to say that on a given day it isn't frustrating
> when you can't get something to compile, especially
> if it's just a tool you need to compile something else.
>   

Oh, hey, I understand why things are like this. You make something work 
properly on Linux, and with not that much effort you can make it also 
work for BSD, Mac OS, Solaris, HP UX... even certain embedded devices 
can potentially run it. You want to make something work on Windows? You 
have to do everything totally differently. (No wonder people thought 
that things like Cygwin and MinGW were a good idea.)

One of the things that has impressed me about GHC is that it takes 
Windows seriously. The compiler and interpretter both work flawlessly on 
Windows. They don't try to teraform Windows into just another Unix, they 
actually try to do things The Windows Way. I like that. And it's not 
like all of Hackage is useless to me; anything that's 100% Haskell 
compiles and installs first time, almost every time. It's just 
frastrating that all the cool multimedia stuff I'd like to be doing 
requires access to C, and that's still currently very difficult. I 
understand not many Haskell people use Windows, so it's not so easy for 
people to test, and not so many people have a detailed knowledge of 
Windows. And with this latest discussion, I'm beginning to understand 
why binding to C is so hard.

But, yeah, it *is* still frustrating. ;-) And, unfortunately, I lack the 
knowledge or skill to be able to improve the situation...

> But this is why developers are so wealthy, they have the
> fortitude to work through these problems.  (Ha ha.)
>   

Heh, good one. ;-)



More information about the Haskell-Cafe mailing list