2 ms·
One thing that makes porting D code easy is byte, short, int and long have the same size across all platforms. It's unbelievable how much time is wasted in C/C+
by WalterBright 6y ago
One thing that makes porting D code easy is byte, short, int and long have the same size across all platforms. It's unbelievable how much time is wasted in C/C++ programming accounting for int not being a reliable size. I know one can use stdint.h, but people still just use `long` and then the code breaks when ported between OSX and Linux.
Another simple but convenient feature is, what if you need the maximum size of an int?
#include <limits.h>
int max = INT_MAX;
But what about:
typedef int myint;
myint mymax = MYINT_MAX; // oops
D has properties, here a .max property:
int max = int.max;
typedef int myint;
myint mymax = myint.max;
Nice things like this eliminate a lot of porting bugs.