When designing programming languages, the hard choice is not about
what you put into the language -- it is what you leave out or what is
mutually exclusive. Haskell did make the choice of being a purely
functional programming language and they did the choice of being
lazy. The positive things manifesting from this is: Lazy evaluation
finds more normal forms than strict evaluation. In the simply typed
lambda calculus it finds all of them but I am not sure this is
the case in Haskell. Secondly, since the language is pure the compiler
is free to reorder computations as it sees fit. Languages which are
strict have an evaluation order limiting how we can reorder
terms. Standard ML is extremely limiting in this respect due to the
correct handling of IEEE floating point numbers and that arithmetic
overflow must throw exceptions.
It is possible to have a strict functional language with added
references and exceptions. These effects can, without too much hassle,
be added to the language in a way such that the implications are
minimal. Ocaml and Standard ML are the main examples, I believe. We
all know that Haskell took the monad route to add effects. A heavy
inspiration from Category Theory gave them a tool to build in effects
by encoding them as monads. It should be noted that there are other
ways to add effects into a purely lazy functional language as is shown
by Clean.
I don't like monads for programming effects. Granted, they give me a
way to formalize (in the type) what effectful computations a given
function have and that can be a tremendous help. But on the other
hand, it also forces me to lift computations into the monad as soon as
I bring it into play. First of all, the lifting adds a lot of boilerplate
code. If I need a monad transformer, this quickly gets out of hand: My
code tends to be invocation of the correct lifts into the
monads. Second, as effects can alter control flow, there is often the
requirement of doing global changes to the program. The changes are
not limited to the function using the effect only - the infection
spreads to the callers and often further up the call chain.
And SML is not perfect at all too: We have a lot of old cosmetic
changes we ought to do. And we better get a grip on how to add linear
typing and an effect system so we can reap the benefits that monads
does give you without all of the hassle.
-
-
As I am typing this, Nine Inch Nails new album, Ghosts, is downloading happily in FLAC format in the background. You have to pay $5 to get it, but that is around 25 DKK which is next to nothing. I feel like I ought to pay some tribute to Trent Reznor as he has produced so much good music through the ages. The $5 is vastly more than he would make, had he gone the usual record company way. I like paying Mr. Reznor. It is my hope that he will be inspired to produce more of his great music. I don't like paying a middle-man who has been factored out of the equation by time. Trent must pay some money for me to download the album in FLAC format. Though this is peanuts compared to the $5. On the other hand, he do not have to pay for the production of a CD, and nor do I want it. Is the price fair? I really do think it is. Note that we are now entering a new era, where you can publish your music on the internet. The record companies made a number of mistakes: They alienated their customers. They alienated their artists. They destroyed Napster, but did not have anything in its place. They promoted utterly bad artists by creating enormously expensive music videos. They didn't know statistics. They did not understand the internet as a media. Now, they must suffer and die.0
Add a comment
View comments