Completing C code with D style

pascal111 judas.the.messiah.111 at gmail.com
Tue Nov 16 00:40:27 UTC 2021


On Sunday, 14 November 2021 at 04:29:53 UTC, forkit wrote:
> On Saturday, 13 November 2021 at 23:02:15 UTC, pascal111 wrote:
>>
>> I touch that D is big language, it's not small like standard 
>> C. This will cost me much studying, so I think I need slow 
>> down and learn it step by step.
>
> Yes. C is so much smaller, and thus simpler (till you wanna do 
> something complex)
>
> But C also makes it 'simpler' to shoot yourself in the foot ;-)
>
> Even with your simple C code, which is so easily tranposed to 
> D, you already benefit from:
>
> - variables being always initialised before use
> (i.e no need to initalise i in your for loop, in D)
>
> - array indices being automatically checked for out-of-bounds
> (i.e. i < 10  ... in D.. it becomes.. numbers.length )
>
> so you can make your simple code, even 'simpler' in D ;-)

Thanks! I won't hide my real intention. Learning C to learning D 
is like the case of doctor Jekyll and Mr. Hyde, if I'm in the 
place of Jekyll, I treat Hyde as a son and I want to teach him 
programming, and we can't do that with C because it belongs to 
vertical thinking, while D belongs to Hyde or the horizontal 
thinking.


More information about the Digitalmars-d-learn mailing list