Master thesis

ketmar via Digitalmars-d digitalmars-d at puremagic.com
Sat Jul 1 08:58:04 PDT 2017


Dgame wrote:

> On Saturday, 1 July 2017 at 14:40:36 UTC, ketmar wrote:
>> Dgame wrote:
>>
>>> Which impact would have D on the software-architecture, if it would be 
>>> choosen for a 2D game instead of C/C++?
>> i can actually finish 'em. most of the time when i'm working with D, i 
>> feel that compiler tries to help me. EVERY TIME i'm working with C/C++, 
>> i know for sure that compiler silently setting traps for me ('cause it 
>> is absolutely impossible to write safe and secure C/C++ code
> Do you have examples (code and/or personal experience) about that?
basically, all of my projects. ;-) like zx spectrum emulator, which took 
monthes in C, and only weeks in D (and it almost on par feature-wise with C 
version, and even more advanced in some areas like FDC emulation).

>> -- tnx to standard committee and compiler implementers, anything can 
>> turn into UB unexpectedly, and writing UB-free code is tedious and it 
>> will have UB anyway).
> Is that described somewhere? Or do you have examples or both?
ah, many people are complaining. just recent ones (there are MUCH MORE out 
there, just follow the links in the articles, for example):

http://www.yodaiken.com/2017/06/26/the-c-standard-versus-c-and-the-mother-of-all-hacks/
http://www.yodaiken.com/2017/01/05/undefined-behavior-and-the-purpose-of-c/

everything compiler authors has to say is (see gcc bugzilla link in one of the 
articles): "it is permitted by the standard. don't write code with UB". 
that is, modern optimizing C compilers are *actively* trying to 
*subvert* your code. using modern C compiler ends up in you being punished 
for all kind of random things: compiler is using *any* your error against 
you. it probably helps to win some stupid compiler benchmarks, but it is 
crystal clear that modern C is not made to write real-world programs in it: 
programmer have to manually track the things, and make machine happy. this 
is exactly the *opposite* of the machine's purpose: it is machine's task to 
make human happy, and free human from tedious and error-prone work, not vice 
versa! ;-)

besides those issues, the GREAT advantage of D is well-defined low-level 
types. `uint` is always 32 bits, `short` is always 16 bits and 2-complement 
(and it has overflow defined!), and so on. no need to `stdint.h` anymore 
(and why do we need it in C at all? winning several CPU cycles on the 
occasion vs hours of fighting to write portable code... OBEY THE MACHINE, 
YOU WORTHLESS HUMAN! ;-)

i dropped C years ago, switched to D, and i will NEVER return. D was made 
by humans, for humans, not by committee and compiler writers to win useless 
benchmarks.


More information about the Digitalmars-d mailing list