Rust vs Java: A Staff Engineer's perspective

preview_player
Показать описание
Are you trying to decide between Rust and Java for your next project? Look no further! In this video, Dario Lencina, staff engineer compares the two programming languages in terms of concurrency, syntax, licensing, and tooling. Whether you're a seasoned developer or new to the scene, this video has something for everyone. So sit back, relax, and let us help you make an informed decision on Rust vs Java.

If you're wondering if Rust is a good language for you, or if Java is still the king of the hill, then this video is for you! I'll share my thoughts on the different languages, and let you know which one I think is the best for certain scenarios. So what are you waiting for? Watch the video and make your decision!

I am doing this, because you, my dear subscribers requested it.

00:00 Java vs Rust Intro
00:14 Apple Pay uses Java
00:21 AWS wants to contribute to Rust
00:56 Rust vs Java motivation and methodology
01:36 How not to compare java and rust
02:00 Table of contents
02:28 Java language goals
03:54 Java Licensing
04:50 Rust Security
05:32 How Memory Management works in java
06:15 How Memory Management works in rust
07:07 Dangling pointer in Java
08:23 Dangling pointer in Rust
09:10 Null pointer in Java
09:33 There are no null pointers in Rust
09:38 Making rust panic using refcell
10:00 Compilation
10:46 Blocking Concurrency
10:57 Deadlock in java
12:10 Deadlock in rustlang
13:19 Non Blocking concurrency
13:30 Create multithreaded mpmc channel with java vs rust
18:21 Tooling
19:00 Install java sdk with sdkman
19:13 managing rust toolchain with rustup
19:54 Using sdk man to install gradle
20:49 create rust project with cargo
21:14 Spring boot vs actix memory and cpu comparison
23:49 Conclusions: both are awesome, (but Rust is newer and better)
Рекомендации по теме
Комментарии
Автор

💞💞 this is the real full comparison.
And Thank you Dario for the shoutout 💞🔥

hamdysaadpersonal
Автор

people who complain about the main method in java have no idea what theyre talking about.

RealViPdude
Автор

I write Rust so I can keep my passion alive and I write Java so I can stay employed

ReedoTV
Автор

Compilation times would be nice to compare. Say, Spring Boot vs Actix or smth. That would be the place Java shines, especially because it doesn't need to recompile all your dependencies even once.
But the real difference would be in the possibilities. In Java, you can change byte code during loading (per class basis) so you can write your "agent" which would instrument client's code with whatever logic you need. It is utilised heavily by telemetry libraries such as DataDog, OpenTelemetry, etc. In Rust, I think, you have to instrument your code manually.
And Java has pretty good Reflexion API. Haven't seen any in Rust

These could be a real dealbreakers for some projects I think.

Taurdil
Автор

I have one tiny nitpick about around 17:10 and in a couple other instances. If you want to compare the libraries of the languages to one another that's one thing. But it should be explicitly stated that you keep saying "Rust" and "Java" interchangeably with "Rust's libraries" and Java's libraries.

I see people do this a LOT when they're comparing two languages but in fact they are just comparing the libraries for the language.

Gennys
Автор

Great video and thanks for going into the details. I've grew up with Java/C++/Python and been learning some Rust for a year as an additional tool to get things done. It's been a pleasure to work with.

karimjedda
Автор

There is a little mistake in mpmc section related to Java assumptions. You must pass the final or effectively final variable to lambda but not to thread. And behavior for primitives and objects are the same. In Java, all parameters are passed by value. In the case of an object, the value is a reference to that object, so the reference still keeps the final props. But anyway, it's a great video!

olexandrkostiuk
Автор

Ironically, I searched "Rust vs Java" and the first video was 1:36. I immediately closed it after seeing the while loop. :D Then youtube recommended this video on my homepage and here I'm. Such a cool channel.

morgomi
Автор

There is null in rust, std::ptr::null

professornumbskull
Автор

25:00 I don't understand what did you show here. In Java you demonstrated how keeping a reference to the object prevents it from being collected. In Rust you just showed that once the object is deallocated you can't call it. These are 2 different features.
I don't know Rust, I actually wanted to see how Rust behaves when you copy the reference/pointer to an object and the deallocate the original (but not the copy).

orsivan
Автор

I'm not sure it's even possible to compare a language relying on a runtime with GC with a language with a deterministic runtime. Their problem domains do not even overlap.

vitalyl
Автор

I use Rust and Java in my latest app RDS. I use Rust to write CGI code, it is executed inside a Java container and certainly the websocket part is handled by Java. Did I mention that a build tool for the project written in Rust? So no controversy is here, just a collaboration.

kamertonaudiophileplayer
Автор

I think you'd benefit from a boom filter on your microphone.

It's not too bad without it, but it would help manage those plosives.

andrebrait
Автор

Bro's really testing an oriented application-maker language in a webpage competition

vencedor
Автор

great video! about dead locks - is there any abstraction around rust Arc<Mutex> to prevent it? like all of your values must implement some trait to use it between threads - and throw error on compile time if you trying to do so

kuqmua
Автор

I used Java a lot in the past and it was never the greatest pain in any project. It is noisy and requires to write quite a lot of boilerplate to setup dependency code, but you get a lot of high quality functionality for free that you won't easily find in other ecosystems. You occasionally run into problems with memory leaks and concurrency, but once you understand the typical causes, this is manageable. Java is often slower than compiled and optimized code, but I very rarely saw that being a real problem.

That being said, I don't see that Java has any substantial advantages over more modern languages like Rust, Go, Zig, or Swift, unless you need the pool of high quality libraries available for Java.

Of these modern choices, I like Zig best, because it is the least opinionated offering the best compatibility to the C family of languages. It has the potential to become the fastest language with the least overhead, maybe with the exception of Mojo and it is much less perly (really don't like the quirkiness of Rust).

I find Rusts borrow checker problematic, because it's by far not as intuitive as garbage collection (just ignore memory management in most cases), creating quite a bit of learning overhead and managing non-local life-times is hard. Zig's approach to manual management is really nice, solving most problems through convention and static analysis while providing full control making this a practically viable model. Swift has an efficient reference counter not requiring garbage collection, which is ok but not great.

What I love about Zig is that you maintain full control over everything and still have a lot of comfort, productivity and sufficient safety (the last is debatable, that's my opinion)

michaelutech
Автор

the rule at 15:38 applies when you passing a variable into a lambda function. variable have to be either declared final or be effectively final, meaning there should be no mutation of variable after its initialization, which is violated by i++ in this case

vitaliikocherga
Автор

and yes, would like to talk about async programming. is there implicit timeout for async functions in rust and what happens if you reach it - and how handle timeout error for async functions without panic - with Result<Ok, Err>.

kuqmua
Автор

Could a boxed value in Rust help create that dangling pointer?

kobibr
Автор

Good video, and you are on point that everything is a tool, good engineers do not fanboy over one or the other just know what is better to use in which situation.
Performance is not a perk of the language but your knowledge of how hardware works and how to write code that takes advantage of it. You can have insane performance with both.

krellin