5 ms·
I do most of my work in C# now, and templates are what I miss most from C++. The syntax is, well, horrible, but the things you can do really help eliminate wha
by drblast 11y ago
I do most of my work in C# now, and templates are what I miss most from C++.
The syntax is, well, horrible, but the things you can do really help eliminate what would otherwise be redundant code.
Just make sure you comment the hell out of things like this or the people that have to read and maintain your code later will hate you.
- jguegant 11y agoI see it as a language in itself. Once done with the steep learning curve you start to observe repeated patterns and get it more easily. I do agree that the syntax is a huge drawback from now.
- cfallin 11y agoYup, it's definitely its own language! It made me so happy when I saw a Haskell-to-C++-template compiler [1] because of all the similarities in pure-FP style (pattern matching, iteration via recursion, etc). [1] https://gergo.erdi.hu/projects/metafun/ https://gergo.erdi.hu/projects/metafun/
- jguegant 11y agoHaskell and C++ look like the "elite" combo these days, especially when it comes to meta-programming and FP as you said! It's funny how these two different communities are mixing. It feels like JavaScript and Ruby having a child.
- mattnewport 11y agoIf you've been away from C++ for a while I'd recommend revisiting it. Some C++14 features greatly improve the syntax when working with templates: auto return type deduction is a huge simplifier for example. Alias templates are very helpful too and generic lambdas come in handy. Variadic templates add new syntax but they make some previously very tedious things relatively trivial once you understand the syntax. C++17 will bring some further improvements when writing templates. Concepts lite will be a huge deal but there are a number of other niceties too, some already available in clang.
- deleted 11y ago[deleted]