1
DF General Discussion / Re: Future of the Fortress
« on: January 31, 2015, 03:54:34 am »Quote from: GreenScapeHave you switched to c++11/14? How much did it make a coding easier?
I don't know about the 14 one, but if I remember, 11 had the auto keyword, which I thought was very useful. I didn't find anything to do with the other 11 features that I recall, like the lambda stuff.
14 was mostly minor cleanup, changes to constexpr etc...
The simplest way lambdas are useful is that you can use the functions in <algorithms> without needing to add tons of boilerplate.
c++11 has a few other features that don't really necessitate a massive rewrite, the explicit nullptr to replace NULL, range based for loops:
Code: [Select]
for (auto& thing : someContainer){foo(thing);}static assert if you do any metaprogramming, technically not needing to put a space between each > when nesting templates is a c++11 feature that was added really early. Stuff that is nice but might require rewriting old code is move constructors, smart pointers, and initializer lists.C++14 mostly works a few kinks out of C++11 -- little fixes and enhancements to the stuff that didn't even exist before. If you like auto, one thing of note is that in C++14 auto works for function return types (not to be confused with writing auto before the function name in order to write the return type after, which was already in C++11 for similar yet different reasons). I also recommend, even in C++11, becoming passingly familiar with decltype, which can be used to get auto-like effects (of tying a type to a variable rather than repeating the type explicitly) in some situations where auto wouldn't work.Quote from: GreenScapeHave you switched to c++11/14? How much did it make a coding easier?
I don't know about the 14 one, but if I remember, 11 had the auto keyword, which I thought was very useful. I didn't find anything to do with the other 11 features that I recall, like the lambda stuff.
C++11 auto/decltype function signatures are a huge pain in the ass and probably aren't worth it if you're not doing a lot of generic programming, which I suspect is not going on in DF. C++14 auto function signatures are nice, but I don't know if Toady is using new enough compilers for them.
Quote
As for lambdas, as far as I can tell they're mostly to help support functional programming composability styles -- sort of thing you'd find useful to no end if you came from a Haskell background, but it's an entirely different mindset with its own pros and cons...
Toady's an algebraist isn't he? I bet he'd enjoy Haskell.