+ 1
Recursive functions and RAM
In recursive functions which manages RAM better, C++ or Python ?
2 ответов
+ 1
Josh Greig 🆓 () 🤔
+ 3
That depends if you want better performance or an easier developer experience managing memory leaks in RAM.
The most efficient use of RAM and best performance goes to well written c++. c++ uses less RAM for a similarly good implementation since all data types are known and optimized at compile-time. For example, an int in c++ will take 4 bytes of RAM using most modern c++ compilers. Python's number usually takes 28 bytes. More details are given at: https://pythonspeed.com/articles/python-integers-memory/
The easiest management of RAM for programmers goes to Python. In Python, you can largely ignore memory leak concerns because it is all garbage collected like in Java. C++ requires programmers to be very careful about freeing up all blocks of memory when they're done using them.