It's pretty, but is it useful?
Aug. 19th, 2005 11:55 pm![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
haarStep x y = [s*(x+y), s*(x-y)] disorderedHaar [] = [] disorderedHaar (x:y:xs) = haarStep x y : disorderedHaar xs haar [a,b] = haarStep a b haar s = let w = disorderedHaar s in (haar (map head w)) ++ (map (!!1) w)
Divide-and-conquer algorithms come over amazingly naturally in Haskell; it's a deeply uncluttered language. First-class functions mean that it's almost always possible to abstract rather than to cut-and-paste; memory allocation and deallocation is dealt with by the garbage collector, looping by the magic of tail recursion. You can write down an algorithm in not many more words than you'd use in English, and with less ambiguity.
On the other hand, everything I've actually written in the language has been a pedagogical exercise. I've implemented pseudoprimality testing, Shanks' algorithm for square roots modulo p, arithmetic on elliptic curves, some rudimentary image processing, two different kinds of wavelet, a routine for counting polyominoes; didn't bother porting my sudoku solver from python. It's a great language for the sort of things I'd have written as a couple of hundred lines of BASIC on the Archimedes.
It may even be possible to write 'real applications'; but most of the real applications inside my head are highly graphical, pictures in the sense of maps from the complex space to a colour-wheel parameterised by arg f(x), to be computed either by vectorised assembly language or by pixel shaders (there's not much of a difference there, of course), and I wonder how to get to there from here, and once I've got there, how to distribute the result. The closest I can get to pictures are
hPutStr hdl "P6\n1000 1000\n255\n" hPutStr hdl (map chr (concat (map pix (newtonset 255 zz (1000,1000)))))
and that's punched-card-era: run the program to generate the file which can be loaded into the gimp. The model in my head is to have a routine compiling an expression-tree representation of what I want to do into machine code which the program can then call; can that actually be done?
I know I used to drip with ideas for that kind of thing, to plan web-sites of moderate grandeur in the bath. What's gone wrong?
no subject
Date: 2005-08-19 11:25 pm (UTC)ah, the eternal questions. you and me both :-(
umm, i hope that doesn't sound flippant. i know where you're coming from, because i'm there myself, d00m.
*hugs*
-m-
no subject
Date: 2005-08-20 01:43 am (UTC)There is a lot of interest amongst serious Haskell people in making the language useful for Real World applications, hence Simon Marlow's impressively brief demo web server. http://www.haskell.org/~simonmar/papers/web-server-jfp.pdf
I think they would be very interested in making haskell do graphical stuff better.
no subject
Date: 2005-08-20 11:19 am (UTC)