Re: [OT] My C++ talk at GoingNative 2013
On Fri, 20 Sep 2013 10:50:23 -0700 Andrei Alexandrescu seewebsiteforem...@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 :)
Re: [OT] My C++ talk at GoingNative 2013
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
Re: [OT] My C++ talk at GoingNative 2013
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!
Re: [OT] My C++ talk at GoingNative 2013
On Thu, 19 Sep 2013 22:56:55 +, 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.
Re: [OT] My C++ talk at GoingNative 2013
On Friday, 20 September 2013 at 15:52:35 UTC, Justin Whear wrote: On Thu, 19 Sep 2013 22:56:55 +, 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 ^^
Re: [OT] My C++ talk at GoingNative 2013
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
Re: [OT] My C++ talk at GoingNative 2013
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!
Re: [OT] My C++ talk at GoingNative 2013
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.
Re: [OT] My C++ talk at GoingNative 2013
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.
Re: [OT] My C++ talk at GoingNative 2013
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!
Re: [OT] My C++ talk at GoingNative 2013
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
Re: [OT] My C++ talk at GoingNative 2013
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
Re: [OT] My C++ talk at GoingNative 2013
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.
Re: [OT] My C++ talk at GoingNative 2013
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 ?
Re: [OT] My C++ talk at GoingNative 2013
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).
Re: [OT] My C++ talk at GoingNative 2013
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.
Re: [OT] My C++ talk at GoingNative 2013
On Sep 12, 2013 9:16 PM, Joseph Rushton Wakeling joseph.wakel...@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';
Re: [OT] My C++ talk at GoingNative 2013
On Sep 12, 2013, at 2:46 PM, Iain Buclaw ibuc...@ubuntu.com wrote: 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/yzsqwejxqlnzryhrk...@forum.dlang.org?page=26
Re: [OT] My C++ talk at GoingNative 2013
On Sep 12, 2013, at 2:46 PM, Iain Buclaw ibuc...@ubuntu.com wrote: On Sep 12, 2013 9:16 PM, Joseph Rushton Wakeling joseph.wakel...@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. I believe this decision happened after dconf as the result of a rather long discussion in digitalmars.D. Someone referenced something written by a C# creator.
Re: [OT] My C++ talk at GoingNative 2013
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.
Re: [OT] My C++ talk at GoingNative 2013
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
Re: [OT] My C++ talk at GoingNative 2013
On 10 September 2013 13:54, Olivier Grant olivier.gr...@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';
Re: [OT] My C++ talk at GoingNative 2013
On 10 September 2013 11:10, deadalnix deadal...@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';
Re: [OT] My C++ talk at GoingNative 2013
On Tuesday, 10 September 2013 at 13:20:18 UTC, Iain Buclaw wrote: On 10 September 2013 11:10, deadalnix deadal...@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
Re: [OT] My C++ talk at GoingNative 2013
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.
[OT] My C++ talk at GoingNative 2013
http://www.reddit.com/r/programming/comments/1m1izv/goingnative_2013_writing_quick_code_in_c_quickly/ Andrei