Differences in writing Java, C # and Javascript classes

This time I would like to mention the difference in how to write Java, Javascript (ES6) and C # classes.

Actually it may be complicated, but I think that there are quite a lot of people who wobble in the class.

I used to be like that, but suddenly I tried to write a Java program, and I had a problem because I didn't know the class. If you think that the concept of class extends the program above the method, you can easily program it. Actually, I think Javascript classes are still coarser than Java and C #.

//Javascript(ES6)

import {hogehoge} from './hogehoge';

class hogehoge{
    static hogehoge(height, width){
        this.height = height;
        this.width = width;
    }
}

//Javascript

import hogehoge from './hogehoge';

class hogehoge{
    static hogehoge(height, width){
        this.height = height;
        this.width = width;
    }
}

//C#

using hoge;

class hoge{
     public void hoge(height, width){
          this.height = height;
          this.width = width;
     }
}

//Java

import hoge;

class hoge{
    public void hoge(height, width){
        this.height = height;
        this.width = width;
    }
}

As you may have noticed, it may be easier to understand if you look at the built-in part of the library. When actually embedding Java and C # are embedding by class name when actually embedding. In the case of Javascript (ES6) and Javascript, the class name and implementation library name exist. In the case of Javascript class, the built-in library name and the class name must match. In case of Java or C #, it can be implemented by writing the class name directly.

Another thing to be careful about is how to write the method. In the case of Java and C #, since the ancestor language is C or C ++, the void class always exists, but in the case of Javascript, it is completed by suddenly implementing the static method. This is a feature of scripting languages that is implemented with static and dynamic methods. In the case of Java and C #, compilation always follows. In the case of Javascript (ES6), it is also a feature that a method called transpile is adopted.

In the case of ES6, transpile has a problem that it cannot be implemented unless it is restored to the original writing style of Javascript. Transpile implements it. For now, transpile is implemented in Babel.

The difference between the compile language and the script language is whether the script is actually replaced with the intermediate language or the OS, or the script itself is rewritten. You have to be careful that Java and C # require compilation, and Javascript requires transpiling when implemented in ES6. If implemented in Javascript, transpile is not required.

Please note that this may happen.

Recommended Posts

Differences in writing Java, C # and Javascript classes
Summarize the differences between C # and Java writing
Java and JavaScript
Differences in writing in Ruby, PHP, Java, JS
Java Direction in C ++ Design and Evolution
Java to C and C to Java in Android Studio
Reading and writing gzip files in Java
A note on the differences between interfaces and abstract classes in Java
java (classes and instances)
Differences between Java, C # and JavaScript (how to determine the degree of obesity)
Organize your own differences in writing comfort between Java lambda expressions and Kotlin lambda expressions.
Java classes and instances to understand in the figure
Try calling JavaScript in Java
[Java] Generics classes and generics methods
Reproduce Java enum in C #
About abstract classes in java
C # and Java Overrides Story
Java abstract methods and classes
[For beginners] Explanation of classes, instances, and statics in Java
Solving in Ruby, Perl and Java AtCoder ABC 113 C Reference
Think about the differences between functions and methods (in Java)
Differences in how to handle strings between Java and Perl
Differences between "beginner" Java and Kotlin
Read Java properties file in C #
Encoding and Decoding example in Java
A person writing C ++ tried writing Java
CGI in C and Dart: Introduction (1)
Writing code with classes and instances
StringBuffer and StringBuilder Class in Java
Reading and writing Java basic files
Understanding equals and hashCode in Java
Java generics (defines classes and methods)
How to use classes in Java?
Differences between Java and .NET Framework
Classes and instances Java for beginners
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
Note: Differences from Java as seen from C #
JSON in Java and Jackson Part ③ Embed JSON in HTML and use it from JavaScript
Difference between final and Immutable in Java
Specify the order in which configuration files and classes are loaded in Java
Call Java method from JavaScript executed in Java
Link Java and C ++ code with SWIG
moment.js (JavaScript) vs Calendar (Java) vs DateTime (C #)
Let's try WebSocket with Java and javascript!
Sorting AtCoder ABC 111 C hashes to solve in Ruby, Perl and Java
[Java] for Each and sorted in Lambda
Using JavaScript from Java in Rhino 2021 version
[Java] Differences between instance variables and class variables
Java programming (classes and instances, main methods)
Use "Rhino" which runs JavaScript in Java
JAVA learning history abstract classes and methods
Continued Talk about writing Java in Emacs @ 2018
Arrylist and linked list difference in java
Comparison of JavaScript objects and Ruby classes
Program PDF headers and footers in Java
The story of writing Java in Emacs
Learn Flyweight patterns and ConcurrentHashMap in Java
[Java ~ Classes and External Libraries ~] Study Memo (6)
Difference between int and Integer in Java