DEV Community

Cover image for Is Rust going to Replace Java?

Is Rust going to Replace Java?

Rithik Samanthula on October 23, 2021

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 ...
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
 
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
 
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
 
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
 
peerreynders profile image
peerreynders

On May 27, 2008 Ted Neward published Dead like COBOL - Is Java ripe for replacement?.

And here we are 13+ years later. That type of legacy has enormous inertia.

If anything (one of my pet hypotheses is that) Google developed Go to de-emphasize the importance of Java within that organization:

  • eliminates OO dogmatism (in favour of a somewhat more procedural approach)
  • has a Pythonesk type of developer experience
  • can create standalone binaries
  • and most importantly: Not subject to constant harassment by Oracle
Collapse
 
siy profile image
Sergiy Yevtushenko • Edited
  • Instead of OO "dogmatism" it uses old-fashioned procedural dogmatism. That, seems, was not enough, so Go added generics and finally reached state of Java5
  • Go-style error handling and propagation produces enormous amounts of boilerplate noise, which makes business logic barely visible
  • Despite existence of Go, Google still uses and continues to write internally a huge amounts of Java code

Java also can produce standalone binaries, but this is not so often necessary. Didn't get your phrase about harassment. Perhaps it's something only you can feel.

P.S. I wrote commercial Go code and worked at Google (and their monorepo), so I know what I'm talking about.

Collapse
 
peerreynders profile image
peerreynders

You mistake me for somebody who likes Go — I don't. I think it was a particularly uninspired effort of 2007+ programming language design.

That said I'm aware that before Oracle got its mittens on Java it was one of the blessed four:

You have to play inside the fence defined by C++, Java, Python, and JavaScript.

Even when looking at the Closure Library I couldn't shake the impression that it was designed to appeal to the Java developer mindset — but that is just my personal opinion.

So it goes to reason that by the time Oracle acquired Sun MicroSystems in 2010 Google already had built up a substantial legacy Java code base that was too extensive to eliminate.

Didn't get your phrase about harassment.

Google LLC v. Oracle America, Inc.

Now that was largely about Android.

But it has a habit of getting into the headlines:

Thread Thread
 
siy profile image
Sergiy Yevtushenko

Sorry, for mistake, didn't mean to be offensive.

My experience with Google is much more recent and by that time Google actively used Java, both in existing and in the new projects.

As for harrasment: case between Google and Oracle is about money between two giant corporations. Despite how it was often represented in media, it was not battle between "good Google" and "greedy Oracle" about Java. And actually didn't presented any danger to Java. Anyway, the battle is over.

As for other cases, I really don't care. From the moment when Oracle made Java open source, their behavior is largely irrelevant - Java will survive regardless from Oracle actions.

Thread Thread
 
peerreynders profile image
peerreynders

The OpenJDK Transition: Things to know and do

This piece is by Rich Sharples, Senior Director of Product Management at Red Hat

Software vendors, including Red Hat, offer OpenJDK distributions and support to make sure that those who had been reliant on Oracle JDK have a seamless transition to take care of the above risks associated with not having OpenJDK support. It also allows customers and partners to focus on their business software, rather than needing to spend valuable engineering efforts on underlying Java runtimes.

More recently: Why Red Hat dumped CentOS for CentOS Stream

There ain't no such thing as a free lunch

Businesses need to get paid for their (commercial) support but the dynamics of how they ensure that they get paid should give one reason for pause.

Collapse
 
mate3241 profile image
mate3241 • Edited

Is the Oracle vs Google thing that bad? I honestly never considered the corporate aspect, so thanks for this.

Collapse
 
peerreynders profile image
peerreynders

Wikipedia: Google LLC v. Oracle America, Inc.

The other thing is that Oracle has a tendency to always look for better ways to fleece its customers — leading to corporate goals like this:

Migration Complete – Amazon’s Consumer Business Just Turned off its Final Oracle Database

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.

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

 
gklijs profile image
Gerard Klijs

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

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

 
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.

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
 
shubhampatilsd profile image
Shubham Patil

Yeah Rust has a pretty low chance since Java is everywhere, but Java might be on the decline for most aspects of development (in terms that i'll clarify next). If a new project were to choose a technology for their servers, they would choose JavaScript or Python. If they wanted a native Android app, they would most likely choose Kotlin, of if they wanted a cross platform app, Flutter/React Native. For games, Unity/Godot/Unreal are much more approachable than things like LWJGL and whatnot. Java is a great language to learn programming with, but I'm seeing less adoption of it in present time. Also yeah, Java is pretty popular still since 10 year old startups used them for their services and don't want to change the code. It's like with PHP: Facebook still uses it but you rarely see a new company using PHP.

 
siy profile image
Sergiy Yevtushenko

This is common misconception. Conciseness is useful only up to the point where context is preserved. As soon as conciseness is achieved by dropping parts of context, it starts to be counterproductive.
And no, bugs are not the reason of productivity decrease. They are consequence of mental overhead and loss of context.
I'm writing an article dedicated to exactly this issue and how to avoid it in Java. Hope to publish it soon.
Link to more detailed review of why Kotlin is worse for backend development I've provided in other message.

Collapse
 
overdash profile image
Pro

See, a better argument here would be COULD Rust replace Java... not "is". No language will replace another, except a never version of itself - ask Python, PHP and JS. But arguing COULD rust replace Java would've made for a much better article.

Spoilers YES Rust can replace Java... but I'm 100% sure it never WILL replace it.

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
 
jimlynchcodes2 profile image
Jim Lynch

In terms of a simple REST backend, many companies choose to write this in Java, JavaScript, Go, Python, etc... because, well, they like the syntax.

But if you really want the fastest execution time and lowest dollar cost for your backend, yeah, probably Rust is the best choice actually.

People who realize this are probably expecting that the number of others who have realized this will increase over time and hence the usage of Rust will continue to grow and "steal market share" from other languages.

Collapse
 
jfftck profile image
jfftck

There are plenty of the first generation of high-level languages still in use to this day, a large number of banks built on COBOL and have no need to change, so the majority of systems built in Java have no need or reason to be rewritten. If Java drops to the same level of usage as COBOL today, there will be an event that would cause a rush of hiring of developers who know the language, just like the Y2K bug had seen COBOL developers being paid top dollar.

Collapse
 
malikalamgirian profile image
Wasif Altaf

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

 
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.

Collapse
 
waxolunist profile image
Christian Sterzl

Oracle released Java? Tell me more.

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
 
therickedge profile image
Rithik Samanthula

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

Collapse
 
avantar profile image
Krzysztof Szala

Better ask yourself why would it replace Java at first place. Your question doesn’t make much sense.

 
siy profile image
Sergiy Yevtushenko

Just finished article which explains my views in details.

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
 
andrewbrown profile image
Andrew Brown 🇨🇦

Better yet is Rust going to replace everything? lol

 
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
 
lexiebkm profile image
Alexander B.K.

"Oracle released Java in 1995."
Uh... if Sun Microsystems still owned Java, we wouldn't be worried about license when using newer versions.

Collapse
 
anatame profile image
Anatame

Another dumb shit article.