Re: c++ for python programmers
On Feb 14, 2:41 pm, Neil Cerutti <horp...@yahoo. comwrote:
[...]
Optional garbage collection is highly likely to be included in the
next C++ standard, due out in a couple of years.
On the other hand having everything dynamically allocated prevents the
adoption of deterministic destruction, which is a far better clean up
mechanism than try/finally clauses.
In modern C++ standard containers and smart pointers help solve most
memory related problems. I'm aware that most is not the same as all,
but on the other hand garbage collection has it's problems too:
depending on the algorithm it may not be able to reclaim all the
unreachable memory and forgetting to explicitly reset variables may
lead to hanging to memory that is really not needed anymore.
Cheers,
Nicola Musatti
On Feb 14, 2:41 pm, Neil Cerutti <horp...@yahoo. comwrote:
[...]
Don't forget the lack of standard garbage collection.
next C++ standard, due out in a couple of years.
Also there's the hell known as exception safety.
>
Python conceptually has many of the same issues with exception
safety, but at least memory leaks aren't one of the consequences.
I imagine most Python programmers don't even think about
exception safety, but probably should be. We just happily raise
exceptions willy-nilly, without worrying about our objects
remaining in a reasonable state. Or do we? Maybe it's better not
to think about it. ;-)
>
Python conceptually has many of the same issues with exception
safety, but at least memory leaks aren't one of the consequences.
I imagine most Python programmers don't even think about
exception safety, but probably should be. We just happily raise
exceptions willy-nilly, without worrying about our objects
remaining in a reasonable state. Or do we? Maybe it's better not
to think about it. ;-)
adoption of deterministic destruction, which is a far better clean up
mechanism than try/finally clauses.
In modern C++ standard containers and smart pointers help solve most
memory related problems. I'm aware that most is not the same as all,
but on the other hand garbage collection has it's problems too:
depending on the algorithm it may not be able to reclaim all the
unreachable memory and forgetting to explicitly reset variables may
lead to hanging to memory that is really not needed anymore.
Cheers,
Nicola Musatti
Comment