In: Computer Science
[Computer Science Question]
Compare and Contrast the trade-offs associated with using C++ in
comparison to Python. How do the characteristics of the languages
impact the amount of memory each language occupies. How do memory
considerations impact each languages real world
implementations?
Both python and c++ are programming languages, mostly used for same purpose, but they both have different characteristics, and they both differ in many ways.
C++:
Actually c++ is not platform independent , hence for each and every operating system the program needs to be compiled once.
Python:
Python has the ability of "write once and comiple anywhere" hence the python progtams are platform independent, which is a great advantage over c++
C++:
It is little hard for users, users need to memorize many syntax and datatype, for example: before using a variable we must declare the type of data(int,float,char,double etc.,).
Python:
Here, there is no need of such datatypes, the compiler itself will recognize the datatype, which makes the code look easier.
C++:
It is a mix of procedural and object oriented laguage.here rapid prototyping is not possible.
Python:
It is known for its simplicity.Here rapid prototyping is possible.
When it comes to memory:
C++ has a bad memory management when compared to the advanced languages like python, this is because c++ does not provide the facility of automatic garbage collection, hence every object created will not be destroyed, which leads to accumulation of unwanted memory. Whereas in python garbage collection is available, the objects are automatically destroyed if the objects are not required.
And the main difference is that c++ make use of pointers very often, this is a main drawback since access to pointer can lead to memory access, hence the memory can be manipulated very easily. In order to avoid this issue pointer are eliminated in python.
In real world application, the process of execution should have a very low space complexity(amount of memory required to run the program should be low). An effecient application should take less space, and mainly it should not access the memory locations. Hence memory considerations are very high when it comes to an effective program. Hence to do this we require a language that uses less memory and a language that is more secure. While comparing c++ and python, python is more useful for the real world implementation.