Back
Close

A Babel of Languages on CodinGame

TBali
66.3K views

Java

Java

When C# was introduced in the early 2000s, it was accused of being "just an imitation of Java". (Java is 5 years older than C#.) The two languages diverged much more since that time, but the similarities are still quite obvious. Therefore, this section will be much shorter than the previous one.

Checking the sample code

Looking at the syntax

We can see similar features as in the C# sample solution, like:

  • classes, a static method as main, a strong and static type system, arrays, type casting, iterators, loops, conditionals, etc. The syntax is slightly different, but I will not go into detail for these features.

Some differences:

  • Java's String is immutable, so StringBuilder class is used to append characters to the solution character by character. It is converted to a string only at the last step by calling its toString() method.
  • In C#, even the primitive types are objects. Java features wrapper classes for the same role. (e.g. Integer for int).
  • Of course, there are many more differences, which are not visible from such a short sample code, and are beyond the scope of this short introductory article.

Other characteristics

  • Both Java and C# are 'managed' languages. Java compiles to Java bytecode, which is then run on a JVM (Java Virtual Machine). Later on, we will see some other languages relying on the same JVM as its runtime environment.
  • By using JIT, their speeds fall in the same range.
  • Java is very popular in the enterprise application development, due to its "write once, run anywhere" philosophy.
  • Besides its Standard Edition (SE), Java has additional editions, such as Enterprise Edition (Java EE) which provides additional facilities for developing and running large, multi-tiered, reliable, and secure enterprise applications. Interestingly, in the past few years Java EE has lost some grounds, because cloud-native or microservice-based applications are more written in plain Java, using other frameworks such as Spring.

Resources to check

Meme

Coming next...

After checking 2 compiled, managed languages with a strong type system, let's explore some languages with a very different approach: weakly typed and interpreted! We start by looking at PHP!

Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io