5 ms·
This isn't really a fair criticism because: 1. You picked probably the most verbose way to do it. 2. It's not valid C++ because you're assigning a pointer to
by cldr 13y ago
This isn't really a fair criticism because:
1. You picked probably the most verbose way to do it.
2. It's not valid C++ because you're assigning a pointer to a value.
3. Idiomatic C++ doesn't use `new` explicitly anyway
4. The `d = {}` of Python is not really equivalent.
My feeling is that python gains brevity in exchange for putting a heavier mental load on the programmer, which is manageable for small programs but becomes unwieldy for larger ones.
- anonymoushn 13y agoDoes idiomatic C++ do heap allocations with malloc then?
- pkolaczk 13y agoNo. Idiomatic C++ allocates everything at compile time by means of template metaprogramming magic (just joking).
- he_the_great 13y agoNo that is D and it is with CTFE. Also joking... mostly.
- cldr 13y agoIdiomatic C++ would allocate everything possible on the stack, and if that wasn't possible, use `make_shared`/`make_unique`. So maybe I will change it to say "doesn't use `new` directly".