John Carmack on Functional Programming in C++

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Mon Nov 17 22:32:04 PST 2014


On Sun, Nov 16, 2014 at 10:06:33AM -0800, Walter Bright via Digitalmars-d wrote:
> http://gamasutra.com/view/news/169296/Indepth_Functional_programming_in_C.php
> 
> Anything John writes is well worth reading, this article included. He
> includes as shout out to D!
> 
> "It seems like there is a sound case for a pure keyword in future
> C/C++ standards. There are close parallels with const – an optional
> qualifier that allows compile time checking of programmer intention
> and will never hurt, and could often help, code generation. The D
> programming language does offer a pure keyword. Note their distinction
> between weak and strong purity – you need to also have const input
> references and pointers to be strongly pure."
[...]

Interesting article... He makes a pretty strong case for immutability
and purity in D, actually. He didn't mention TLS, but with immutable,
pure, and TLS by default, D could stand a pretty good chance of doing
well with concurrent programming. The imperative paradigm may not be
such a killer if you have TLS for almost all your data and keep most of
your code pure. Even if it's not strongly pure, in many cases it's still
thread-safe, unlike in C/C++ where the equivalent of __gshared by
default means that if you want to do multithreading, your code is unsafe
by default and you'll have a big headache trying to eliminate race
conditions.

This is a pretty valuable combination that D has, that we should pay
more attention to; it has long-term benefits for D.


T

-- 
Shin: (n.) A device for finding furniture in the dark.


More information about the Digitalmars-d mailing list