DEV Community

Ankur Goyal
Ankur Goyal

Posted on

What's something that you can only do in java

Hey guys... can you tell me. What can you do only in java, which in not possible in any other language such as python, PHP, JavaScript.

Top comments (10)

Collapse
 
crisz profile image
crisz

There is nothing you can do in a programming language and not in another, as soon as they are turing-complete, and as soon we are talking about the output of algorithms and not technical features (e.g. pointers) or libraries (e.g. a lib for cryptography may be available in a programming language but not in another).

So the answer to your question is "nothing", and we should talk about programming languages as tools in the inventory of every programmer. If your goal is to hammer a nail every tool can reach your goal: a stone, a piece of wood, a screwdriver. But a hammer is the best tool for this specific scope. Java may be the best choice for many projects but it's not somehow magic or special

Collapse
 
jagedn profile image
Jorge

Explain to your boss this is not javascript

Collapse
 
cicirello profile image
Vincent A. Cicirello • Edited

Anything that can be computed in one Turing-complete language can be computed in any other Turing-complete language. So the answer to your question is: nothing. For an extreme example... If you can do it in Java, you can even do it in PostScript.

Collapse
 
ervin_szilagyi profile image
Ervin Szilagyi • Edited

As others have said as long as your language is Turing complete you can do anything in terms of algorithms.

If we look at the Java compiler itself, there are some quirks which are Java specific. One thing I can think of are checked exception. I might not be knowledgable enough, but as far as I know, only Java is forcing you the explicitly handle certain exceptions.

Most of the "usual" modern languages support exceptions, but they do not really force the developer to handle them.

"But with Go you have to handle errors..." 😤
With Go you have errors as returned values, which are not exceptions. Go has its own way of forcing you to think about exceptional cases, but that is entirely different of how exceptions work.

Collapse
 
derlin profile image
Lucy Linder

I was going to say compile into java bytecode for the pun, but even this is not true anymore with Kotlin and all 😄

Collapse
 
theelitegentleman profile image
Buhake Sindi

Kotlin is a JVM language, that runs on top of Java. It's not an independent language like PHP.

Collapse
 
derlin profile image
Lucy Linder

This was true at the beginning, but Kotlin Multiplatform now allows to "compile" into many more targets (javascript for one). I am not sure "JVM language" still holds now.

Collapse
 
mta67 profile image
Thomas Adrian

a bean

Collapse
 
ervin_szilagyi profile image
Ervin Szilagyi

Technically that's just a class with a set of properties. Now, obviously you cannot have Java Beans in other languages, for obvious reasons 😅, but the implementation of the concept itself should be pretty easy.

Collapse
 
citronbrick profile image
CitronBrick

Applets.