How does D improve design practices over C++?

Walter Bright newshound1 at digitalmars.com
Wed Oct 29 00:13:52 PDT 2008


Janderson wrote:
> Hi,
> 
> I was talking with some collages at work and they asked me how D 
> enforces good programming practices.   For course I mentioned a couple 
> of the ones I knew of hand -
> 
> - Unit checking
> - Design by contract
> - Invariant checks
> - Stronger const
> - Modules
> - Garbage collection
> - No automatic copy constructor
> - More restrictive operators
> - Delegates (Specifically, encouraging there use by making them simple 
> to use)
> - Specific constructs such as Interfaces
> - More restrictive casting
> - No C style Macros
> 
> I'm sure I've missed a lot in this area.  I'd like to email them a good 
> list of "good coding design" that D promotes through syntax.  Note: The 
> C++ verse D page is not what I'm looking for.  I'm more interested in 
> coding practices then anything else.  For instance things that you can 
> mess up in C++ but D won't let you.

It's a good idea to come up with such a list. Let me add:

- Overload sets which prevent function call hijacking
- Nested functions
- Structs with value semantics, Classes with reference semantics
- Ability to move (bitcopy) a struct without invoking construction
- Alias parameters to templates
- Compile time function evaluation
- Function, array, and struct literals
- String mixins
- In, reference, and out function parameters
- Lazy function parameters
- Standardized way of doing conditional compilation
- Standardized way of debug conditionals
- Warnings on implicit casts that lose bits
- No uninitialized data
- User defined default initializers for typedefs and fields
- Template constraints




More information about the Digitalmars-d mailing list