www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Go vs D on reddit

reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
http://www.reddit.com/r/programming/comments/dohif/go_vs_d_interesting_thread_on_the_go_mailing_list/

Andrei
Oct 08 2010
next sibling parent reply bearophile <bearophileHUGS lycos.com> writes:
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 features useful to write acceptable kernel code with a safe language. 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
Oct 08 2010
next sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
bearophile wrote:

 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.
From the article: "The second way to solve the problem is to automatically initialize all locations to some fixed, predictable value at the point at which they are defined, but this introduces new assignments that may impede performance. In this case, definite assignment analysis enables a compiler optimization where redundant assignments — assignments followed only by other assignments with no possible intervening reads — can be eliminated. In this case, no programs are rejected, but programs for which the analysis fails to recognize definite assignment may contain redundant initialization. The Common Language Infrastructure relies on this approach." This is EXACTLY what D does, and did from day 1. The analysis to do it was implemented (by me) back in 1985 or so. It's OOOOOLLLLLDD technology, not some The term for it is "Dead Assignment Elimination." You can find it in compiler textbooks, even old ones. I learned about it in 1982 from Hennessey and Ullman. I strongly suggest you take a tour through the comments in the source code of the dmd optimizer. The global optimizer code is in files starting with 'g'. Optimizations not done by dmd: 1. loop unrolling, loop fusion 2. auto-vectorizing 3. use of sse fp registers You can rag on dmd for not doing them, but please, most standard data flow analysis done by compilers is old hat, is done in dmd, has been for decades, and is not some new fangled thing recently invented by other compiler marketing departments.
Oct 08 2010
parent reply Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
On 10/9/10, Walter Bright <newshound2 digitalmars.com> wrote:
 I strongly suggest you take a tour through the comments in the source code
 of
 the dmd optimizer. The global optimizer code is in files starting with 'g'.
I had a look at the sources a few days ago. I find it *awesome* that most of the functionality is fully documented + there's all those nice ASCII tree structure art everywhere (where needed, of course). You can only realize the scale of the size of the compiler once you see the code. But it's pretty readable imo. :p
Oct 14 2010
parent Walter Bright <newshound2 digitalmars.com> writes:
Andrej Mitrovic wrote:
 I had a look at the sources a few days ago. I find it *awesome* that
 most of the functionality is fully documented + there's all those nice
 ASCII tree structure art everywhere (where needed, of course). You can
 only realize the scale of the size of the compiler once you see the
 code. But it's pretty readable imo. :p
Thanks!
Oct 14 2010
prev sibling parent bearophile <bearophileHUGS lycos.com> writes:
 http://en.wikipedia.org/wiki/Definite_assignment_analysis
By the way, I forgot to add that Definite assignment analysis is a (nice) special case of "typestate", that I was talking about recently. Bye, bearophile
Oct 09 2010
prev sibling next sibling parent "Nick Sabalausky" <a a.a> writes:
"Andrei Alexandrescu" <SeeWebsiteForEmail erdani.org> wrote in message 
news:i8ofc0$il7$1 digitalmars.com...
 http://www.reddit.com/r/programming/comments/dohif/go_vs_d_interesting_thread_on_the_go_mailing_list/

 Andrei
Hey, cool, someone ("Netcob") over ther quoted me :) I'm a virus!
Oct 08 2010
prev sibling parent so <so so.do> writes:
On Sat, 09 Oct 2010 04:08:55 +0300, Andrei Alexandrescu  
<SeeWebsiteForEmail erdani.org> wrote:

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

 Andrei
The quality of discussions on that Reddit thing is getting closer to Youtuhe-comment level, rapidly. I wouldn't waste my time there anymore... -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Oct 08 2010