News for hackers. Stuff that matters.
Re:Why care about functional programming? Part 1: Immutability by phkahler on Thursday March 19, 2015 @04:46PM (#9234508)
That's an awful lot of text to advocate for immutable data to prevent shooting yourself in the foot when things go concurrent.

I've got this renderer that takes a huge data structure and uses simple OpenMP constructs to draw images. There is an assumption that the underlying data will not change during a render. Do I need a functional language to enforce this? No. Would it be nice if C++ had a feature to enforce it? Yes. Will I eventually want to make something that can carefully modify the data while rendering? Maybe, but I'm not sure that even makes sense.

I think a bigger threat is event driven code which IMHO is notorious for making things happen in unexpected order.

Re:Why care about functional programming? Part 1: Immutability by sirseal on Thursday March 19, 2015 @08:55PM (#9235663)
I'm not that great at C++, but can't you use the const keyword to declare that something's value isn't changing?
Re:Why care about functional programming? Part 1: Immutability by tjradcliffe on Friday March 20, 2015 @01:28AM (#9236359)
You can. If you want to write immutable C++ simply declare every single variable const. Done.

The only difference between C++ and "immutable by design" languages is that in C++ you'd have to write your own little processor to ensure that your rule is followed (this is no big deal, and I've written much more complex processors to enforce C++ coding standards as part of the build.)

Re:Why care about functional programming? Part 1: Immutability by AgentME on Friday March 20, 2015 @01:49AM (#9236397)
const / final in most languages don't prevent the object from being mutated. They just stop the variable binding from being changed.
Re:Why care about functional programming? Part 1: Immutability by zzzcpan on Thursday March 19, 2015 @09:04PM (#9235693)
> I think a bigger threat is event driven code which IMHO is notorious for making things happen in unexpected order.

What do you mean by unexpected order? I find event driven code to be the easiest to understand and maintain. Typically, you will be forced to specify order explicitly, i.e. nesting callbacks for sequential execution or not for parallel.

Re:Why care about functional programming? Part 1: Immutability by phkahler on Friday March 20, 2015 @10:56AM (#9238068)
>> What do you mean by unexpected order?

Events are find if your app is stateless (boring). Otherwise you may get events when things are not ready for them. You can get around that with lots of checking, or perhaps building a nice OO system underneath may help. I have a hard time explaining this because it can be subtle. See the Therac 25 for an example.

http://en.wikipedia.org/wiki/Therac-25