Home Java Differences between C++/Visual Basic and Javaat a general level (for beginners and students)

Differences between C++/Visual Basic and Javaat a general level (for beginners and students)

by admin

C++ and Javaare one of the very popular programming languages. They can be compared in detail, comparing speed, typing, compilers, etc., but it’s too much for an average layman, and it’s much easier to consider their differences at a general, basic level, so that even a person far from the programming and only looking at this area could make conclusions to himself. Already at this stage you can conclude which paradigm language is right for you. And yes, the situation of such a choice is quite real – for example, for students for educational purposes.
To do this I will try to look briefly at the basic constructs of programming languages, namely :
expressions : mathematical, logical, string;
Operators : composite operator, assignment operator, conditional IF operator, FOR and WHILE loops, GOTO operator, and others;
Subroutines : procedures and functions;
data types : basic types, structures, classes, interfaces, and templates.
(this article is not a translation, but my personal analysis of the information collected)

Expressions

Java

Mathematical expressions

A mathematical expression is an expression that results in a number. They include variables, functions, and constants.
Arithmetic operators in Javaallow you to perform standard mathematical operations of addition, subtraction, multiplication, and so on. The language also has decrement and increment operators (increase or decrease a value by one).

Logical expressions

A logical expression is a description of an expression whose result is true or false. Logic operators work only with operands of type boolean.
All logical operators with two operands combine two logical values to form the resulting logical value.
Java supports over ten operators: AND (logical and abbreviated), OR (logical and abbreviated), XOR, NOT, and so on.

String expressions

A string expression is a manipulation of strings. It looks like a mathematical expression, but the result is a new string.
The Java language allows you to add, subtract, divide and join strings. A distinctive feature of Java is the String class, designed specifically to work with strings.

C++ / Visual basic

Mathematical expressions

C++ and Visual Basic also have arithmetic operators, decrement and increment operators, and the syntax of mathematical expressions also supports brackets and unary minus.
Just as in Java, they have more complex operations available as built-in functions, such as the square root of sqrt(x) and exponent exp(x).

Logical expressions

Visual Basic uses six operators: in addition to AND, OR, NOT, XOR, the equivalence and implication operators are also used.
C++ uses three logical operators: AND, NOT and OR. In all languages considered, some of the operators can be used for several operands at once.

String expressions

Unlike Java, C++ has no built-in support for objects like strings, and if you need to work with strings (addition, subtraction, etc.) you have to include the header file string.
In Visual Basic, because of the importance of working with strings, the String data type, which represents a sequence of characters, is supported. A variable of this type can accept any expression that results in a string.

Operators

Java

All languages considered are similar in that they support loop operators (FOR, WHILE), the IF condition operator, but the essential difference is that in Java there is no goto operator as such : the keywords "const" and "goto" are retained but not used.

C++ / Visual basic

C++ and Visual Basic, developed much earlier than Java, have a goto operator, but the use of this operator is generally undesirable.

Procedures and functions

Java

A subprogram is a named, logically complete group of language statements that can be called to execute any number of times from various places in a program. Functions return some value to the main program; procedures do not.
In Java there are no procedures or functions, both are called methods, but they may or may not return values, and they may or may not be called with or without parameters.

C++ / Visual basic

In C++, subroutines are implemented as functions. A C++ program consists of one or more functions that must be described before they can be used.
Visual Basic programs also consist of several subprograms, which are divided into procedures and functions.

Data types

Java

Java uses certain conventions for all basic numeric types independently, independent of the particular implementation of the environment, which guarantees reproducible results on a wide range of platforms.Also In Java there are no struct and union constructs, it is all combined into class concepts.
In addition, Java does not support pointers (their role in Java is played by so-called "references"), templates, operator overloading, structures, etc.

C++ / Visual basic

C++ inherited from C all of the latter’s usual data types. These types are used to represent integers and real numbers of various sizes and accuracies. Unfortunately, the actual range and accuracy of these types varies depending on the particular implementation of the translator.
Because of the translator dependency on different platforms, the behavior of C++ and Visual Basic code can vary. C++, on the other hand, tries to provide the programmer with the ability to encapsulate data by declaring structures (struct) and polymorphism by means of unions. These two constructs cover critical and catastrophic machine-dependent size and alignment constraints.
C++ and Visual Basic support pointers and pointer arithmetic, operator overloading, etc.

Results

The Java language was developed under the influence of languages that existed before it, including Visual Basic and especially C++, which means that some of the constructs of these languages overlap, but Java has corrected many shortcomings of C++ that affected program performance and results, and has also taken measures to "simplify" the language compared to C++, which implies that Java is significantly different from C++. Despite the presence of similar constructs, Java is very different from both C++ and Visual Basic.
P.S. Just in case, I’ll mention that it’s not my intention to give advice on choosing a language to learn or the best language to learn, but only to provide food for thought. And by the way, how did you choose your first programming language? Or were you "forced" to write in a certain language?

You may also like