Why is D unpopular?

Siarhei Siamashka siarhei.siamashka at gmail.com
Mon Nov 15 05:45:51 UTC 2021


On Monday, 15 November 2021 at 03:10:34 UTC, forkit wrote:
> I really like this video.. it compares doing gcd (greatest 
> common divisor) in 16 different languages. If I were running a 
> intro to programming course, I'd make them all watch this, as 
> soon as they walk into their first class.
>
> The link below starts where he compares the C++ vs D vs Rust 
> solution.
>
> In D, you just do it and quote '.. move on'.
>
> https://youtu.be/UVUjnzpQKUo?t=449

This video shows a suboptimal solution for D, because their 
implementation unnecessarily iterates over the array twice. Their 
C++ solution is much faster, because of doing processing in a 
single pass. But D can do it in a single pass too:

```D
int 
findGCD_from_the_video_if_you_dont_care_about_performance(const 
int[] nums)
{
   return gcd(nums.minElement, nums.maxElement);
}

int findGCD_twice_faster_for_large_arrays(const int[] nums)
{
   return gcd(nums.reduce!(min, max)[]);
}
```



More information about the Digitalmars-d mailing list