Go vs D on reddit

bearophile bearophileHUGS at lycos.com
Fri Oct 8 18:44:53 PDT 2010


Andrei Alexandrescu:

> http://www.reddit.com/r/programming/comments/dohif/go_vs_d_interesting_thread_on_the_go_mailing_list/

Walter has just put the same link in the announce newsgroup.

Few quotations and comments from/about that Reddit page:

>we need a compiler which is good at type inference (SBCL already does it, I think) and which can get runtime statistics from a program run and will suggest type hints (I call it "profile-guided type inference", cf. "profile-guided optimization")<

This is not so useful for D, but it may be nice if the D compiler tells me what variables/arguments (that are mutable) may be annotated with const/immutable (or even enum, but this is less easy). Such comments aren't errors nor warnings, but suggestions. CommonLisp compilers often give many similar hints (when the optimization level required is high) to help the programmer optimize the code better. C-family compilers don't have the custom of doing such things, but I think this is a custom worth introducing in D language too.


>You need a bunch of stuff to do systems programming, none of which are supplied by C++. You have to even go outside the standard to cast an arbitrary integer into a pointer. Plus C++ provides no access to CPU registers, memory maps, the trap instruction, interrupt handling, multiple separate stacks, etc etc etc.<

It's true that standard C or C++ lack several things useful or necessary to write a kernel. GCC adds some of them as non-standard extensions, and then few other type system extensions are managed by external tools like the Sparse tool written by Linus. The Spec# language by Microsoft, shows other type system features useful to write acceptable kernel code with a safe language.


Following a short trail of links I've found this page, about how C# tests its variable initialization, it's quite cute:
http://en.wikipedia.org/wiki/Definite_assignment_analysis
D is less smart and more rough here, but to invent and implement this you may need more than one developer... I don't think you can ask Walter to implement that, even if the algorithm is known. I don't know how Mono devs have managed to implement it.

Bye,
bearophile


More information about the Digitalmars-d mailing list