Jump to page: 1 2
Thread overview
Three articles on D
Jun 07, 2020
data pulverizer
Jun 07, 2020
Paul Backus
Jun 08, 2020
data pulverizer
Jun 08, 2020
Paul Backus
Jun 08, 2020
data pulverizer
Jun 09, 2020
tastyminerals
Jun 11, 2020
data pulverizer
Jun 11, 2020
tastyminerals
Jun 12, 2020
jmh530
Jun 13, 2020
data pulverizer
Jun 13, 2020
data pulverizer
Jun 08, 2020
Russel Winder
Jun 11, 2020
data pulverizer
Jun 09, 2020
tastyminerals
Jun 11, 2020
data pulverizer
June 07, 2020
I was doing research for my next article and decided to write three shorter ones in the interim. Two are about basic aspects in D and one is a small benchmarking exercise of D math functions.

1. Importing modules & scripts in D. It's much more informative than it sounds especially for beginners, and includes all the import cases including `mixin(import("script.d"));`  https://github.com/dataPulverizer/ImportingInD/blob/master/README.md

2. Template basics decomposition and value types: Once you've written your first basic template in D, at some point soon afterwards you start struggling for how to decompose template types and articulate the template pattern you want in order to facilitate template auto-inference by the compiler. That's what this article helps with: https://github.com/dataPulverizer/DTemplatesDecompositionAndValueTypes/blob/master/README.md

3. Benchmarking of mathematical functions in D, `std.math`, vs C in core, vs LLVM in LDC_intrinsic: https://github.com/dataPulverizer/DMathBench/blob/master/report.md

I look forward to your comments.

Thank you


June 07, 2020
On Sunday, 7 June 2020 at 22:42:34 UTC, data pulverizer wrote:
> 2. Template basics decomposition and value types: Once you've written your first basic template in D, at some point soon afterwards you start struggling for how to decompose template types and articulate the template pattern you want in order to facilitate template auto-inference by the compiler. That's what this article helps with: https://github.com/dataPulverizer/DTemplatesDecompositionAndValueTypes/blob/master/README.md

The examples here seem a bit contrived and unrealistic. It might be difficult for readers to understand how and why they would apply these techniques to their own code.

Also, the vocabulary used is different from the official vocabulary in the language spec. For example, what the tutorial calls "decomposition" is officially called "template argument deduction" [1]. Using official terminology whenever possible makes it easier for users to find relevant information with search engines, get help from the community, and integrate knowledge from multiple sources.

[1] https://dlang.org/spec/template.html#argument_deduction
June 08, 2020
On Sunday, 7 June 2020 at 23:34:56 UTC, Paul Backus wrote:
> On Sunday, 7 June 2020 at 22:42:34 UTC, data pulverizer wrote:
>> 2. Template basics decomposition and value types: Once you've written your first basic template in D, at some point soon afterwards you start struggling for how to decompose template types and articulate the template pattern you want in order to facilitate template auto-inference by the compiler. That's what this article helps with: https://github.com/dataPulverizer/DTemplatesDecompositionAndValueTypes/blob/master/README.md

Thank you for your response.

> Also, the vocabulary used is different from the official vocabulary in the language spec. For example, what the tutorial calls "decomposition" is officially called "template argument deduction" ...

I've made the change to the article.

>
> The examples here seem a bit contrived and unrealistic. It might be difficult for readers to understand how and why they would apply these techniques to their own code.
>

It would probably be helpful for you to pick an example and describe what you mean. From my point of view I'm targeting people writing numerical code and Julia. Someone like that will look at the article and think "hmm okay interesting ...".

The introductory example is a dot product ... those people will know what that is and the code itself is simple enough to extrapolate and get people curious.

The second example getting static array size is from code that actually I use. The code is small in size and simple to follow.

The third example of value type is analogous to Julia's value types (https://docs.julialang.org/en/v1/manual/types/#%22Value-types%22-1) and targets people that have some familiarity with Julia - makes them feel comfortable knowing that some of the same Julia constructs are available in D.

June 08, 2020
On Monday, 8 June 2020 at 00:25:38 UTC, data pulverizer wrote:
> On Sunday, 7 June 2020 at 23:34:56 UTC, Paul Backus wrote:
>>
>> The examples here seem a bit contrived and unrealistic. It might be difficult for readers to understand how and why they would apply these techniques to their own code.
>>
>
> It would probably be helpful for you to pick an example and describe what you mean. From my point of view I'm targeting people writing numerical code and Julia. Someone like that will look at the article and think "hmm okay interesting ...".
[...]
> The second example getting static array size is from code that actually I use. The code is small in size and simple to follow.

See, that's one of the examples I had in mind, because the way I'd get the length of a static array in real code is

    arr.length

I assumed you knew about that and were just using the example to demonstrate template argument deduction. :)

> The third example of value type is analogous to Julia's value types (https://docs.julialang.org/en/v1/manual/types/#%22Value-types%22-1) and targets people that have some familiarity with Julia - makes them feel comfortable knowing that some of the same Julia constructs are available in D.

I'm not familiar with Julia's value types, and reading the linked page doesn't give me a clear idea what they are used for. Again, the example does a decent job showing how template value parameters [1] work, but it doesn't give me much of a clue about why I'd want to use them. Perhaps that's just me, though, and a programmer with a background in Julia would understand better.

[1] https://dlang.org/spec/template.html#template_value_parameter
June 08, 2020
On Monday, 8 June 2020 at 00:43:34 UTC, Paul Backus wrote:
> On Monday, 8 June 2020 at 00:25:38 UTC, data pulverizer wrote:
>> On Sunday, 7 June 2020 at 23:34:56 UTC, Paul Backus wrote:
>>>
>>> The examples here seem a bit contrived and unrealistic. It might be difficult for readers to understand how and why they would apply these techniques to their own code.
>>>
>>
>> It would probably be helpful for you to pick an example and describe what you mean. From my point of view I'm targeting people writing numerical code and Julia. Someone like that will look at the article and think "hmm okay interesting ...".
> [...]
>> The second example getting static array size is from code that actually I use. The code is small in size and simple to follow.
>
> See, that's one of the examples I had in mind, because the way I'd get the length of a static array in real code is
>
>     arr.length
>
> I assumed you knew about that and were just using the example to demonstrate template argument deduction. :)

I assumed that arr.length is always run-time for arrays - but I just checked with a simple example and it works for static arrays at compile time. I can now see why you were saying it was contrived - because you don't need the template to get the length. Fair enough.

>
> I'm not familiar with Julia's value types, and reading the linked page doesn't give me a clear idea what they are used for. Again, the example does a decent job showing how template value parameters [1] work, but it doesn't give me much of a clue about why I'd want to use them. Perhaps that's just me, though, and a programmer with a background in Julia would understand better.
>
> [1] https://dlang.org/spec/template.html#template_value_parameter

They are more similar to template alias parameters (https://dlang.org/spec/template.html#aliasparameters) but you can dispatch on anything - you don't have to specify a type (compiler deduces).

The official template documentation looks as if it has been updated, the last time I saw it, it wasn't this detailed. Great!

June 08, 2020
As well as publishing in the usual online places, I am sure the editors of CVu and/or Overload would love to see these sort of article published in one of those two. ACCU folk love this sort of programming stuff.


On Sun, 2020-06-07 at 22:42 +0000, data pulverizer via Digitalmars-d wrote:
> I was doing research for my next article and decided to write three shorter ones in the interim. Two are about basic aspects in D and one is a small benchmarking exercise of D math functions.
> 
> 1. Importing modules & scripts in D. It's much more informative than it sounds especially for beginners, and includes all the import cases including `mixin(import("script.d"));` https://github.com/dataPulverizer/ImportingInD/blob/master/README.md
> 
> 2. Template basics decomposition and value types: Once you've written your first basic template in D, at some point soon afterwards you start struggling for how to decompose template types and articulate the template pattern you want in order to facilitate template auto-inference by the compiler. That's what this article helps with: https://github.com/dataPulverizer/DTemplatesDecompositionAndValueTypes/blob/master/README.md
> 
> 3. Benchmarking of mathematical functions in D, `std.math`, vs C in core, vs LLVM in LDC_intrinsic: https://github.com/dataPulverizer/DMathBench/blob/master/report.md
> 
> I look forward to your comments.
> 
> Thank you
> 
> 
-- 
Russel.
===========================================
Dr Russel Winder      t: +44 20 7585 2200
41 Buckmaster Road    m: +44 7770 465 077
London SW11 1EN, UK   w: www.russel.org.uk



June 09, 2020
On Sunday, 7 June 2020 at 22:42:34 UTC, data pulverizer wrote:
> I was doing research for my next article and decided to write three shorter ones in the interim. Two are about basic aspects in D and one is a small benchmarking exercise of D math functions.
>
> [...]

Thanks. Interesting that D is less susceptible to floating types than C and LLVM.
Also, a minor typo in "... to think about [then] considering which ...".
June 09, 2020
On Monday, 8 June 2020 at 00:25:38 UTC, data pulverizer wrote:
> On Sunday, 7 June 2020 at 23:34:56 UTC, Paul Backus wrote:
>>> [...]
>
> Thank you for your response.
>
>> [...]
>
> I've made the change to the article.
>
> [...]

FYI, I have a couple of Julia benchmarks timed against NumPy here:
https://github.com/tastyminerals/mir_benchmarks#general-purpose-multi-thread
June 11, 2020
On Monday, 8 June 2020 at 07:52:58 UTC, Russel Winder wrote:
> As well as publishing in the usual online places, I am sure the editors of CVu and/or Overload would love to see these sort of article published in one of those two. ACCU folk love this sort of programming stuff.
>
>
> On Sun, 2020-06-07 at 22:42 +0000, data pulverizer via Digitalmars-d wrote:
>> [snip]

Thanks for your suggestion. I've taken a look at their website and publications. It looks like a great place to write articles for. I'll prepare some stuff for that.


June 11, 2020
On Tuesday, 9 June 2020 at 21:26:02 UTC, tastyminerals wrote:
> Thanks. Interesting that D is less susceptible to floating types than C and LLVM.
> Also, a minor typo in "... to think about [then] considering which ...".

Updated. Thanks

« First   ‹ Prev
1 2