DEV Community

Cover image for Is Rust going to Replace Java?
Rithik Samanthula
Rithik Samanthula

Posted on

Is Rust going to Replace Java?

Hey Coders!!

A lot of you have been telling me that rust is soon going to replace java.

Looking at the perspective of the number of people using java, I would say Rust isn't going to replace java.

I don't think a language can fully replace another one.

Oracle released Java in 1995. It is still used worldwide by so many developers out there.

I mean, sure, Java is pretty lengthy and we need another way to make it easier to write code.

Technologies such as Rust and Go function the same way as Java but they are written in shorter code.

Hello World Written in Java:

class Simple{  
    public static void main(String args[]){  
     System.out.println("Hello Java");  
    }  
}
Enter fullscreen mode Exit fullscreen mode

Hello World Written in Rust:

fn main() {
  println!("Hello world!");
} 
Enter fullscreen mode Exit fullscreen mode

Well, Rust does have a lot of new more interesting ideas and concepts but we don't know whether they are going to be adopted universally.

There are also a lot of other companies that have java code written in their programs.

One advantage of using Java is that you have a lot of libraries and APIs available.

Well, Rust doesn't really have as many developers as Java does.

Rust might not be large enough to become a conventional language.

The Final Reason why I think Java won't be replaced is because the entire company of Android has a lot of servers that run on Java.

Overall, There is a possibility that Rust could replace Java but it most likely wont.

I hope I answered your question and I hope you enjoyed this blog!

And don't forget...

Keep Coding Y'All πŸ‘¨πŸ»β€πŸ’»

Oldest comments (73)

Collapse
 
guptashreyansh profile image
Shreyansh Gupta • Edited

I don't know about rust but I think kotlin is better in terms of development experience and most of the time kotlin code is concise and shorter than java code.

Collapse
 
mate3241 profile image
mate3241 • Edited

Yes, but Kotlin was designed with this exact mentality. Java plus some features, minus some annoyances, basically.
While I assume that you can do most things in Rust, it is primarily a speed and memory safety focused language. Without garbage collection, I might add. That does not make Rust bad, obviously, but I genuinely don't see the point of this article.

Collapse
 
gklijs profile image
Gerard Klijs

And adding some other annoyances, like not being able to use Java 17 together with Kotlin at the moment.

Thread Thread
 
therickedge profile image
Rithik Samanthula

Right.

Thread Thread
 
mate3241 profile image
mate3241

I was actually wondering about that. Is Kotlin supposed to be compatible with Java in the future as well? If not, major RIP.

Thread Thread
 
therickedge profile image
Rithik Samanthula

True.

Thread Thread
 
gklijs profile image
Gerard Klijs

Yes, and likely it's won't be much longer before Java 17 is supported. Spring is likely to take a year before going to 17. If it's not possible by then, it's going to be a major deal breaker. Originally people used Kotlin mostly because they were stuck on also JVM's with Android. Kotlin also has other compile targets, like native and js. But I think they are still used very little.

Thread Thread
 
therickedge profile image
Rithik Samanthula

Despite all the differences between the two languages, Java and Kotlin are 100% interoperable. You can call Kotlin code from Java, and you can call Java code from Kotlin.

Thread Thread
 
gklijs profile image
Gerard Klijs

Not 100%, you can't call a coroutine from Java, and you can't use Java Code that contains records for the moment. But yes, it all runs on the JVM, as does Scala, Groovy and Clojure, which you could use all together in one app.

Thread Thread
 
gklijs profile image
Gerard Klijs

Seems you can use Java records with Kotlin (and even define them in Kotlin)
kotlinlang.org/docs/jvm-records.ht...

Collapse
 
siy profile image
Sergiy Yevtushenko

Conciseness per se is pointless. Development productivity is only thing that matter when comparing Kotlin and Java. And Kotlin often is worse than Java in this regard. At least for backend development.

Collapse
 
mate3241 profile image
mate3241

Do you have personal experience with this? I wonder if this will change with time as people adapt to using the language more. In my area, Kotlin jobs or even projects are still very rare unfortunately, so please elaborate.

Thread Thread
 
siy profile image
Sergiy Yevtushenko

This might change over the time, but odds are low since some issues are inherent to Kotlin as a language. Here is my answer on similar question with more details and my personal experience.
I should note, that many Java issues, which make people consider Kotlin, can be solved by adopting Pragmatic Functional Java in combination with Java 11 and up (especially Java 17).

Collapse
 
mate3241 profile image
mate3241

I don't know much about Rust, but from what I gather, it has about the same chance of replacing Java as JavaScript replacing C in the Linux kernel. Would make roughly the same amount of sense too.
Also, 3 vs. 5 lines in a hello world program proves what exactly?

Collapse
 
overdash profile image
Pro

I doubt rust would replace Java but it defo has more of a Chance replacing Java than JS has replacing C.

Rust is intended to actually replace C++; it adds all the safety features needed to make responsible code with C/C++, but brings a modern syntax with what I'd say is by far the most helpful compiler ever.

Collapse
 
lexiebkm profile image
Alexander B.K.

If I want to build a desktop GUI app using GTK, I would certainly pick C++, because Rust executable size is big and takes very long to compile.

Thread Thread
 
llaith profile image
Nos Doughty

Err... and the C++ one will likely have bugs and race conditions, and the Rust one won't.

Do you not understand the value proposition of Rust?

Collapse
 
udalrich profile image
udalrich

Rust has less boilerplate here, but only because there is nothing that needs error checking or making the borrow checker happy. I suspect a thirty line piece of java ported to scala and rust would have the fewest lines in scala. Java probably comes in slightly smaller than rust, but could easily be a little bigger.

Collapse
 
luizc91 profile image
LuizC91

I guess this isn't about the number, but the length of the lines. You can have less lines, but with a bigger length.

Collapse
 
stefan_aichholzer_e61f13c profile image
Stefan Aichholzer

Oracle did neither create nor release Java. It was Sun Microsystems, which Oracle acquired in 2010.

Collapse
 
vasyaa profile image
Vasiliy Astapov • Edited

Looks like author have no idea

Collapse
 
siy profile image
Sergiy Yevtushenko

While I like Rust a lot and consider its approach to resource management brilliant, I believe that Rust has very little chances to replace Java. First and foremost, it has no sensible advantages for enterprise app development - main Java use case. Rust is still more complex to use than Java and Java still has much more developers than Rust.

Collapse
 
malikalamgirian profile image
Wasif Altaf

Oracle did not release Java in 1995. Get your facts right please.

Collapse
 
alvarosc2 profile image
alvarosc2

I read somewhere else about the chances of using rust in the Linux kernel development. Specifically in device driver development to make it easier.

Collapse
 
mi_native_nutt profile image
Mark

In 2021 comparing languages especially in the arena that Java plays is not comparing the right thing. I will include kotlin in Java and any other jvm language that plays well with Java. The reason being is all of the quote on quote microservice Frameworks all of the libraries all of the years of development all of the companies using it to include Enterprises and companies like Netflix to include the humongous community. That is what any language has to overcome. I don't see any language of run time doing that or even coming close. I used lots of different languages over my 26 years of my professional software development experience

Collapse
 
sunitk profile image
Sunit Katkar

Every programming language has its pros and cons and over time becomes suited for certain kind of development. No language replaces any other language ...

Collapse
 
mate3241 profile image
mate3241

Well, if we talk about a great enough time period, most languages will be replaced, at least at the general usage level.
I still hope that JS becomes the browser version of Java bytecode. Any day now!

Collapse
 
gklijs profile image
Gerard Klijs

For the browser we have been stuck on JS, or at least compiling to JS for a while now. With WASM there finally seems an alternative, although currently you still need a bit of JS.

Collapse
 
therickedge profile image
Rithik Samanthula

Yes, I don't think Java is going to be replaced

Collapse
 
thisisanshgupta profile image
Ansh

I don't think Rust or any other language can replace Java as in today's world most of the devices are running on Java even Android also.

Collapse
 
therickedge profile image
Rithik Samanthula

Yes, I don't think Rust will

 
mate3241 profile image
mate3241

Yes, but that comes with additional complexity. Which is not a bad thing, as I said. We could say that Java does not have an ownership model because it's garbage collected nature does not need it.
It's just a different approach that demands different things from the programmer.

Thread Thread
 
mtrantalainen profile image
Mikko Rantalainen

I think the most important part of Rust is that its ownership model also allows thread safety without manually synchronizing access to shared memory. Java cannot do that even in theory.

Some comments may only be visible to logged-in visitors. Sign in to view all comments.