Hmm - about manifest/enum
Walter Bright
newshound1 at digitalmars.com
Sat Dec 29 11:39:14 PST 2007
Derek Parnell wrote:
> So I guess its not a necessary requirement but it is a nice thing to have,
> so we can lower the cost of developing acceptable applications.
Constness has 2 main uses:
1) Better specification of an API. This is of little import for smaller
projects or projects done by a very small team. It becomes important for
large projects worked on by diverse teams. It essentially makes explicit
what things a function can be expected to change, and what things it
won't change.
2) It makes functional programming possible. The plum FP gets us is it
opens the door to automatic parallelization of code! C++ and Java are
dead in the water when it comes to automatic parallelization - if there
are multiple cores, the app needs to be painfully and carefully recoded
to take advantage of them. With FP, this can be done automatically.
Some secondary advantages are:
3) Better optimization.
4) ROMable data.
What languages we use definitely shape our thinking about programming.
C++ has a crippled const system which delivers about half of (1) and
none of (2). Java has no const at all, and doesn't deliver any of (1) or
(2). But since nearly all of us came to D from C++ or Java, it's hard to
see the value in something we have never known. It's like when the first
car came to town - who needs it? It's noisy, smelly, breaks down, and
gets stuck in the mud. My horse works just fine.
I've been willing to put so much work into const because solving this
problem will get us (1) and (2), and once those floodgates are open,
we'll all gaze in pity at the backwards folk still using horses <g>.
More information about the Digitalmars-d
mailing list