Garbage collection:
- Although it's always fun to mock people who fail due to memory leaks while using a garbage collected language...
- I think D simultaneously defeats C++ and Java/C# here...
- But, but, C++ has garbage collection libraries! Yea, in ten years of programming I haven't used a C++ garbage collection library. I have used Purify, Valgrind, and even overloading new and delete; looking for memory leaks (not to mention the NewStars code is loaded with memory leaks...)
- Java has garbage collection, and only garbage collection - unless you use Embedded Java, then you get no garbage collection! Enjoy!
- D "makes the easy case work". The default is garbage collection, with overrides for self-managed memory (of various forms).
- Doxygen ('///' and '/***/') works on C++ and Java (it's an extension of JavaDocs)
- However, it needs to run as a separate step of the build.
- This can be confusing. For example, I ran the debug build, and didn't see Doxygen (although it might be in there, with make spewing thousands of pages of output...). Some of the code uses it, some doesn't. So, I started converting everything to not use it (it's ugly and confusing, if you're not going to generate the docs). Until I discovered than there is a build that does use it (and the code not using it, needs it)
- Less ugly Doxygen style comments are built into the D spec. There is a compiler switch to do the docgen run.
- Programming is all about assumptions. When writing new code, you've got some idea of what's going on in the program, and what the inputs will be, and what sort of outputs you can create.
- Of course, assumption are made to be broken. That's why I'm always sprinkling my code with plenty of 'asserts'.
- DBC formalizes all of this. 'assert' is part of the spec (rather than being an ugly macro). Also, there are 'in' and 'out' blocks for functions (to check inputs and outputs). Classes have 'invariant' statements, which are processed before and after functions (to ensure class invariants are maintained).