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
 
lambdafalcon profile image
falcon

Rust doesn't have garbage collection because it's memory model doest need it.

Thread Thread
 
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.

Thread Thread
 
lambdafalcon profile image
falcon

Yeah, I just got your comment "Without garbage collection" as if that's a feature missing from Rust.

Thread Thread
 
mate3241 profile image
mate3241

In a very literal sense it is missing from Rust, but yeah, could have phrased it better.

Thread Thread
 
ashoutinthevoid profile image
Full Name

It may be worth distinguishing between missing, which in context you seem to be using along the lines of 'not built in to the language or std library', and unavailable, which I would describe as a feature not being accessible at all when using the language in question.

Rust doesn't supply garbage collection in std, but if you have a specific case where you need it there are crates like gc that implement a specific form of it. Rust also doesn't supply async/await, but you can add Tokio or async-std and have that feature available if you need it. Both examples of Rust's preference for paying only for what you use and their specific approach to what is and is not included in the std library.

Java has a different approach, as far as I know.

Re the original article, talking about language replacement without talking about what the tool is being used for seems a little misguided. It's sort of the blog equivalent of making a technical decision without knowing any of the actual project constraints. Real world examples of switching to Rust (eg Discord switching certain services from Go to Rust) are specific to the use case, not just blanket 'rewrite all the things in Rust'.

Thread Thread
 
mate3241 profile image
mate3241

Great info, thanks!

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
 
lambdafalcon profile image
falcon

Why would anyone think that?

Rust is way more suited to replace other systems languages, e.g. C and C++.

Java is more likely to be replaced by other JVM languages like Kotlin.

Collapse
 
therickedge profile image
Rithik Samanthula

I had a lot of requests to make a blog on this topic

Collapse
 
gklijs profile image
Gerard Klijs

But Kotlin needs Java, so it can never really replace it.

Collapse
 
therickedge profile image
Rithik Samanthula

Yes this is true too

Collapse
 
lambdafalcon profile image
falcon

No, it doesn't. Kotlin and Scala and other JVM languages use the JVM, they don't use Java. They can be compatible with Java and import Java libraries, but they don't need Java to work.

Thread Thread
 
gklijs profile image
Gerard Klijs

Yes, but without Java, there is no JVM. And especially Kotlin, you really need Java libraries for some things..

Thread Thread
 
lambdafalcon profile image
falcon

That's absolutely not true, the JVM is separate from Java.
And which Java libraries do you really need in Kotlin?

Thread Thread
 
gklijs profile image
Gerard Klijs

Yes and no, although it's possible in principe to have a 'Kotlin' KVM maintened by JetBrains. So far the JVM is closely tied to Java.
I have a hard time seeing what you could do in Kotlin without any Java interop. Concurrent collections, networking, most of the JVM ecosystem, it's all Java.

Thread Thread
 
lambdafalcon profile image
falcon

What do you mean? Kotlin compiles to Java Bytecode, it does not need Java libraries to work.

The JVM was developed for Java originally but has had features built in to facilitate developing other JVM languages.

About the ecosystem: MANY libraries and frameworks already have Kotlin versions, first in line Spring and Android. Kotlin has even been the preferred language for Android for years now.

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 Gupta

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

Collapse
 
gklijs profile image
Gerard Klijs

“Technologies such as Rust and Go function the same way as Java but they are written in shorter code."
This is not true, it's much fairer to say it's all 3 different beasts, with their own strengths, once you want more than hello world.

I'm not very familiar with Go, so this might not be totally fair. But Go seems the best language for programs around networking, which don't need a lot of additional dependencies.

Java is mostly great for it's vast ecosystem, and Spring Boot. With it's easily to hook on almost any database, and expose is as you want, even 'official' with GraphQL lately. Also don't forget all the tools around it's JVM runtime for performance / safety etc.

Rust is nice when performamce is important, and when you want to reduce some categories of errors. The price to pay is that you need more time to program. Compared to Java and Go the core language is tiny. Even for random getting numbers you need a library. The ecosystem does get better. But when you want to connect to databases, or when dealing with formats like Avro its not as smooth as Java. And using Protobuf is possible, but not as smooth as with Go.

Some others mentioned already, probably no language will totally replace another language. I can imagine some things on the backend, I did in the past with Java, can be done with Rust now. But to be fair at the moment it would not be my first choice.

It's still good to know multiple languages, and there relative strengths through.

Collapse
 
labzdjee profile image
GĂ©rard Gauthier

I agree with most comments stating this lean article misses the point and there would be much to say around this fairly strange question from some (well also there was an article about 'will Rust replace Python', so there's no limit for puzzling questions).
As much it is right and interesting to wonder which fields Rust will address (like backoffice, embedded IoT, frontends, Linux and more generally OS'es system programming) considering its daring complexity, it appears quite clear to me to note Rust benefits from its youth while Java is quite ossified now. Rust is certainly fast, secure, and modern (with a much potent macro system). Will Rust broadly succeed where academic languages never made it through? No definite answer either way...
Java mainly thrived on backend, Android, and as a cross-OS solution (Eclipse, NetBeans...). Something remarkable and strange is Java never made its way in the browser as a frontend option. Such a void place ECMAScript addressed to such an extend its realm is much beyond now.
From some articles I come to read almost daily, C++, C#, ECMAScript and now TypeScript keep being equipped with many most discussed features like functional, asynchronicity, etc and boilerplate squashing. And yes Kotlin, Go, Swift... are also languages communities discuss much.
About Java? No so, very much not so. Uh? Never heard of modern Java as it is the case for modern C++, latest version of C# or TypeScript. And Rust in this respect as the new kid on the block is part of this heat.
I will not elaborate more on those fields Java was king years ago and now not a strong candidate any longer. Java opened a way and is probably lagging behind now. Nonetheless it has an immense installed based and is present in many prominent industries.
Does Java sound like Cobol to some extend?

Collapse
 
mate3241 profile image
mate3241

I am not sure if community buzz is a very useful metric here. I mean Java is certainly not cutting edge, but liked and used are two very different things. As a Java dev I am obviously biased, but I generally don't get the hate.
With the JVM and all the frameworks/tooling around it, even if it's dying, it will be a viable career option for quite some time still. Certainly long enough for me to pick up something else when the ship really starts sinking. Not everyone works in SV after all.

Collapse
 
labzdjee profile image
GĂ©rard Gauthier

Thank you for this addition. I fully agree with you. I consider Java as a big player for many years to come before it even faint and become a niche as Cobol or Fortran are now.
My reaction was not about buzz only, it was also as in the job offers and projects coming with many other options along with Java are looming large.
For a job seeker or a anyone wanting to engage in the software industry it would be wrong to assert Java is dying, don't go there (it even an option to consider if you plan to join many reference companies). It is still a very sound option for at least one solid decade to go. I'm sure you'll continue having fun with Java!

Collapse
 
jafar4all18 profile image
jafar

The argument that hello world easier to write is so and so language so it will replace this language is flawed.
Hello world is much easier to write in c. But still Java and cpp replaced C because there was some flawed in pure function programming.
Java was designed this way for a reason.

Collapse
 
samhdev profile image
Sam Huddart

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

This is just incorrect.

Java is compiled into byte-code and then interpreted by the JVM. Whereas rust is compiled to machine code.

Java itself forces hard OOP, hence the longer Syntax. Rust on the other hand has its lovely trait system.

Please do you research.

This article is horrible to read :)

Keep Coding Y'All 👨🏻‍💻

Collapse
 
ksaaskil profile image
Kimmo Sääskilahti

The article deserves its critique, but there's no reason to be mean and call the article "horrible to read". Everyone here is contributes and writes articles for free. Seeing comments like this can even scare other people from writing their own articles. Please be considerate.

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