3 ms·
To me, this seems like it increases cognitive load, which is the opposite of what it ought to be. At some point the abstraction is so abstract, that you have to
by spacedcowboy 2y ago
To me, this seems like it increases cognitive load, which is the opposite of what it ought to be. At some point the abstraction is so abstract, that you have to stop and think about what the [redacted] you're actually reading, without it just making intrinsic sense.
If you want to enumerate over a bunch of items to print them out, do that. Don't wrap it up in some obscure language feature.
Stuff like this is why, of the two main "C with classes" extension languages, I prefer ObjC over C++. If I really need the speed of C++, I can just use it, but you'd better believe it'll be straightforward C++/STL. At all other times, it's easier to grok ObjC, easier to work with it, and (again) the cognitive load over and above 'C' is really minimal compared to C++.
I guess I'm just one of the old-fashioned folks who think that just because something was difficult to write, it shouldn't be difficult to read. Code clarity wins over brevity in my book any day.
- jlarocco 2y ago> I guess I'm just one of the old-fashioned folks who think that just because something was difficult to write, it shouldn't be difficult to read. Code clarity wins over brevity in my book any day. I treat template metaprogramming in C++ like macro code in Lisp - it's not something I use all the time and it's often more complicated than every day code, but used well it make the rest of the codebase simpler to understand. The most complicated template I've written recently wraps a vendor's clunky old iterator classes (unrelated to STL) with .Current() and .Next() methods, and lets us use them in C++11's `for (auto thing : VendorIterator)` loops. In the vendor's defense, they started writing the library in the early 90s, before the STL was formally part of C++ - though it would be nice if they provided a template like this themselves. In any case, the template greatly simplifies using the iterators (5 lines of code goes to 1) in dozens of places, at the cost of a complicated template that rarely needs to change. To me it's a fair tradeoff.
- waynecochran 2y agoCognitive load is greatly increased. As a corollary this kind of stuff becomes difficult to prove correct. There is a fine line between clever and stupid. Some of these C++ additions have jumped the shark.
- pjmlp 2y agoObjective-C is also full of warts, from its original days, the transition to be more developer friendly, special constructs to ease interop with Swift. Also, had it not been for NeXT's reverse acquisition of Apple it would have been long forgotten by now.
- danielscrubs 2y agoSwift as a language is great. But the compile time performance and the timeouts are just laughable, truly worthy of damnation.
- pjmlp 2y agoYep, a mix of type system complexity, and LLVM.