Re:Why Rust ditched pure functions
by frozenport on Friday December 20, 2013 @08:58AM
(#6941351)
You would only use D if you considered it great.
[ Parent
| on HN ]
There are other reasons to use D, and indeed, most of the community came from languages without pure functions and did not want the feature before trying it.
However, it's one of those things where once you use it for a while, you begin to really appreciate it. Better optimization, autovectorization and cpu -> gpu code conversion are all unimportant reasons for checked purity in the type system. The important reason is that by constraining what functions do, it makes reasoning about complex systems easier.
Generally, after you've worked in maintenance on one large project that designed everything to be pure unless there's a very compelling reason not to, you start to really miss the feature when you go back to projects in languages without it.
Agreed there. But, on the other hand, D misses out on statically checked resource management, and IMO that is more important than purity in the niche Rust and D are targeted at (systems development). Of course, nothing prevents a language from having both. :-)
Re:Why Rust ditched pure functions
by WalterBright on Friday December 20, 2013 @01:41PM
(#6943145)
Purity has a large advantage when writing concurrent code, as pure functions don't need to be synchronized.
This is why D has enforced purity (via an attribute) rather than inferred purity.