Question

In: Computer Science

Your task is to write an article describing the differences you have found or noticed so...

Your task is to write an article describing the differences you have found or noticed so far between C++ and Java.

First you should go through the W3schools C++ tutorials as described in the week’s description, taking some notes about the differences between C++ and Java as you do so. Then, you should write your document.

Your document does not need to be long, but it should be well-written. Imagine that you are writing this for Java programmers who want to know about C++.   You will be telling them about some of the differences between the two languages that you noticed as you began to learn about C++.

It would best to submit your article as a Word. Be sure to include your name and a title at the top of the article, much like we do with identifying documentation when programming, no specific format is required, as long as the information is there and your document doesn’t look too bad.

Practice writing about topics in Computer Science is important for students studying the discipline.

Solutions

Expert Solution

Java : Java programming language was developed by Sun Microsystems by James Gosling and released in 1995 as core component of Sun Microsystems Java platform. With the advancement of Java and its widespread popularity, multiple configurations were built to suit various types of platforms. Java is guaranteed to be Write Once, Run Anywhere.

C++ : C++ is a powerful general-purpose programming language. It can be used to develop operating systems, browsers, games, and so on. C++ supports different ways of programming like procedural, object-oriented, functional, and so on. All this makes C++ powerful as well as flexible. A general purpose programming language created as an extension of C language and can be said as C language with classes is called C++. The language offers high level control for system and memory and as a cross platform language develops high performance applications.

I will list down some basic differences first before going into the other smaller differences:

  • Java uses both compiler and interpreter whereas C++ uses the only compiler
  • C++ supports operator overloading and multiple inheritances but Java does not.
  • C++ is more hardware oriented in comparison to Java.
  • Java uses import functionality to include different classes and its methods in the program whereas C++ uses the concept of header files to include different libraries in the program.
  • C++ provides support for default arguments whereas Java does not.
  • C++ uses the scope resolution operator whereas Java uses dot operator
  • Java does not have destructors, therefore, garbage collection is easier than C++.
  • Java supports function overloading whereas C++ supports function as well as operator overloading.
  • Java has the concept of pass-by-value.
  • C++ has the implementation of unsigned integers whereas Java does'nt.
  • C++ uses pointers and has the capability of manipulating memory addresses.
  • Java does not use pointers that make it a type-safe programming language.
  • Java uses Generics whereas C++ uses templates.
  • Java has an in-built Thread class that needs to be inherited for the creation of a new thread whereas C++ has no support for threads like Java. However, C++ achieves the functionality of thread using external libraries.

Now some more in-depth differences:

Class vs. Object

From the name, it seems like object-oriented programming is all about objects. But when we write an object-oriented program, our code specifies something called a class and both C++ and Java have class as a keyword but object is not a keyword in either of them. The concepts of class and object are connected at a very fundamental level but the two concepts are distinct.

The most common example used to show the relationship between an object and a class is of a cookie and a cookie shaper. A class is like a cookie shaper which describes the shape and the size of a cookie but it is inedible and does not consist of any cookie ingredients. Cookies are like objects. Once the cookie dough is made and rolled out, we can shape them using the cookie shaper. The shape and size of every cookie will be identical.

Similarly, a class is a description. At a high level a class describes three features of the objects that are created or instantiated from the class:

  1. The name of the class. A class name becomes a new data type that may be used throughout the program.
  2. The variables (the names and the types) that can be stored in or managed by an instance of the class which is nothing but an object
  3. The methods or functions that can operate on the data or variables managed by the object.

General Method and Function Calls:

Let's suppose that the model class has a method or function called display. C++ has two ways of creating an object, which requires two ways to use the object, which in turn requires an operator not found in Java. C++ has the arrow operator which is used whenever the asterisk appears during object instantiation. Both languages use the dot operator to make the call. Concept of code using asterisk and the arrow operator is a feature called pointers.

mymodel1.display();    // Java
mymodel2->display();   // C++
mymodel3.display();    // C++, looks like Java

Arrays:

Java implements arrays as objects whereas C++ treats them as a primitive data type.

Functionally, an array is a collection of variables which are accessed through a common name. Individual variables or elements of the array are selected by an index or a subscript. Arrays have a size, which is determined when they are created.

Arrays in Java have a length attribute, which is possible because they are considered as objects. However, C++ arrays are not objects and do not have a length attribute.

Generally Java is more robust than C++ due to the following:

  • Object references are automatically initialized to null.
  • References are checked before accessing, and exceptions are thrown in the event of problems.
  • Out of bounds array cannot be accessed
  • Memory leaks are prevented by automatic garbage collection, as mentioned earlier

Some more differences:

Due to the fact that as Java program runs on a virtual environment (Java Virtual Machine), programmers cannot access deeply.

Generally, Java can be just as fast or faster because the JIT compiler that can make optimizations that a C++ compiled program cannot because it can query the machine.

A C++ program has to be compiled beforehand usually with mixed optimizations so that it runs decently well on all machines, but is not optimized as much as it could be for a single configuration.

Java does heap allocations more efficiently than C++ because of the layer of abstraction between the garbage collector and the code which allows it to do all heap compression at once


Related Solutions

please write a brief essay describing the important concepts you have learned so far on FIN555....
please write a brief essay describing the important concepts you have learned so far on FIN555. Be as specific as possible and provide example of things you consider important. 1) present value concept 2) alter ative to npv; stock valuation 3)financial statements; free cash flow 4)capital budgeting; bond valuation
Write a short summary (200 words) of an article that you have found about preterm labor,...
Write a short summary (200 words) of an article that you have found about preterm labor, complications of pregnancy or fundal assessment (pick one). Please give the reference in APA form.
Write a three-paragraph essay describing your chosen function, and why you rank its importance so highly....
Write a three-paragraph essay describing your chosen function, and why you rank its importance so highly. Your essay must include three properly referenced and defined terms from the module reading. Answer and address these questions: What is the primary function you selected? How does it interact with the other functions? What would happen to “management” without your selected function? What factors cause you to rank its importance above the others? In addition to the text, you are encouraged to research...
Prepare a typewritten paper describing your plan to improve the process (TASK) you currently work in...
Prepare a typewritten paper describing your plan to improve the process (TASK) you currently work in or take an example of any US organization, presented with Problem Statement and Flowcharts. This plan should identify and explain the details of the process, including graphical representations and flowcharts. This paper will be coherent unification of operation management, and quality processes quantifying the magnitude of the anticipated improvement, e.g., quantifiable cycle time reductions, inventory cost reductions. Data depicting the results of the process...
Find a news article of your choice describing a good or service (you may use articles...
Find a news article of your choice describing a good or service (you may use articles from websites such as cnn.com or foxnews.com). Summarize the situation and identify what supply or demand shift factor is at work. Describe the effect on equilibrium price and quantity given the shift factor.
You have noticed in your life that you are assisted particularly in difficult times? Who is...
You have noticed in your life that you are assisted particularly in difficult times? Who is it and how they support you?
Assignment Content Imagine you have been asked by your local paper to write an article on...
Assignment Content Imagine you have been asked by your local paper to write an article on the use of Electronic Health Records (EHRs) in health care. Write a 350- to 700-word article for the paper in which you: Explain the functions and advantages of using EHRs. Explain the relationship between paper forms and EHRs. Describe the basic flow of information within a health care organization using EHRs. Cite any outside sources to support your assignment.
For this task, you are to write a report about a time you have provided individualized...
For this task, you are to write a report about a time you have provided individualized support to a client in the community services industry. If you have not provided individualized support for a client in the community services industry, please complete this in conjunction with your observation task. Your report must include details on the following: All information regarding the reporting and documentation you completed as part of your support.
For this task, you are to write a report about a time you have provided individualized...
For this task, you are to write a report about a time you have provided individualized support to a client in the community services industry. If you have not provided individualized support for a client in the community services industry, please complete this in conjunction with your observation task. Your report must include details on the following: a. How you provided support services for the client, including: i. What you did to prepare for the support activities, include information regarding...
Prepare a typewritten paper describing your plan to improve the process (TASK) in an organization like...
Prepare a typewritten paper describing your plan to improve the process (TASK) in an organization like Chick fil- A or McDonald's or any US organization, presented with Problem Statement and Flowcharts. This plan should identify and explain the details of the process, including graphical representations and flowcharts. This paper will be coherent unification of operation management, and quality processes quantifying the magnitude of the anticipated improvement, e.g., quantifiable cycle time reductions, inventory cost reductions. Data depicting the results of the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT