> Frank Christoph wrote
> > It's partly a failing of Haskell, but
> > it is more because of the operating system which is completely biased towards
> > imperative languages and hence forces client programs to do practically
> > everything even though it could reasonably provide generic algorithms to
> > perform the dirty work.
>
> Very interesting remark. Could you give some examples of things that
> an operating system could do to support languages like Haskell?
Well, this is not an instance of `generic algorithms', but for example, Haskell's
I/O system is partly based on the assumption that the real world will always
demand the result of a program. An operating system better suited to the
(lazy) functional paradigm might provide a mechanism for executing programs
lazily.
There's really much more to it than that, of course. Nearly all operating systems
are still based on the `typeless' model of programming inherited from unsafe
languages like C. For example, in Unix you can only pass in strings as arguments
or environment variables, and I think interprocess communication is completely
untyped. Surely it would be convienient if you could pass around more structured
data. As another example, an OS that understood static type systems could use the
greater safety guarantees to run well typed programs in unprotected memory frames
and avoid the overhead needed to trap segment violations, etc.
In fact, it is not too far-fetched to completely forego the idea of a conventional
operating system and replace it with a sufficiently flexible programming language.
Olin Shivers is doing work on an experimental operating system called Express
that uses conventional drivers for the very lowest level of the system, but
replaces the rest of it with Standard ML. Think how nice it would be if, instead
of thousands of unstructured files whose only type identification is a flimsy
little 3-character file extension, you could associate a module type with each
file. (Frankly, though, I don't know if that's the sort of thing the Express team
has in mind.)
-- FC
P.S.
My use of the term `generic algorithms' was really pretty sloppy. There are OSes
like Spin which let you replace kernel routines, so you can do something akin to
specializing system libraries, etc., but they are based on an object-oriented
paradigm rather than a functional one. That's fine for object-oriented languages,
but languages like Haskell are fundamentally different and deserve better support.
Extant operating systems ignore so much potential type information that I have a
hunch that any operating system which actually took advantage of a powerful,
statically decidable type system in the same vein as Haskell's or ML's would see
order-of-magnitude performance gains in some areas. (But don't quote me. :)