I have written some comments about the article written by Andrei Alexandrescu:
http://www.reddit.com/r/programming/comments/8t7s1/the_case_for_d_the_other_side_of_the_coin/ Andrei has commented some things on Reddit, I think it's better to move the discussion here. If there are wrong things in what I have written I'll fix them (Fixing a LiveJournal post is simple, probably simpler than fixing an article on DDJ). >I have seldom been this annoyed at a piece of feedback, and I've received my >share of bile.< I didn't mean to hurt feelings so much. I never had somethign against you or against D. >I have no idea what the author wants to convey.< I have answered that in the first few lines: >Giving false expectations in possible new D users is dangerous. I think that >giving a more balanced account of the current situation is better, even if in >future most of current D problems may be fixed.< I think your article shows mostly positive sides of D, even if what you say may become true in future. I think my comments (once fixed) are actually good for the spreading of D :-) >The article originates in some feedback that the author (I'd sent him a draft >for review) sent me, and that I considered unfit to integrate in the final >version.< The article doesn't originate from that, it originates just from the final article you have written on DDJ. >Some comments are patently false (such as the one that you must compile with >dmc to call C functions on Windows).< Is this true? I have seen many times people here answer that code has to be compiled with DMC, etc. If I am wrong I'll fix the text. >Some are ignorant (the author concluded that dmd can't optimize tail recursion >by trying it with the non-tail-recursive factorial function; and I took the >time to explain him!).< If I compile this D2 program with DMD: import std.stdio: printf; import std.conv: to; int sum(int[] a, int start=0) { if (start >= a.length) return 0; else { return a[start] + sum(a, start+1); //auto b = a[start]; //return b + sum(a, start+1); } } void main(char[][] args) { int n = args.length > 1 ? to!int(args[1]) : 1; auto a = new int[n]; foreach(i, ref x; a) x = i; printf("%d\n", sum(a)); } This is the cleaned up code I obtain: sum: L0: push EAX push EAX push EBX cmp EAX,010h[ESP] jb L12 pop EBX add ESP,8 xor EAX,EAX ret 8 L12: mov EDX,014h[ESP] mov EBX,010h[ESP] mov EAX,[EAX*4][EDX] push EAX sub ESP,4 mov EAX,010h[ESP] push EDX inc EAX push EBX call near ptr _D4test3sumFAiiZi add ESP,4 mov ECX,EAX pop EAX add EAX,ECX pop EBX add ESP,8 ret 8 main L0: sub ESP,024h push EBX push ESI cmp dword ptr 030h[ESP],1 jbe L23 mov EDX,034h[ESP] mov EAX,030h[ESP] mov EAX,8[EDX] mov EDX,0Ch[EDX] push EDX push EAX call near ptr _D3std4conv19__T11parseStringTiZ11parseStringFAxaZi jmp short L28 L23: mov EAX,1 L28: mov ECX,offset FLAT:_D11TypeInfo_Ai6__initZ push EAX push ECX call near ptr __d_newarrayT xor EBX,EBX mov ESI,EDX mov 014h[ESP],EAX mov 018h[ESP],EDX add ESP,8 cmp 0Ch[ESP],EBX je L53 L49: mov [EBX*4][ESI],EBX inc EBX cmp EBX,0Ch[ESP] jb L49 L53: push dword ptr 010h[ESP] xor EAX,EAX push dword ptr 010h[ESP] call near ptr _D4test3sumFAiiZi mov EBX,offset FLAT:_DATA push EAX push EBX call near ptr _printf add ESP,8 xor EAX,EAX pop ESI pop EBX add ESP,024h ret LDC is almost able to turn that tail-call into a loop (you have to split the final expression in two parts, I don't know if in the meantime such limit has being lifed), and GCC is able to. >Some are just nitpicky beyond belief.< I don't agree. Other anonymous people have answered lot of things in the comments in LiveJournal itself, in some time I'll fix things that have to be fixed, etc. Bye, bearophile
