"The major evolution that is still going on for me is towards a more functional programming style, which involves unlearning a lot of old habits, and backing away from some OOP directions."
"The major evolution that is still going on for me is towards a more functional programming style, which involves unlearning a lot of old habits, and backing away from some OOP directions."
http://www.altdevblogaday.com/2012/04/26/functional-programm...
If I missed it, I can't be the only one.
This is a very good point that probably could be systematically exploited. Does anyone know examples of this?
Come to think of it, restricting mutable access to only the relevant objects as per function call using const seems to allow just this!
A function having only const input and output "should be" free of side effects (if no global mutables); while still being allowed to run all manner of unpure processes local to its own calling context.
import Control.Monad.ST
import Data.STRef
fact :: Int -> Int
fact n = runST (fact' n)
fact' :: Int -> ST s Int
fact' n = do a <- newSTRef 1
mapM_ (\x -> modifySTRef a (*x)) [1..n]
readSTRef a
Here the function `fact'` uses mutable variables (encoded in the use of `ST` in its type -- `ST` stands for State Thread) but the function `fact` is pure -- the call to `runST` ensures that none of the side effects leak out of `fact'`.As with most Haskell code, the types are optional - I included them for clarity.
I'd just like to make it clear to anyone else reading this. The types aren't optional, but because Haskell has type inference, specifying them is optional.
I don't know what's his stance on the subject since though.
That wasn't for functional programming though. It was instead for the built-in static code analysis the Haskell type system and compiler provides.
If your description is accurate, Rust[1] is exactly what he wants. I've been learning Rust recently (with a little help from [2]) and it does a ton of static code analysis, is safe by default (no dangling or null pointers, no shared mutable state), uses Hindley-Milner type interface just like Haskell, and generally is what you would expect if Haskell and C++ had a baby.
All too often, I've heard about some language, and then spent minutes trying to figure out what it is all about.
Rust is definitely worth a longer look by me.
http://gamasutra.com/view/news/169296/Indepth_Functional_pro...
http://www.reddit.com/r/haskell/comments/jap3x/im_very_tempt...
http://blogs.uw.edu/ajko/2012/08/22/john-carmack-discusses-t...