Alright, this article is aiming to answer this very popular answer to newcomers in the IT world.
If you ask yourself this question you're probably starting programming and think of choosing the proper language. We will see that's not the real question.
Both are programming languages, they achieve the same goal which is to automate some tasks using programming.
By scripting it means that code can be serialized and executed within runtime (however, there are kind of caching mechanism to optimize the runtime performances inside the engine)
What is Java?
Java is an object-oriented programming language. Java promised, "Write Once, Run Anywhere".
This is achieved thanks to a virtual machine platform that allows you to create compiled programs that run on nearly every platform.
This is a very popular language, widely used in industry, especially in banking.
Static typing and compilation
Java is a strongly typed language, which means you should give them a type and declare them before using it. In Java, the type of a variable is checked at compile-time. Java can only run compiled with machine code and force compilation.
TypeScript can help in such cohesion.
- Java is Object-oriented only, all the code is written using classes and gives objects instances at runtime.
Now there is kind of classes that are not advanced like their Java version but allows of kind of Oriented Object Programming (OOP).
Using TypeScript, you can mimic the behavior of typing and encapsulation.
You have more freedom and it's also easier to play with JSON, which is the most used data format in the world. But remind to be consistent in the way you write code.
- Java uses thread to manage concurrency, which can get complicated when the program grows and need to sync data between thread.
Generally speaking, I can only suggest learning Object Oriented Programming to learn best practices of coding.
- Java gives you a context that you need to respect and this is great to learn.
Java has overall good performances and by ensuring types it gives strong confidence in code.
You can use it server-side, on desktop, and also with Android.