News for hackers. Stuff that matters.
Re:“Mostly functional” programming does not work (2014) by qznc on Monday June 22, 2015 @08:55AM (#9757914)
What if you could do "fully functional" programming within a language that also allows OO, procedural, and generic programming?

My exhibit would be D. Here is the 'identity' declaration:

    T identity(T)(const T me) pure nothrow @safe @nogc;
It cannot have side effect (do IO,start a thread,etc) because "pure". It cannot throw any exceptions because "nothrow". It cannot do any pointer-magic shenanigans because "@safe". It cannot modify the argument because "const". It even guarantees that no memory will be allocated through the garbage collector because "@nogc".

(Yes, pure by default etc would be better, but such a change would break too much code at this point. Yes, Haskell looks cleaner, but this article is not about beauty.)

Re:“Mostly functional” programming does not work (2014) by TazeTSchnitzel on Monday June 22, 2015 @08:58AM (#9757932)
How does "pure" work? How does the D compiler know the functions it calls do not have side effects?

More importantly, however, D's type system is not as expressive as Haskell's.

Re:“Mostly functional” programming does not work (2014) by qznc on Monday June 22, 2015 @09:03AM (#9757954)
Pure functions can only call pure functions.

Details: http://dlang.org/function.html#pure-functions

And Haskell's type system is not as expressive as D's. E.g. records.

Re:“Mostly functional” programming does not work (2014) by egorl4r on Monday June 22, 2015 @10:35AM (#9758577)
I'm not very good at D, but if you are referring to row polymorphic records, Haskell can do that too (e.g. https://github.com/nikita-volkov/record-preprocessor/blob/ma...)
Re:“Mostly functional” programming does not work (2014) by marcosdumay on Monday June 22, 2015 @03:27PM (#9760626)
> And Haskell's type system is not as expressive as D's. E.g. records.

Please, don't go there. D lacks add types and anything that isn't a first order type. Its type derivation also isn't even remotely as powerful.

Re:“Mostly functional” programming does not work (2014) by mpu on Monday June 22, 2015 @09:12AM (#9758026)
But what a type! I would be much more inclined to annotate effectful code instead.
Re:“Mostly functional” programming does not work (2014) by qznc on Monday June 22, 2015 @09:50AM (#9758271)
Well, it can be done simpler. The D compiler can infer those annotations for template functions such as this. So with an implementation you can write:

T identity(T)(T me) { return me; }