469 karma · joined April 12, 2009
http://www.github.com/batterseapower http://blog.omega-prime.co.uk/
I reported this to Oracle about 3 months ago (ref JI-9024492) but haven't heard anything since 2015-09-29, when they contacted me asking for some code to reproduce the issue (which I gave to them on the same day). :-/
type Promise a = (a -> IO ()) -> IO ()
getData :: Promise String
Whereas with callbacks you pass that around explicitly: getData :: (String -> IO ()) -> IO ()
Promises are a monad, so you get the usual monad advantages of being able to "hide the plumbing" behind the abstraction, hence no tower of explicit callbacks in your JS code. instance Monad Promise where
return x = \k -> k x
fmap f p = \k -> p (k . f)
mx >>= fxmy = \k -> mx (\x -> fxmy x k)When I do encounter a problem, the answer is almost always available after 5 minutes on Google.
Following the herd leads to an easy life. Go figure.
Strict languages can sidestep this problem to an extent but still end up with "wrong" numbers of inhabitants for e.g. T -> (), since (\_ -> ()) is different from (\_ -> undefined).
So the only guys living in pure algebraic bliss are the total functional programmers like the Agda aficionados.
Not sure what to say about your second point: you do have to store context for the other fibers, but only in the same way you have to pay to store the context of an OS thread or pending callback.
id x = id xThe type system is definitely a big part of this, but almost as important are algebraic data types and compiler checks for exhaustivity when scrutinising values of such types.
Apparently the AES-NI stuff is actually already part of the public OpenSSL codebase: http://datacenteroverlords.com/2011/09/07/aes-ni-pimp-your-a...
Of course, from the perspective of a Bittorrent client author it's much easier to implement TCP-over-UDP than to depend upon raw socket support / install a custom congestion control algorithm into the OSes TCP stack.
The reason the code here looks so complex is that Jaspers implementation adds additional abstractions so he can use the type system to distinguish between DCPU computations that can are pure (except insofar as they access DCPU memory) and those that are impure (in that they communicate with the outside world by e.g. writing to the console).
I don't think this is confined to just geek behaviour -- in my experience, it is typical human behaviour.