Hacker News new | ask | show | jobs
by cldr 4629 days 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.

1 comments

Does idiomatic C++ do heap allocations with malloc then?
Idiomatic 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".
No. Idiomatic C++ allocates everything at compile time by means of template metaprogramming magic (just joking).
No that is D and it is with CTFE. Also joking... mostly.