These are a few things I want in a programming language that I haven't seen:
- A way to (easily) define new types that are almost the same as existing types (ambiguous, I know). My motivation is to make sure I'm indexing arrays/vectors with the correct type of index. So ideally, I'd define a particleIndex type, and my position and velocity arrays could only be indexed with a particleIndex. I'd want a compile time error if I tried to use an objectIndex. particleIndex should be like a std::size_t, but with a subset of the available operations/conversions, etc. AFAIK, in c++ you'd either to a typedef, which doesn't prevent you from mixing types, or you'd define a class and implement all the operations you care about which would be a big pain (you'd probably only have to do this once, but still).
- This one is for C++ STL stuff specifically. Many std::algorithms take comparator objects that take complex objects and return a boolean. I often write comparators that look like
[](const T& a, const T& b){return expensiveComputation(a) < expensiveComputation(b);}.
For something like std::min_element, if I wrote my own loop, I think I'd be computing expensiveComputation half as many times, since I'd compute it once per object and store the value, as opposed to computing it twice per comparison. I think a better interface would be if the algorithms took a function object that computed a comparable value, rather than the comparison function itself, ie, took something like [](const T& a){return expensiveComputation(a);}.
Ben Jones May 2015