Hacker News new | ask | show | jobs
by chainingsolid 1032 days ago
"D doesn't really have a niche where it might be a good language to use."

I'm wondering if metaprograming would be a niche D could exploit. I have yet to find a systems language with the same introspection and code generation capabilities (minus JAI but its non public). Though not sure what business use case that would fall into... You are right C++ is catching up, Andrei Alexandrescu has a talk that about proposing changes to constexpr to effectively recreate D's static if so he can do Design by Introspection in C++ (https://www.youtube.com/watch?v=tcyb1lpEHm0)

--Examples/more info--

They literally have a "function" that takes in a regex and spits out D code that then gets compiled in to the executable.

https://www.youtube.com/watch?v=HdzwvY8Mo-w DConf 2017 Day 3 Keynote: Design by Introspection -- Andrei Alexandrescu

https://www.youtube.com/watch?v=0lo-FOeWecA DConf Online 2021 - Metaprogramming in D - Bradley Chatha (this one gives a great overview + quick dive into what D meta programing can do)

https://dlang.org/phobos/std_traits.html

1 comments

Since C++20 that DbI is possible in C++, although not as nice as D, or as Andrei would like it to be.

By making use of constexpr if and concepts.

Yet another example of how D has missed to mainstream languages, that eventually got a good enough alternative, with a much rich and mature ecosystem.