Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

While completing your research on multiparadigm languages in Module 2, you selec

ID: 3721191 • Letter: W

Question

While completing your research on multiparadigm languages in Module 2, you selected three languages used in industry that interested you.

If you choose to code, you will write small code that displays the major difference between two languages in two different paradigms.

When comparing languages, for either option, you need to compare at least three concepts. Examples include: garbage collection method, implementation models used, types used, and parameter passing methods. Make sure you do not compare syntax differences.

Explanation / Answer

Types:

C++- Statically typed. Need to explicitly mention data type of each variable during declaration.

int num=0;

string str="hello";

list<int> l (1,2,3);

Java- Statically typed. Same as C++. Need to explicitly mention data type of each variable during declaration.

int num=0;

String str="hello";

List<Integer> l=new ArrayList<Integer>();

l.add(1);l.add(2);l.add(3);

Python- Dynamically typed, no need to explicitly declare int,string etc datatypes.

num=0;

str="hello";

l=[1,2,3]

Garbage Collection:

C++- Memory management can be done manually via new / delete, automatically by scope, or by smart pointers. Supports deterministic destruction of objects.

Java- Garbage collection happens automatically by JVM. Even though it supports a non-deterministic finalize() method, but use of finalize is not recommended.

Python- Python’s memory allocation and deallocation method is automatic. The user does not have to preallocate or deallocate memory similar to using dynamic memory allocation in languages such as C or C++. Python uses two strategies for memory allocation:Reference counting,Garbage collection.

Execution of program:

C++- Each C++ source file needs to be compiled into an object file. The object files resulting from the compilation of multiple source files are then linked into an executable/binary file which is ready to be loaded into memory and executed by the system.

Java- Java compiler compiles the source program to create a intermediate byte code which is the class file. The byte code is then executed by JVM. We need different JVM for different platform.

Python- Python is both an interpreted and a compiled language. Python code is translated into intermediate/byte code by compiler, which is next executed by a virtual machine, known as the PVM, the Python virtual machine. This is a similar approach to the one taken by Java. it is like a big loop that iterates through the byte code instructions, one by one, to carry out their operations.