Why is Java always called verbose, but C++ never verbose? Letbyte Z explains, because Java supports only one programming paradigm, object-oriented.

Support only one paradigm, the advantage is rigorous, unified style; The downside is being dull and wordy.

Its main function, for example, can no longer be written as a separate function, as in other languages, but must be wrapped in a class that has no real use…

The “you have to class everything first, whether it’s necessary or not” requirement obviously leads to a lot of unnecessary indirection and a lot of other complications that arise from it — which is of course overly verbose compared to other languages.

Especially in the early, the relevant theory is not yet mature, plus the limitation of single model, makes it relative to other language already mature, very expressive weak – there is a famous speech, the effect is “the Java needs to come up with so many design patterns, is to express ability because it is too weak, can do other language is very simple, It has to be done indirectly through design patterns “(of course, these are mainly procedural and object-oriented style differences, not entirely Java flaws).

C++, by contrast, is a “multi-paradigm” language, unstructured, structured, object-oriented, macro, template… What works for you is what you get – you have the easiest way to do any job.

The drawback is that no one can “master C++” anymore — you can use it for C, for Java, for Object-C, for template black magic… But it’s best not to use it as C++. Otherwise, no one can hold it.

The same was true of Pascal: it supported only one paradigm of structured programming, and its pure, “straight” style made it the best “teaching language” at the time, but it was rarely used in real-world projects.

C, on the other hand, supported structured programming and also allowed you to interpret memory data arbitrarily. This gave it a lot of extra flexibility, and even now it’s alive and well.

Of course, things were different then and now.

Editors of the past were not as powerful and intelligent as they are today; Pascal’s “rigid” approach failed to bring more benefits than clear concepts in teaching. Instead, it was hindered by the constraints of a single paradigm, and it was no match for C.

But the syntax hints of modern editors are so handy — the syntax hints of “straight” single generic strongly typed languages are so handy that it’s hard to save syntax errors until the last curly braces come out: at the cost of a little formatting, you get a lot of bang for your buck…

In contrast, the overly flexible and arbitrary C++ syntax hints are unusually difficult to make.

Let alone the “dark ages” of 200x or so, even now, there are still a number of major editors that don’t provide java-level syntax hints for C++ code (I know of better syntax hints today, which work the same way as compiling in the background and actually parsing syntax trees) : The compiler must also support dynamic compilation of “half-pulled functions”, otherwise it is difficult to give accurate input suggestions.

As a result, no one could have persuaded me to join VIM: write C++ using a heavy IDE like eclipse/VS, otherwise the syntax is unreadable (of course, this is a long time ago). There are already many editors that can give high-level C++ syntax hints, and even automatically prompt for the correct parameter types after template instantiation. VIM, for its part, has long been able to create syntactically based hints; However, I was too lazy to write C++ with it in the early years. .

Similarly, due to the limitations of compiler development, Pascal syntax in the past was “rigid”, which made it incur significant additional performance costs (because there was no way to keep programmers “smart” like C); Now, Java, because of its own board, gives the bytecode compiler and the immediate compiler a lot of hints, allowing them to do deep optimization, which is extremely efficient execution…

Times are different, supporting technology maturity is different, a lot of things are different.

In short, there is no free lunch, and many correlations are not static; Every successful language is successful for a reason. Comment on the pros and cons should be based on the case, this is not easy to upset…

From: Lebyte