What are the prominent upsides of the D programming language?

Ruby The Roobster michaeleverestc79 at gmail.com
Mon Sep 21 22:18:44 UTC 2020

On Monday, 21 September 2020 at 11:04:43 UTC, Imperatorn wrote:
> Top reasons to use D instead of for example Rust, Julia, Go etc 
> :)

1. In C and C++, you have to define the size of the array. In D, 
you can just leave the brackets empty.
2. You can return an array directly. In C and C++, you would have 
to return a pointer to an array:

int* return_int_array() {
int* ret = new int[3];
return ret;
3.The foreach loop. Just iterates over things. You could also use 
a for loop in place of this, but writing out a foreach loop is 
shorter and is easier to read.

4.  Mixins. These allow mixing in strings into the code. These 
are not in C or C++.

Completely unrelated, but is this code valid?

import std.string;
import std.stdio;
T someTemplate(T) () {
//function template

void main(){
string template_type;
mixin("someTemplate!" ~ data ~ "()");

More information about the Digitalmars-d mailing list