Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recent blog/talk about metaprogramming #70

Open
septcolor opened this issue Feb 20, 2022 · 2 comments
Open

Recent blog/talk about metaprogramming #70

septcolor opened this issue Feb 20, 2022 · 2 comments

Comments

@septcolor
Copy link

septcolor commented Feb 20, 2022

I have come across this blog post recently, which might be of some example for the utility of templates for such simulations. (I have no experience with "gas dynamics", so not familiar with their calculations themselves.)

A Gas Dynamics Toolkit in D
https://dlang.org/blog/2022/02/02/a-gas-dynamics-toolkit-in-d/

(Excerpts from the blog)

Features of D that have been of benefit to us include:

  • Template programming that other Mechanical Engineers can understand (thanks Walter!). Many of our numerical routines are defined to work with numbers that we define as an alias to either double or Complex!double values. This has been important to us because we can use the same basic update code and get the sensitivity coefficients via finite differences in the complex direction. We think this saved us a large number of lines of code.
  • String mixins have replaced our use of the M4 preprocessor to generate C++ code in Eilmer3. We still have to do a bit of head-scratching while building the code with mixins, but we have retained most of our hair—something that we did not expect to do if we continued to work with C++.
  • Good error messages from the compiler. We often used to be overwhelmed by the C++ template error messages that could run to hundreds of lines. The D compilers have been much nicer to us and we have found the “did you mean” suggestions to be quite useful.

The homepage of their software seems here:
https://gdtk.uqcloud.net/
https://github.com/gdtk-uq/gdtk
https://github.com/gdtk-uq/gdtk/tree/master/src/eilmer

I've also come across a recent talk in FOSDEM2022, which explains the utility of generics, templates, and macros in the Nim language. What I felt interesting is the classification of those things into "Level 1, 2, and 3" (where 1 => generics, 2 => templates, 3 => macro). I guess D's template and string mixin (that are mentioned in the above D blog) correspond roughly to Levels 1/2, while Julia's parametrized functions/types and macro correspond probably to Level 1 and 2/3, respectively (though the distinctions may be not so clear...)

https://www.youtube.com/watch?v=y6GQeWdmSb8 (youtube recording)
https://video.fosdem.org/2022/D.nim/ (from the FOSDEM site, choose "metaprogramming.webm")

@tclune
Copy link
Member

tclune commented Feb 21, 2022

I'm a bit overwhelmed with multiple projects at the moment, so may not be able to dive into these materials. I will say that we (generics subgroup) are intentionally ovoiding metaprogramming which is related, but distinct to generic programming. (But the terms are often incorrectly used interchangably.)

@septcolor
Copy link
Author

Thanks much for your message, and please do not worry about checking them so soon! I will post related materials here (in this thread) when I come across something interesting or potentially useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants