Java Direction in C ++ Design and Evolution

Preface

It seems that there are many people who say that Java is old and not cool from the viewpoint of the "Imadoki" language. On the other hand, my claim [^ 1] from Hirao that "No, Java is aiming for a great moderation in the first place, so this is fine" is "C ++ design. And evolution ”is the basis for loose poetry.

[^ 1]: I just think so

Why "C ++ Design and Evolution"?

It goes without saying that Java is influenced by C ++. And, of course, Java has some choices from C ++ and some not. By reading "Design and Evolution of C ++", which tells in his own words how Stroustrup made C ++, I think it will be possible to see how Java chose the current path. think. Aside from that, "Design and Evolution of C ++" should be read by any programmer who loves programming languages after overcoming the barrier of consciousness that "any language can move" regardless of whether C ++ can be done. I think it's a good book.

The problem is that new products are no longer available. In writing this article, I borrowed it from the library for the first time in a while and read it ...

Java Direction in C ++ Design and Evolution

So, unless otherwise noted, the following quotes are from "C ++ Design and Evolution".

Classes and interfaces

As you all know, Java has classes, abstract classes, and interfaces, but I'm sure some of you may be worried about how to use each, especially abstract class and interface.

Function definitions are usually specified "outside" (outside the class declaration). That's to make the class declaration (...) purely like an interface specification.

In Java, this is class and interface, isn't it? It can be said that the interface was prepared just "to make it look like an interface specification".

Did not correctly explain to C ++ users that they use derived classes to separate the interface from the implementation. I made an effort to explain it, but it seems that the purpose was not properly communicated. Perhaps the main reason for this failure is that many (most?) C ++ programmers and other programmers interested in C ++ express themselves in class declarations that specify interfaces-one of the implementations of objects. I never dreamed that I could write a club, which is equal to what I had to do. If can is misunderstood as have to and the "always" expression (implementation) is written in the class declaration, the benefits of the derived class I tried to explain disappear. Naturally.

Yes, you can also write the implementation inside the interface, this is an abstract class.

I'm not sure if the Java class system was actually designed in line with the idea of Strawstrap, but if so, it would be better to design with interface and implement with class, abstract class. I think it is possible to think that there was no particular need. However, Java seems to have chosen to have as an abstract class the part that C ++ had as a result, "the expression-a part of the implementation of the object-can be written in the class declaration that specifies the interface". Seems to be. I think I had the option of not having an abstract class, but Java dared to do that.

Why C ++ is based on C

There are several reasons why we didn't make a big difference from C. Integrating C's suitability for systems programming with Simula's ability to organize programs was a major challenge. If we added important features of other languages one after another, it would become a "shopping list" language, resulting in an unfocused language.

If we had ignored C and Simula's implemented technologies from the beginning, C with Classes and C ++ would have taken longer to mature.

I think these are probably language implementation stories, but even when it comes to language specifications, it would have been of great significance for the spread to not change what is already there.

Syntax

The C syntax I hate the most is the declaration syntax. Many people are confused because there are both prefix and suffix operators for declaration.

The negative reaction from users to this part of the change was very strong.

Even in Java, for example, array declarations

String[] values = null;

Although this notation is recommended

String values[] = null;

It's okay to add [] to the variable What if

//Even without spaces
String[]values = null;
//Even if it sticks to the beginning of a variable
String []values = null;
//Even if it's scary
String   []   values = null;
//Even if you break a line
String values





[] = null;

All of these are also accepted. Again, I'm sure there was a choice to allow only the first notation, but Java didn't. Java also chose not to make syntax changes that Stroustrup couldn't do in C ++.

Afterword

Besides, why is there a primitive type and it is not pure as OOPL? I'm sure there are a lot of things that make me want to say that, but I'm sure Java knows everything and chooses it. To stay blunt and moderate, forever and ever.

I love Java like that.

Recommended Posts

Java Direction in C ++ Design and Evolution
Java to C and C to Java in Android Studio
Reproduce Java enum in C #
C # and Java Overrides Story
Solving in Ruby, Perl and Java AtCoder ABC 113 C Reference
Read Java properties file in C #
Encoding and Decoding example in Java
CGI in C and Dart: Introduction (1)
StringBuffer and StringBuilder Class in Java
Understanding equals and hashCode in Java
Encrypt with Java and decrypt with C #
Hello world in Java and Gradle
AtCoder ARC 081 C hash to solve in Ruby, Perl and Java
Difference between final and Immutable in Java
Link Java and C ++ code with SWIG
[Java] for Each and sorted in Lambda
Program PDF headers and footers in Java
Reading and writing gzip files in Java
Difference between int and Integer in Java
Discrimination of Enums in Java 7 and above
Sorting AtCoder ABC 111 C hashes to solve in Ruby, Perl and Java
Regarding the transient modifier and serialization in Java
Create barcodes and QR codes in Java PDF
Detect similar videos in Java and OpenCV rev.2
Partization in Java
Java design pattern
Difference between next () and nextLine () in Java Scanner
Changes in Java 11
Rock-paper-scissors in Java
Java Design Patterns
Detect similar videos in Java and OpenCV rev.3
Add, read, and delete Excel comments in Java
Check static and public behavior in Java methods
[Java] Understand in 10 minutes! Associative array and HashMap
Summarize the differences between C # and Java writing
Java and JavaScript
XXE and Java
Java and Swift comparison (3) Class implementation / Class inheritance / Class design
Distinguish between positive and negative numbers in Java
Java adds and removes watermarks in word documents
Detect similar videos in Java and OpenCV rev.1
Pi in Java
Represents "next day" and "previous day" in Java / Android
Questions in java exception handling throw and try-catch
Upload and download notes in java on S3
Parse the date and time string formatted by the C asctime function in Java
Encrypt / decrypt with AES256 in PHP and Java
Generate OffsetDateTime from Clock and LocalDateTime in Java
FizzBuzz in Java
Convert JSON and YAML in Java (using Jackson and SnakeYAML)
I tried Mastodon's Toot and Streaming API in Java
Write ABNF in Java and pass the email address
Solving with Ruby, Perl and Java AtCoder ABC 128 C
Vectorize and image MNIST handwritten digit image data in Java
[Java] Difference between static final and final in member variables
Java classes and instances to understand in the figure
[.net, Java integration] Nger that executes .jar in C # .net
Java joins and splitting table cells in Word documents
This and that for editing ini in Java. : inieditor-java
How to convert A to a and a to A using AND and OR in Java
Reverse Enum constants from strings and values in Java