www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - [OT] My C++ talk at GoingNative 2013

reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
http://www.reddit.com/r/programming/comments/1m1izv/goingnative_2013_writing_quick_code_in_c_quickly/

Andrei
Sep 09 2013
next sibling parent reply "deadalnix" <deadalnix gmail.com> writes:
On Monday, 9 September 2013 at 16:43:54 UTC, Andrei Alexandrescu 
wrote:
 http://www.reddit.com/r/programming/comments/1m1izv/goingnative_2013_writing_quick_code_in_c_quickly/

 Andrei
So I'll jump in as I've seen the conf before that post. It is really worthwhile to watch. Quite informative on the technical side (funilly, I did implement the solution presented in the devirtualization part on a platform where virtual function were not available because of crappy compiler, but had no idea it was worthwhile for speed, it wasn't the goal so I never measured, and it also may not the case on the given plateform). Many discussed subject apply as well to D. By the way, what is the state of std.bitmanip in comparison to what is presented in the conf ? Also, Andrei, did you try LLVM/clang ? Related to going native, Chandler the discussion on signess of integers and I really wonder if we should follow the rule that make unsigned spread like a virus, as C does.
Sep 10 2013
parent reply Iain Buclaw <ibuclaw ubuntu.com> writes:
On 10 September 2013 11:10, deadalnix <deadalnix gmail.com> wrote:
 On Monday, 9 September 2013 at 16:43:54 UTC, Andrei Alexandrescu wrote:
 http://www.reddit.com/r/programming/comments/1m1izv/goingnative_2013_writing_quick_code_in_c_quickly/

 Andrei
So I'll jump in as I've seen the conf before that post. It is really worthwhile to watch. Quite informative on the technical side (funilly, I did implement the solution presented in the devirtualization part on a platform where virtual function were not available because of crappy compiler, but had no idea it was worthwhile for speed, it wasn't the goal so I never measured, and it also may not the case on the given plateform).
Interestingly enough, gcc recently added (about a month before Andrei did the talk) a new interprocedural analysis pass that sets all methods that can be devirtualised. I expect that LLVM have something cooking up for this too. As of yet, I haven't ran any tests which show that this works though... -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0';
Sep 10 2013
parent "PauloPinto" <pjmlp progtools.org> writes:
On Tuesday, 10 September 2013 at 13:20:18 UTC, Iain Buclaw wrote:
 On 10 September 2013 11:10, deadalnix <deadalnix gmail.com> 
 wrote:
 On Monday, 9 September 2013 at 16:43:54 UTC, Andrei 
 Alexandrescu wrote:
 http://www.reddit.com/r/programming/comments/1m1izv/goingnative_2013_writing_quick_code_in_c_quickly/

 Andrei
So I'll jump in as I've seen the conf before that post. It is really worthwhile to watch. Quite informative on the technical side (funilly, I did implement the solution presented in the devirtualization part on a platform where virtual function were not available because of crappy compiler, but had no idea it was worthwhile for speed, it wasn't the goal so I never measured, and it also may not the case on the given plateform).
Interestingly enough, gcc recently added (about a month before Andrei did the talk) a new interprocedural analysis pass that sets all methods that can be devirtualised. I expect that LLVM have something cooking up for this too. As of yet, I haven't ran any tests which show that this works though...
The main problem with devirtualization is that you can only have full benefits when targeting VM based environments. With native generated code, it is only possible to apply devirtualization on static linked code. -- Paulo
Sep 10 2013
prev sibling next sibling parent reply "Olivier Grant" <olivier.grant gmail.com> writes:
First of all, I very much enjoyed the talk. It was as interesting 
as it was entertaining.

I do have a question regarding the talk's section on 
devirtualization. As a language that imposes virtual methods for 
classes, how well does D play when it comes to devirtualization? 
And on a side note, does D have a different way of implementing 
virtual methods than most C++ compilers do?

Thanks,

O.

On Monday, 9 September 2013 at 16:43:54 UTC, Andrei Alexandrescu 
wrote:
 http://www.reddit.com/r/programming/comments/1m1izv/goingnative_2013_writing_quick_code_in_c_quickly/

 Andrei
Sep 10 2013
next sibling parent reply Iain Buclaw <ibuclaw ubuntu.com> writes:
On 10 September 2013 13:54, Olivier Grant <olivier.grant gmail.com> wrote:
 First of all, I very much enjoyed the talk. It was as interesting as it was
 entertaining.

 I do have a question regarding the talk's section on devirtualization. As a
 language that imposes virtual methods for classes, how well does D play when
 it comes to devirtualization? And on a side note, does D have a different
 way of implementing virtual methods than most C++ compilers do?
All class methods are virtual by default in D, unless declared 'final'. Devirtualisation is not something done by the front-end, but recent updates and interest from compiler back-ends may provide a solution. -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0';
Sep 10 2013
parent reply "Joseph Rushton Wakeling" <joseph.wakeling webdrake.net> writes:
On Tuesday, 10 September 2013 at 13:08:29 UTC, Iain Buclaw wrote:
 All class methods are virtual by default in D, unless declared 
 'final'.
There was an intense discussion a while back which ended in (I think) a decision by Walter to switch to final-by-default, but there has so far been no practical follow-up.
Sep 12 2013
next sibling parent Iain Buclaw <ibuclaw ubuntu.com> writes:
On Sep 12, 2013 9:16 PM, "Joseph Rushton Wakeling" <
joseph.wakeling webdrake.net> wrote:
 On Tuesday, 10 September 2013 at 13:08:29 UTC, Iain Buclaw wrote:
 All class methods are virtual by default in D, unless declared 'final'.
There was an intense discussion a while back which ended in (I think) a
decision by Walter to switch to final-by-default, but there has so far been no practical follow-up. Not sure how long ago that was, but dconf everyone agreed to disagree and left it at "we're not changing it". Regards -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0';
Sep 12 2013
prev sibling next sibling parent Sean Kelly <sean invisibleduck.org> writes:
On Sep 12, 2013, at 2:46 PM, Iain Buclaw <ibuclaw ubuntu.com> wrote:
=20
 Not sure how long ago that was, but dconf everyone agreed to disagree =
and left it at "we're not changing it". Here's a portion of the discussion where Walter seemed to change his = mind: = http://forum.dlang.org/thread/yzsqwejxqlnzryhrkfuq forum.dlang.org?page=3D= 26=
Sep 12 2013
prev sibling parent Sean Kelly <sean invisibleduck.org> writes:
On Sep 12, 2013, at 2:46 PM, Iain Buclaw <ibuclaw ubuntu.com> wrote:

=20
 On Sep 12, 2013 9:16 PM, "Joseph Rushton Wakeling" =
<joseph.wakeling webdrake.net> wrote:
 On Tuesday, 10 September 2013 at 13:08:29 UTC, Iain Buclaw wrote:
 All class methods are virtual by default in D, unless declared =
'final'.
 There was an intense discussion a while back which ended in (I =
think) a decision by Walter to switch to final-by-default, but there has = so far been no practical follow-up.
=20
 Not sure how long ago that was, but dconf everyone agreed to disagree =
and left it at "we're not changing it". I believe this decision happened after dconf as the result of a rather = long discussion in digitalmars.D. Someone referenced something written =
Sep 12 2013
prev sibling parent reply Jacob Carlborg <doob me.com> writes:
On 2013-09-10 14:54, Olivier Grant wrote:
 First of all, I very much enjoyed the talk. It was as interesting as it
 was entertaining.
Yes, I enjoyed it as well.
 I do have a question regarding the talk's section on devirtualization.
 As a language that imposes virtual methods for classes, how well does D
 play when it comes to devirtualization? And on a side note, does D have
 a different way of implementing virtual methods than most C++ compilers do?
In D it seems that currently the preferred way to compile a project is to compile all the source at once using RDMD or similar. Isn't that a great opportunity for full program analysis to do devirtualization? -- /Jacob Carlborg
Sep 12 2013
next sibling parent "deadalnix" <deadalnix gmail.com> writes:
On Friday, 13 September 2013 at 06:24:26 UTC, Jacob Carlborg 
wrote:
 On 2013-09-10 14:54, Olivier Grant wrote:
 First of all, I very much enjoyed the talk. It was as 
 interesting as it
 was entertaining.
Yes, I enjoyed it as well.
 I do have a question regarding the talk's section on 
 devirtualization.
 As a language that imposes virtual methods for classes, how 
 well does D
 play when it comes to devirtualization? And on a side note, 
 does D have
 a different way of implementing virtual methods than most C++ 
 compilers do?
In D it seems that currently the preferred way to compile a project is to compile all the source at once using RDMD or similar. Isn't that a great opportunity for full program analysis to do devirtualization?
No because export is ill defined. But it definitively should.
Sep 12 2013
prev sibling parent reply "Mathias LANG" <pro.mathias.lang gmail.com> writes:
 I do have a question regarding the talk's section on 
 devirtualization.
 As a language that imposes virtual methods for classes, how 
 well does D
 play when it comes to devirtualization? And on a side note, 
 does D have
 a different way of implementing virtual methods than most C++ 
 compilers do?
In D it seems that currently the preferred way to compile a project is to compile all the source at once using RDMD or similar. Isn't that a great opportunity for full program analysis to do devirtualization?
It may be a trend, but I hope it will never become D's official approach, because it doesn't scale. This would left out all the people that use the object-file based approach (and related tools, like Makefiles), which is dominant in the Linux world, and is required in some cases (limited hardware, distributed compiling, or simply huge projects).
Sep 13 2013
parent Jacob Carlborg <doob me.com> writes:
On 2013-09-13 09:40, Mathias LANG wrote:

 It may be a trend, but I hope it will never become D's official
 approach, because it doesn't scale. This would left out all the
 people that use the object-file based approach (and related
 tools, like Makefiles), which is dominant in the Linux world, and
 is required in some cases (limited hardware, distributed
 compiling, or simply huge projects).
D supports separate compilation, object files and libraries. I don't think it will ever stop supporting that. -- /Jacob Carlborg
Sep 14 2013
prev sibling next sibling parent reply "Olivier Pisano" <olivier.pisano laposte.net> writes:
On Monday, 9 September 2013 at 16:43:54 UTC, Andrei Alexandrescu 
wrote:
 http://www.reddit.com/r/programming/comments/1m1izv/goingnative_2013_writing_quick_code_in_c_quickly/

 Andrei
This talks are amazing. I learned a lot. Thank you all guys for your dedication and pedagogy. BTW, I really liked your face during the 'Ask us anything' panel, when STL talked about Garbage Collection! Congratulations for resisting the need to shout 'D does already solves this problem' at least a dozen of times. Too bad Native means C++ in Microsoft speak.
Sep 10 2013
parent reply "deadalnix" <deadalnix gmail.com> writes:
On Wednesday, 11 September 2013 at 05:27:35 UTC, Olivier Pisano 
wrote:
 On Monday, 9 September 2013 at 16:43:54 UTC, Andrei 
 Alexandrescu wrote:
 http://www.reddit.com/r/programming/comments/1m1izv/goingnative_2013_writing_quick_code_in_c_quickly/

 Andrei
This talks are amazing. I learned a lot. Thank you all guys for your dedication and pedagogy. BTW, I really liked your face during the 'Ask us anything' panel, when STL talked about Garbage Collection!
There is 2 ask us anything. Can you tell us which one and approximately when ?
Sep 12 2013
parent reply "Olivier Pisano" <olivier.pisano laposte.net> writes:
On Friday, 13 September 2013 at 06:51:52 UTC, deadalnix wrote:
 There is 2 ask us anything. Can you tell us which one and 
 approximately when ?
Yes, the first one ( http://channel9.msdn.com/Events/GoingNative/2013/Interactive-P nel-Ask-Us-Anything ) around 01:14:20.
Sep 18 2013
parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 9/18/2013 1:23 AM, Olivier Pisano wrote:
 On Friday, 13 September 2013 at 06:51:52 UTC, deadalnix wrote:
 There is 2 ask us anything. Can you tell us which one and approximately when ?
Yes, the first one ( http://channel9.msdn.com/Events/GoingNative/2013/Interactive-Panel-Ask-Us-Anything ) around 01:14:20.
Classic Andrei! :-) Should zoom in on that and make a gif!
Sep 19 2013
parent reply Justin Whear <justin economicmodeling.com> writes:
On Thu, 19 Sep 2013 14:31:28 -0700, Walter Bright wrote:

 On 9/18/2013 1:23 AM, Olivier Pisano wrote:
 On Friday, 13 September 2013 at 06:51:52 UTC, deadalnix wrote:
 There is 2 ask us anything. Can you tell us which one and
 approximately when ?
Yes, the first one ( http://channel9.msdn.com/Events/GoingNative/2013/Interactive-Panel-Ask-
Us-Anything
 ) around 01:14:20.
Classic Andrei! :-) Should zoom in on that and make a gif!
Yessir: http://imgur.com/W5AMy0P
Sep 19 2013
next sibling parent Walter Bright <newshound2 digitalmars.com> writes:
On 9/19/2013 3:56 PM, Justin Whear wrote:
 Yessir: http://imgur.com/W5AMy0P
!!
Sep 19 2013
prev sibling next sibling parent "Olivier Pisano" <olivier.pisano laposte.net> writes:
On Thursday, 19 September 2013 at 22:56:55 UTC, Justin Whear 
wrote:
 On Thu, 19 Sep 2013 14:31:28 -0700, Walter Bright wrote:

 Yessir: http://imgur.com/W5AMy0P
Thank you so much!
Sep 20 2013
prev sibling next sibling parent reply Justin Whear <justin economicmodeling.com> writes:
On Thu, 19 Sep 2013 22:56:55 +0000, Justin Whear wrote:

 On Thu, 19 Sep 2013 14:31:28 -0700, Walter Bright wrote:
 
 On 9/18/2013 1:23 AM, Olivier Pisano wrote:
 
 Classic Andrei! :-)
 
 Should zoom in on that and make a gif!
Yessir: http://imgur.com/W5AMy0P
I think I'm going to start posting simply this in response to any statement that I find dubious.
Sep 20 2013
parent reply "Tobias Pankrath" <tobias pankrath.net> writes:
On Friday, 20 September 2013 at 15:52:35 UTC, Justin Whear wrote:
 On Thu, 19 Sep 2013 22:56:55 +0000, Justin Whear wrote:

 On Thu, 19 Sep 2013 14:31:28 -0700, Walter Bright wrote:
 
 On 9/18/2013 1:23 AM, Olivier Pisano wrote:
 
 Classic Andrei! :-)
 
 Should zoom in on that and make a gif!
Yessir: http://imgur.com/W5AMy0P
I think I'm going to start posting simply this in response to any statement that I find dubious.
It has quite some meme potential ^^
Sep 20 2013
parent "Joakim" <joakim airpost.net> writes:
On Friday, 20 September 2013 at 16:09:46 UTC, Tobias Pankrath 
wrote:
 On Friday, 20 September 2013 at 15:52:35 UTC, Justin Whear 
 wrote:
 On Thu, 19 Sep 2013 22:56:55 +0000, Justin Whear wrote:

 On Thu, 19 Sep 2013 14:31:28 -0700, Walter Bright wrote:
 
 On 9/18/2013 1:23 AM, Olivier Pisano wrote:
 
 Classic Andrei! :-)
 
 Should zoom in on that and make a gif!
Yessir: http://imgur.com/W5AMy0P
I think I'm going to start posting simply this in response to any statement that I find dubious.
It has quite some meme potential ^^
Heh, when I loaded it imgur claimed that 2 MB gif had already been downloaded almost 150k times, using 250 GBs of bandwidth. I had no idea the D forums were so popular. ;) Then, I reloaded the imgur page again and it cut the stats by a factor of 100, still not bad. I'm guessing they aren't using D to calculate their stats.
Sep 20 2013
prev sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 9/19/13 3:56 PM, Justin Whear wrote:
 On Thu, 19 Sep 2013 14:31:28 -0700, Walter Bright wrote:

 On 9/18/2013 1:23 AM, Olivier Pisano wrote:
 On Friday, 13 September 2013 at 06:51:52 UTC, deadalnix wrote:
 There is 2 ask us anything. Can you tell us which one and
 approximately when ?
Yes, the first one ( http://channel9.msdn.com/Events/GoingNative/2013/Interactive-Panel-Ask-
Us-Anything
 ) around 01:14:20.
Classic Andrei! :-) Should zoom in on that and make a gif!
Yessir: http://imgur.com/W5AMy0P
Awesome. My coworkers added that to our panoply of visual comments in our review tool (Phabricator). Now any code reviewer could insert the word "skeptical" to insert that image in a review. Fits how I feel about some code, notably my own :o). Thanks! Andrei
Sep 20 2013
parent Nick Sabalausky <SeeWebsiteToContactMe semitwist.com> writes:
On Fri, 20 Sep 2013 10:50:23 -0700
Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote:

 On 9/19/13 3:56 PM, Justin Whear wrote:
 Yessir: http://imgur.com/W5AMy0P
Awesome. My coworkers added that to our panoply of visual comments in our review tool (Phabricator). Now any code reviewer could insert the word "skeptical" to insert that image in a review. Fits how I feel about some code, notably my own :o).
That's just awesome :)
Sep 21 2013
prev sibling next sibling parent reply "growler" <growlercab gmail.com> writes:
On Monday, 9 September 2013 at 16:43:54 UTC, Andrei Alexandrescu 
wrote:
 http://www.reddit.com/r/programming/comments/1m1izv/goingnative_2013_writing_quick_code_in_c_quickly/

 Andrei
Just wanted to say thanks for posting the link, it was a great talk. Of the other talks I especially enjoyed those by the backend VC compiler guys, Compiler++ and Compiler Confidential. Watching your second talk on tuples I couldn't help thinking how much easier templates are in D. When reading C++ I find I have to make a context switch between run-time and compile-time thinking. It's quite jarring. In D, however, templates come naturally and it's very seamless.
Sep 18 2013
parent "Gary Willoughby" <dev nomad.so> writes:
On Wednesday, 18 September 2013 at 10:18:43 UTC, growler wrote:
 Watching your second talk on tuples I couldn't help thinking 
 how much easier templates are in D. When reading C++ I find I 
 have to make a context switch between run-time and compile-time 
 thinking. It's quite jarring. In D, however, templates come 
 naturally and it's very seamless.
This is how i feel too, templates in D are an absolute joy to use and so natural!
Sep 18 2013
prev sibling parent =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 09/09/2013 09:43 AM, Andrei Alexandrescu wrote:
 http://www.reddit.com/r/programming/comments/1m1izv/goingnative_2013_writing_quick_code_in_c_quickly/


 Andrei
Great talk indeed! I am late to the party so instead of commenting on Reddit I will write here. There are two points made in the talk that favor out parameters over return-by-value: <quote> Slide 33/40: The Composability Argument * Appending to containers: cheap * Concatenating containers: expensive Slide 34/40 The Measurements Argument * Which one is faster? // API 1: Returns next line (with terminator) // or empty string at end of file string nextLine(istream&); // API 2: Fills string with next line (with terminator) // returns false at end of file bool nextLine(istream&, string& s); </quote> This topic happens to be one of my favorite interview questions. :) If program correctness is valued, the by-ref out parameter may not be the faster option because the caller may not want to pass in a precious container to a function only to be halfway appended to it. Imagine that the function appends N/2 items to the caller's container and then throws. If that half-baked state is not desired, either the function itself or the caller may have to undo what has already been appended. If the function should not append but first clear the container and then create it anew, then fair enough, we would be taking advantage of already-allocated buffer of the container. (A valid consideration for arrays but not every pointer-based data structure takes advantage of old buffers.) But still, for correctness, the function should not append but create anew (on top of the existing buffer), which necessitates "concatenation" on the caller side anyway. Ali
Sep 21 2013