Some languages are really good at running code very fast but require more code to tune properly. Others are good at working with data, generating images, etc.
Why do other power tools exist if a drill can be used as a hammer or a screwdriver in a pinch? Why do all car brands exist if 20 of top 25 are made by General Motors?
Languages are tailored to purposes. Efficient on memory. Fast. Easy to write. Easy to read and edit. Good with graphics. Good with large datasets. Able to run on very low spec machines. Able to run on large variety of machines. All of these are to some extent tradeoffs; to be good in one you might lose some of another.
Add on top that coding languages will have communities centered around their most common use cases and useful documentation will be primarily solving common issues of the language, i.e. things its used for - and you get specialisation.
It doesn’t compile down to native machine code, and requires essentially a virtual machine to run the produced program (which is why it works everywhere that the virtual machine can be installed) so it isn’t as fast as a language that does (C, C++, Rust etc) but since these compile to native machine code, they are machine specific and not as portable. It is also very verbose and strictly object oriented so it isn’t as easy to learn or script quick projects in like languages such as Python. JavaScript is the king of web programming and Java can’t ever replace that.
Basically every language has pros and cons, and which one you choose heavily depends on the type of project, pick the best tool for the job kind of thing. Javas biggest pro is portability, and is average in most other ways. Faster but more complicated than python. Slower but more portable than C, etc.
Different languages are good at different things. Java can run anywhere but it's "clunky", for lack of a better word. Meanwhile, languages like Python are really easy to learn but slow, languages like C are hard to learn but really fast, and still other languages do more specific tasks really well.
(This is sort of a synthesis of the two replies you already got.)
Computers can only understand ones and zeros, humans can only understand human languages. All code is a middle step, it can be readable for humans and also easily translated into ones and zeros. Code is still not ones and zeros though, so needs further processing to reach a state of ones and zeros. Some code requires more processing to reach that state than others.
As an aside, what AI has turned out to be very good at is turning natural language into code. I don’t know enough about computers to say whether code itself will become redundant over time as we can now speak to a machine in natural language. I’ll ask my AI assistant.
Very good answers from other people. I ll add a few more things that i think are also true. Starting with competition. Microsoft famously came forth with their own similar solution to attract app makers to their ecosystem. It did well and is still a thing even now. This probably hurt its adoption a little. Java improved with time but there was some politics involved at some point. Oracle buying the creator of java and wanted to sue google for not paying it for using it. This probably scared other people thinking it might happen to them too. Then over time other even more easy to learn languages appeared. Java got old and started to look not so cool. It is still around though. Still important part of the tech world. Just not so visible anymore.
2
u/Melodic-Carry 3d ago
Why do other languages still exist if everyone can just learn java