Open Source Your Knowledge, Become a Contributor
Technology knowledge has to be shared and made accessible for free. Join the movement.
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.
Stringis immutable, so
StringBuilderclass 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
- In C#, even the primitive types are objects. Java features wrapper classes for the same role. (e.g.
- 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.
- 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
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!