News for hackers. Stuff that matters.
Re:Porting 58000 lines of D and C++ to jai, Part 0: Why and How by WalterBright on Wednesday November 23, 2022 @08:24PM (#33726784)
> D is closer to C++ than C

I'd put C++ as being between C and D, as D leaves a lot of things behind like the preprocessor.

Re:Porting 58000 lines of D and C++ to jai, Part 0: Why and How by SilentLambda on Wednesday November 23, 2022 @11:17PM (#33727743)
.. you forgot to mention also, that (in the context of a D module) D stops treating a user-defined class-type as real type. Additionally, a D class is a reference type. Whereas in C++, a class type is a real type (treated as any built-in type), and is a value type (by default).

Nor does D have a concept of C++ friend.

So even when it comes to classes, C++ and D are miles apart.

Re:Porting 58000 lines of D and C++ to jai, Part 0: Why and How by WalterBright on Wednesday November 23, 2022 @11:37PM (#33727849)
D structs are value types, D classes are reference types. This was done to avoid mistakes like having a type that is sometimes used as a value type and sometimes as a reference type.
Re:Porting 58000 lines of D and C++ to jai, Part 0: Why and How by SilentLambda on Thursday November 24, 2022 @04:47AM (#33729451)
Would have been much better in my opinion, if D had maintained a C like struct (not a C++ like struct), and a C++ like class. That would have solved the problem you identified, while still allowing for the class to be what it was designed to be. The mistake C++ made was the mistake you identified. But the solution you provided in D is its own mistake.
Re:Porting 58000 lines of D and C++ to jai, Part 0: Why and How by WalterBright on Friday November 25, 2022 @03:04AM (#33740283)
The C++ class would require the user to constantly remember it has to be passed by reference, not by value. D making the class a reference type means the user cannot mix them up.

It has worked well from the beginning, it is not a mistake.

Re:Porting 58000 lines of D and C++ to jai, Part 0: Why and How by SilentLambda on Saturday November 26, 2022 @06:29PM (#33758081)
..and in the context of a module.. not even used as a type at all.
Re:Porting 58000 lines of D and C++ to jai, Part 0: Why and How by ibgeek on Wednesday November 23, 2022 @11:28PM (#33727796)
Honest question: as a GC’d language, D seems to occupy the same niches as Go, JVM-based, and CLR-based languages rather than that of C++. Wouldn’t it be more accurate to compare to them than C/C++? Am I misunderstanding something?
Re:Porting 58000 lines of D and C++ to jai, Part 0: Why and How by WalterBright on Wednesday November 23, 2022 @11:34PM (#33727839)
D isn't a GC based language. The GC can be used, or not used, as the user chooses. D supports many different programming paradigms.
Re:Porting 58000 lines of D and C++ to jai, Part 0: Why and How by ibgeek on Thursday November 24, 2022 @12:04AM (#33727962)
Ah! Okay, that’s what I was missing. I found the blog posts on using malloc and free from D. I knew the GC could be disabled, but I wasn’t aware of how practical it was to manually manage memory. Thanks!
Re:Porting 58000 lines of D and C++ to jai, Part 0: Why and How by WalterBright on Thursday November 24, 2022 @01:04AM (#33728209)
It's not necessary to disable it, just don't use it.