www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Taking D to GDC Europe - let's make this tight

reply Ethan Watson <gooberman gmail.com> writes:
http://schedule.gdceurope.com/session/d-using-an-emerging-language-in-quantum-break

My proposal for a talk has been accepted, and I'll be in Cologne 
next month presenting to industry peers.

One of the things I was asking during the approval process was 
whether attendees tended to be more on the game programming side 
or the tech/engine programming side. They don't have that data. 
Looking at the rest of the talks on the schedule, there does 
appear to be a bit of a lack of technical talks. So that pretty 
much settles it for me, I'm going to go a bit in-depth on D. I've 
been seeing this talk as basically a sales pitch to the rest of 
the industry to check D out, and going in-depth means its time to 
shine.

The general gist of the talk will broadly cover what both my talk 
at DConf this year and Manu's talk at DConf in 2013 covered. But 
to break up the flow a bit, I intend on inserting examples of 
ways D saves time. Take the lighting talk I did about a simple 
interpolation function - illustrate the problem in C++, and the 
solution in D. But because there's options out there for 
languages these days, I also want equivalent solutions in Rust 
(as that is the most likely other option). I might also add a 
column for Swift so I can write "LOLNO" for each problem. Perhaps 
also relevant is C# equivalents as that has quite a lot of 
support in game programming these days thanks to Unity.

The examples are also meant to highlight specific language 
features. The interpolation example highlights template 
constraints and type inspection. And they're going to be based on 
code I've either written for Quantum Break, or had to spend an 
unholy amount of time getting to work in C++ recently.

Mainly here, I would like the assistance of someone that has used 
Rust and can provide Rust-based examples that perform the same 
task. Stefan Koch was also illustrating some of the modern 
syntactic shortcuts on IRC last night, I've been programming in a 
DMD that was released in 2013 for a while so getting up to speed 
on modern D programming with my examples will help make this even 
tighter than I can otherwise make it by myself.

The examples I'm looking at using (aiming for a spacing of about 
one every 10-15 minutes in the talk, so 4 in total):

* Generic interpolation function
   - Already illustrated at DConf for both C++ and D
   - C++ - Unmaintainable, buggy mess
   - Rust - No idea
   - D - Write once, handle any type thanks to type inspection
   - D feature demonstration: template constraints, type inspection

* Check a type for an equality operator
   - C++ - SFINAE whackiness, and as near as I can tell requires 
separate tests to determine if an object has a member operator 
and/or a global operator for comparison tests
   - Rust - No idea
   - D - Simple is() check wrapped in an enum
   - D feature demonstration: is, static if for further use

* Expansion of code for a script wrapper to a native function 
(retrieve parameters and pass to native)
   - C++ - Pre-C++11 is a mess but doable. Will focus on C++11, 
which requires template parameter inference, compile time number 
range generation, and calling a function with two dummy instances 
of objects to allow the inference to happen.
   - Rust - No idea
   - D - Haven't written the code, but intend on using mixin with 
strings
   - D feature demonstration - mixin, mixin template

* Fourth example TBD, might try to make it tie in to the binding 
system which means I'll cover CTFE.

Speaking of the binding system, the plan is to open source it for 
the talk. I'm in the process of cleaning it up right now for such 
purposes.
Jul 12 2016
next sibling parent reply Ola Fosheim =?UTF-8?B?R3LDuHN0YWQ=?= writes:
On Tuesday, 12 July 2016 at 11:27:18 UTC, Ethan Watson wrote:
 * Check a type for an equality operator
   - C++ - SFINAE whackiness, and as near as I can tell requires 
 separate tests to determine if an object has a member operator 
 and/or a global operator for comparison tests
It isn't all that whacky as the required traits for testing for members have been included in the standard library for C++17: http://en.cppreference.com/w/cpp/experimental/is_detected http://en.cppreference.com/w/cpp/types/void_t I use it in my production code, it is actually quite reasonable for a library solution.
 * Expansion of code for a script wrapper to a native function 
 (retrieve parameters and pass to native)
   - C++ - Pre-C++11 is a mess but doable. Will focus on C++11, 
 which requires template parameter inference, compile time 
 number range generation, and calling a function with two dummy 
 instances of objects to allow the inference to happen.
Not sure what you mean by this. There have been improvements to template arguments in all recent revisions of C++ so prepare for comments from the audience.
Jul 12 2016
parent reply Ethan Watson <gooberman gmail.com> writes:
On Tuesday, 12 July 2016 at 12:51:42 UTC, Ola Fosheim Grøstad 
wrote:
 C++14/17 stuff
Which would be relevant if the target audience didn't need to support Visual Studio, which still doesn't fully support C++11 in the latest revision let alone C++14 features. https://msdn.microsoft.com/en-us/library/hh567368.aspx
Jul 12 2016
parent reply Ola Fosheim =?UTF-8?B?R3LDuHN0YWQ=?= writes:
On Tuesday, 12 July 2016 at 12:57:15 UTC, Ethan Watson wrote:
 On Tuesday, 12 July 2016 at 12:51:42 UTC, Ola Fosheim Grøstad 
 wrote:
 C++14/17 stuff
Which would be relevant if the target audience didn't need to support Visual Studio, which still doesn't fully support C++11 in the latest revision let alone C++14 features. https://msdn.microsoft.com/en-us/library/hh567368.aspx
cppreference.com provides this implementation for void_t for pre C++14 compilers, are you sure it doesn't work? « template<typename... Ts> struct make_void { typedef void type;}; template<typename... Ts> using void_t = typename make_void<Ts...>::type; »
Jul 12 2016
parent reply Ola Fosheim =?UTF-8?B?R3LDuHN0YWQ=?= writes:
On Tuesday, 12 July 2016 at 14:48:17 UTC, Ola Fosheim Grøstad 
wrote:
 On Tuesday, 12 July 2016 at 12:57:15 UTC, Ethan Watson wrote:
 On Tuesday, 12 July 2016 at 12:51:42 UTC, Ola Fosheim Grøstad 
 wrote:
 C++14/17 stuff
Which would be relevant if the target audience didn't need to support Visual Studio, which still doesn't fully support C++11 in the latest revision let alone C++14 features. https://msdn.microsoft.com/en-us/library/hh567368.aspx
cppreference.com provides this implementation for void_t for pre C++14 compilers, are you sure it doesn't work? « template<typename... Ts> struct make_void { typedef void type;}; template<typename... Ts> using void_t = typename make_void<Ts...>::type; »
It does work in Visual Studio Update 2 according to this discussion: http://stackoverflow.com/questions/31907885/void-t-fails-on-visual-studio-2015 Anyway, if you are going to compare languages, use the latest edition of both languages. Doesn't seem fair to compare D to VS, if it is just as much work to use D as it is to use GCC or Clang? AFAIK MS is aiming to close the gap, but they have an old backend to work with that they claim is holding them back.
Jul 12 2016
parent reply Ethan Watson <gooberman gmail.com> writes:
On Tuesday, 12 July 2016 at 14:48:17 UTC, Ola Fosheim Grøstad 
wrote:
 «
 template<typename... Ts> struct make_void { typedef void type;};
 template<typename... Ts> using void_t = typename 
 make_void<Ts...>::type;
 »
Variadic expansion works on my home code in VS2015. But we shipped Quantum Break on VS2012. I can use variadic template arguments for SFINAE purposes in VS2012, anything more involved is virtually unsupported. On Tuesday, 12 July 2016 at 15:14:39 UTC, Ola Fosheim Grøstad wrote:
 Anyway, if you are going to compare languages, use the latest 
 edition of both languages.
I know this makes sense. But by the same token, this is a practical talk aimed at people using compilers and toolchains that aren't necessarily up to date. What I'd rather do is have further examples visible online for C++17 standards to compare against. Either way, given Microsoft's rate, the industry will be able to use C++17 some time in 2021. Also of note is that with the binding system we're open sourcing, it's meant to just slot in and start people using D alongside their C++ codebases. And further of note, this is to show things that are just plain horrible to do in C++. SFINAE whackiness leads me in to talking about the is operator in D, which leads in to talking about the binding system... It's all about how it directly relates to usage, not to what someone can do in six years time.
Jul 12 2016
parent reply Ola Fosheim =?UTF-8?B?R3LDuHN0YWQ=?= writes:
On Tuesday, 12 July 2016 at 15:50:59 UTC, Ethan Watson wrote:
 that aren't necessarily up to date. What I'd rather do is have 
 further examples visible online for C++17 standards to compare 
 against. Either way, given Microsoft's rate, the industry will 
 be able to use C++17 some time in 2021.
Well, just make sure you say you are aware of it ;-), or else you'll get the same response that you would get from D-users if you compared C++17 to D1... I can get this to work: template<class, class = void_t<>> struct has_equality : std::false_type { }; template<class T > struct has_equality<T, void_t<decltype( std::declval<T&>() == std::declval<T&>() )>> : std::true_type { }; and call it with: if( has_equality<int>() ) ... with C++14 you also can get rid of the parens by binding ::value so you get if( has_equality<int> ) ...
 horrible to do in C++. SFINAE whackiness leads me in to talking 
 about the is operator in D, which leads in to talking about the 
 binding system... It's all about how it directly relates to 
 usage, not to what someone can do in six years time.
I am not sure if I understand the argument. Wouldn't MS have kept D at D1 if the core issue is their backend? Why is it easier to user D than clang/gcc?
Jul 12 2016
next sibling parent Stefan Koch <uplink.coder googlemail.com> writes:
On Tuesday, 12 July 2016 at 16:24:07 UTC, Ola Fosheim Grøstad 
wrote:
   template<class T >
   struct has_equality<T, void_t<decltype(
      std::declval<T&>() == std::declval<T&>()
   )>> : std::true_type { };
It looks horrible. And in D it is much prettier.
Jul 12 2016
prev sibling parent reply Ethan Watson <gooberman gmail.com> writes:
On Tuesday, 12 July 2016 at 16:24:07 UTC, Ola Fosheim Grøstad 
wrote:
 you'll get the same response that you would get from D-users if 
 you compared C++17 to D1...
That's both wildly hyperbolic; and not going to happen for the mentioned reasons.
 I can get this to work:
Which is both not the way I'm currently doing it, and not the way I've seen it done elsewhere. Effectively, the way I've seen it done is by testing the return type of a variadic-template-parameterised function that is specialised with the decltype for the operation in question. However, this goes to prove my point. In both cases, it's a bunch of legwork just to get to a true_type or a false_type. Having it available in the standard library ignores the fact that if you need to do something similar that will never be covered by the standards, it's a whole bunch of near-esoteric work you'll need to understand to get to that point. Whereas in D, you can do the same thing with an is() statement. As I pointed out at DConf (and which I saw someone around here quote somewhere), the number one thing you can do in D that you can't do in C++ is save time. The is() statement isn't just a simple operator, it's far more powerful that writing a boatload of boilerplate template code because it tests if code compiles. Far more flexible than writing template code for the fail case and specialising for the success case, far quicker to learn, far quicker to use, far quicker to write, etc.
 I am not sure if I understand the argument.
Did you see my DConf talk? Do you know that DMD uses mslink for 64 bit builds, and we use the Xbox One version of mslink to get Xbox One compatibility? It seems to me you'll understand where I'm coming from better if you look at what I've already put out there.
Jul 12 2016
parent Ola Fosheim =?UTF-8?B?R3LDuHN0YWQ=?= writes:
On Tuesday, 12 July 2016 at 17:55:22 UTC, Ethan Watson wrote:
 However, this goes to prove my point. In both cases, it's a 
 bunch of legwork just to get to a true_type or a false_type.
Ok, I don't have much trouble with it. I usually want to abstract such tests into concepts and stuff them in to a library and only use "has_equality<T>"...
 covered by the standards, it's a whole bunch of near-esoteric 
 work you'll need to understand to get to that point.
Well, the problem is that there is a lot of out-dated advice out there for how to do template programming in C++ that is rather convoluted. But there are some fairly simple patterns to use for both testing functionality and disabling functionality. In my view the major advantage D has is in being able to disable struct fields with static if, I haven't found a simple way to do that in C++.
 Whereas in D, you can do the same thing with an is() statement.
Sure, you can always add special-cased builtins, but if you can express it in a relatively simple core inference engine then you can just add it with syntactical sugar and avoid all the special casing in analysis stages. Lowering to the core language should always be the preferred way to extend the language. So from a language design perspective it is sound to only implement the core language and enable library solutions. If that leads to boiler plate you need to reconsider the abstraction mechanisms you provide and not necessarily add lots of special cased functionality. The inference engine that C++ templates provide is convoluted, no doubt about it, but that is a past mistake. Adding special casing isn't the right answer to rectifying the mistake.
 Did you see my DConf talk? Do you know that DMD uses mslink for 
 64 bit builds, and we use the Xbox One version of mslink to get 
 Xbox One compatibility? It seems to me you'll understand where 
 I'm coming from better if you look at what I've already put out 
 there.
I haven't seen any of the 2016 DConf talks.
Jul 12 2016
prev sibling next sibling parent reply Abdulhaq <alynch4047 gmail.com> writes:
On Tuesday, 12 July 2016 at 11:27:18 UTC, Ethan Watson wrote:
 http://schedule.gdceurope.com/session/d-using-an-emerging-language-in-quantum-break

 My proposal for a talk has been accepted, and I'll be in 
 Cologne next month presenting to industry peers.
Congratulations and it sounds good, however I would say that it's something of a truism in sales not to criticize the competition - it doesn't have the effect that you think it will. The expressiveness of D code next to the (long winded etc.) equivalents in the other languages will be clear, so it's more effective to praise those languages for their historical strengths and let D talk for itself as a good improvement and worthy of investigation. IMHO.
Jul 12 2016
parent Meta <jared771 gmail.com> writes:
On Tuesday, 12 July 2016 at 13:34:42 UTC, Abdulhaq wrote:
 On Tuesday, 12 July 2016 at 11:27:18 UTC, Ethan Watson wrote:
 http://schedule.gdceurope.com/session/d-using-an-emerging-language-in-quantum-break

 My proposal for a talk has been accepted, and I'll be in 
 Cologne next month presenting to industry peers.
Congratulations and it sounds good, however I would say that it's something of a truism in sales not to criticize the competition - it doesn't have the effect that you think it will. The expressiveness of D code next to the (long winded etc.) equivalents in the other languages will be clear, so it's more effective to praise those languages for their historical strengths and let D talk for itself as a good improvement and worthy of investigation. IMHO.
If I understand correctly he will be doing a comparison, not a criticism (except for Swift).
Jul 12 2016
prev sibling next sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 07/12/2016 07:27 AM, Ethan Watson wrote:
 http://schedule.gdceurope.com/session/d-using-an-emerging-language-in-quantum-break


 My proposal for a talk has been accepted, and I'll be in Cologne next
 month presenting to industry peers.
This is awesome! You should do an interview with Mike about the conference. -- Andrei
Jul 12 2016
parent Ethan Watson <gooberman gmail.com> writes:
On Tuesday, 12 July 2016 at 14:29:03 UTC, Andrei Alexandrescu 
wrote:
 This is awesome! You should do an interview with Mike about the 
 conference. -- Andrei
Just saw an email from him to this effect.
Jul 12 2016
prev sibling next sibling parent Jacob Carlborg <doob me.com> writes:
On 2016-07-12 13:27, Ethan Watson wrote:
 http://schedule.gdceurope.com/session/d-using-an-emerging-language-in-quantum-break


 My proposal for a talk has been accepted, and I'll be in Cologne next
 month presenting to industry peers.
Will the talk be recorded? -- /Jacob Carlborg
Jul 13 2016
prev sibling next sibling parent deadalnix <deadalnix gmail.com> writes:
On Tuesday, 12 July 2016 at 11:27:18 UTC, Ethan Watson wrote:
 http://schedule.gdceurope.com/session/d-using-an-emerging-language-in-quantum-break

 My proposal for a talk has been accepted, and I'll be in 
 Cologne next month presenting to industry peers.
Awesome ! I hope you can make good impression.
Jul 14 2016
prev sibling next sibling parent Jalal El Mansouri <jalal.elmansouri gmail.com> writes:
On Tuesday, 12 July 2016 at 11:27:18 UTC, Ethan Watson wrote:
 http://schedule.gdceurope.com/session/d-using-an-emerging-language-in-quantum-break

 My proposal for a talk has been accepted, and I'll be in 
 Cologne next month presenting to industry peers.
 ....
 ....
 Speaking of the binding system, the plan is to open source it 
 for the talk. I'm in the process of cleaning it up right now 
 for such purposes.
Cool, the full presentation will be in the GDC Vault afterwards I guess for people who can't attend. It feels like some of the "code as data" aspects you are covering in your DConf presentation are similar to mono based frameworks implementations that mainly use C#. So I would focus on C# too as it is a very familiar language in a lot of large game productions. We actually have a couple of domain specific languages that are very close to C# but compile to C++.
Jul 14 2016
prev sibling parent Meta <jared771 gmail.com> writes:
On Tuesday, 12 July 2016 at 11:27:18 UTC, Ethan Watson wrote:
 http://schedule.gdceurope.com/session/d-using-an-emerging-language-in-quantum-break

 My proposal for a talk has been accepted, and I'll be in 
 Cologne next month presenting to industry peers.

 One of the things I was asking during the approval process was 
 whether attendees tended to be more on the game programming 
 side or the tech/engine programming side. They don't have that 
 data. Looking at the rest of the talks on the schedule, there 
 does appear to be a bit of a lack of technical talks. So that 
 pretty much settles it for me, I'm going to go a bit in-depth 
 on D. I've been seeing this talk as basically a sales pitch to 
 the rest of the industry to check D out, and going in-depth 
 means its time to shine.

 The general gist of the talk will broadly cover what both my 
 talk at DConf this year and Manu's talk at DConf in 2013 
 covered. But to break up the flow a bit, I intend on inserting 
 examples of ways D saves time. Take the lighting talk I did 
 about a simple interpolation function - illustrate the problem 
 in C++, and the solution in D. But because there's options out 
 there for languages these days, I also want equivalent 
 solutions in Rust (as that is the most likely other option). I 
 might also add a column for Swift so I can write "LOLNO" for 
 each problem. Perhaps also relevant is C# equivalents as that 
 has quite a lot of support in game programming these days 
 thanks to Unity.

 The examples are also meant to highlight specific language 
 features. The interpolation example highlights template 
 constraints and type inspection. And they're going to be based 
 on code I've either written for Quantum Break, or had to spend 
 an unholy amount of time getting to work in C++ recently.

 Mainly here, I would like the assistance of someone that has 
 used Rust and can provide Rust-based examples that perform the 
 same task. Stefan Koch was also illustrating some of the modern 
 syntactic shortcuts on IRC last night, I've been programming in 
 a DMD that was released in 2013 for a while so getting up to 
 speed on modern D programming with my examples will help make 
 this even tighter than I can otherwise make it by myself.

 The examples I'm looking at using (aiming for a spacing of 
 about one every 10-15 minutes in the talk, so 4 in total):

 * Generic interpolation function
   - Already illustrated at DConf for both C++ and D
   - C++ - Unmaintainable, buggy mess
   - Rust - No idea
   - D - Write once, handle any type thanks to type inspection
   - D feature demonstration: template constraints, type 
 inspection

 * Check a type for an equality operator
   - C++ - SFINAE whackiness, and as near as I can tell requires 
 separate tests to determine if an object has a member operator 
 and/or a global operator for comparison tests
   - Rust - No idea
   - D - Simple is() check wrapped in an enum
   - D feature demonstration: is, static if for further use

 * Expansion of code for a script wrapper to a native function 
 (retrieve parameters and pass to native)
   - C++ - Pre-C++11 is a mess but doable. Will focus on C++11, 
 which requires template parameter inference, compile time 
 number range generation, and calling a function with two dummy 
 instances of objects to allow the inference to happen.
   - Rust - No idea
   - D - Haven't written the code, but intend on using mixin 
 with strings
   - D feature demonstration - mixin, mixin template

 * Fourth example TBD, might try to make it tie in to the 
 binding system which means I'll cover CTFE.

 Speaking of the binding system, the plan is to open source it 
 for the talk. I'm in the process of cleaning it up right now 
 for such purposes.
Just saw this on Gamasutra: http://www.gamasutra.com/view/news/278892/Catch_these_great_talks_at_GDC_Europe__Online_registration_closes_Wednesday.php "Plus, there'll be an excellent talk from Remedy Entertainment's Ethan Watson about how the studio built its hit 2016 action game Quantum Break using the D programming language. "D: Using An Emerging Language in Quantum Break" is a notable talk about a language that's rarely discussed in game development, and Watson aims to answer important questions like: what benefits does D have over C++? Is it ready for mass use? Does treating code as data with a traditional C++ engine work? His talk will cover Remedy's usage of the D programming language in Quantum Break and also provide some details on where the studio wants to take usage of it in the future. Make sure to check it out if you're interested in gaining knowledge of a realistic alternative to C++, an understanding of D's real world usage and insight into what the possibilities could be for your own usage." Good luck with the talk, Ethan. Looks like this will provide a lot of visibility for D.
Aug 10 2016