Are there any 100% pure languages (as I describe in the Stack Overflow post) out there already and if so, could they feasibly be used to actually do stuff? i.e. do they have an implementation? I'm not looking for raw maths on paper/Pure lambda calculus. However Pure lambda calculus with a compiler or a runtime system attached is something I'd be interested in hearing about.
|
|
Indeed, as Simon Peyton Jones once stated, Haskell is the finest imperative language out there. Seriously, purity is not a religious issue. The problem is not that impure functions and mutable data exist. The problems in conventional languages is that often you can't tell impure frm pure and mutable from immutable: not by looking at it, not by compiling it, only by running it. This is the great advantage that Clean, Haskell (and followers like Frege) have. Conversely, languages like F#, Scala or Clojure that embrace the imperative world and just add the possibility to build something functional alongside suffer from the same problems as the imperative languages, although they may seem very practical indeed. |
|||||||||||||
|
|
It seems to me you're trying to reinvent Haskell.
Nice description of how IO is done in Haskell.
You mean monads?
After the first half (M a) prompted the user to provide data (of type a), the second half (a -> M b) is the the "remainder" you describe. If Haskell allowed you to introspect functions instead of just allowing you to run them, it would also be homoiconic. |
|||
|
|
I would regard Haskell as 100% pure. And it can certainly get stuff done. While there are some good debates about what "100% pure" actually means, it is certainly not true that a pure functional language cannot do IO. See also the comp.lang.functional FAQ. All you have to do to allow IO in a pure language is pass a parameter that represents the state of the world to the program, and return the state of the world as an output. This program has no side effects, is referentially transparent and counts as 100% pure. This is pretty much what Haskell's IO Monad does under the hood. A special mention perhaps for Clojure, which is definitely a practical language with the entire JVM ecosystem and toolchain to your fingertips. It is clearly not 100% pure (since you can get side effects via the STM managed references, various IO functions or Java interop). However the core language if you avoid these special cases is purely functional. So if you stick to the pure subset of Clojure, you actually have a pretty decent pure functional language for most purposes. |
||||
|
|
A "pure" language that couldn't do IO couldn't do much. ...after all, even printing a result on the screen is IO. So if you can't see the result of a program, wouldn't it be rather pointless? You couldn't read files, couldn't listen to sockets, couldn't interact with users, couldn't ask for input... etc. What good would that be? That said, Haskell is the closest to "pure" (whatever that means) functional programming I know of. Their whole IO system is even made using Monads, which kind of a mix between IO and functional. I also know of "Clean" which is an academic functional language and sees IO as a transform of a World object if I remember right ...however, this starts to be very exotic. |
|||||||||||||
|