News for hackers. Stuff that matters.
Re:Teaching D from Scratch: Is it a viable first language? by WalterBright on Wednesday December 29, 2021 @10:51PM (#29733372)
Another issue with C being an allegedly good beginner language is strings. C is simply terrible at handling strings. Let's say I want to concatenate two strings:

    char *concat(char *p, char *q)
    {
        size_t plen = strlen(p);
        size_t qlen = strlen(q);
        char *r = (char*)malloc(plen + qlen + 1);
        assert(r);
        memcpy(r, p, plen);
        memcpy(r + plen, q, qlen + 1);
        return r;
    }
And never mind the issue of when to free() r. Contrast with D:

    string concat(string p, string q)
    {
        return p ~ q;
    }
P.S. Yes, I know about the potential overflow problem with `plen + qlen + 1`.
Re:Teaching D from Scratch: Is it a viable first language? by ziml77 on Thursday December 30, 2021 @01:20PM (#29739540)
I get that C tries to be incredibly barebones, but operations on strings are so common that it's crazy how bad the string handling in C is. It seems like it was designed under the assumption that all of your strings are stored in fixed-size buffers.

I might not pick D as a beginner language simply because it unfortunately isn't very popular, but I certainly wouldn't pick C as a beginner language.