Rust vs Java: A Staff Engineer's perspective

Поділитися
Вставка
  • Опубліковано 15 вер 2024

КОМЕНТАРІ • 160

  • @hamdysaadpersonal
    @hamdysaadpersonal Рік тому +12

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

    • @dario.lencina
      @dario.lencina  Рік тому +1

      Thank you my friend, I hope you have an awesome 2023!!

  • @RealViPdude
    @RealViPdude 8 місяців тому +49

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

    • @dario.lencina
      @dario.lencina  8 місяців тому +8

      That is exactly right, nowadays you do not even have to type it, the use will do it for ya

  • @ReedoTV
    @ReedoTV Рік тому +48

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

    • @dario.lencina
      @dario.lencina  Рік тому +1

      The market is ready for rust developers! Checkout all the positions on LinkedIn

    • @gmodrules123456789
      @gmodrules123456789 Рік тому +10

      Java can be fun if you write it intuitively rather than following some strict guideline

    • @dario.lencina
      @dario.lencina  Рік тому +2

      I agree! I remember the Java EE enterprise beans stuff, it makes me sad!

    • @gowthamk7416
      @gowthamk7416 29 днів тому +1

      @@gmodrules123456789well said I like playing around with Java without following any guidelines but no one cares about it so the hate is more on the community rather than the language

  • @orsivan5731
    @orsivan5731 2 години тому +1

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

    • @dario.lencina
      @dario.lencina  2 години тому

      I am trying to look at the time stamp that you mention but the video is 25 mins, if you share the time stamp I can explain

  • @Taurdil
    @Taurdil Рік тому +7

    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.

    • @dario.lencina
      @dario.lencina  Рік тому +5

      Yes! Compile time is still terrible in Rust! Also Java Agents are awesome! I completely forgot about them.
      I love how mature the Java echo system is!

  • @professornumbskull5555
    @professornumbskull5555 Рік тому +19

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

    • @dario.lencina
      @dario.lencina  Рік тому +7

      Yikes, thanks for pointing this out, how do you use it?

    • @professornumbskull5555
      @professornumbskull5555 Рік тому +18

      ​@@dario.lencina You don't. Null pointer should not be used in application, in any form, unless you're working with Systems development. You can get a null pointer by invoking function, ptr::null(), which gives you a raw pointer, pointing to null, which to do anything with, you need to be in an unsafe block.

    • @dario.lencina
      @dario.lencina  Рік тому +1

      Makes sense, 👏🤗 thank you so much

    • @coffee-is-power
      @coffee-is-power Місяць тому +1

      @@dario.lencina LIke there's references with & in rust and then there is raw pointers that are similar to C and C++ pointers which you only use with low level programming and when you're interacting with C libraries and calling external code and you need an unsafe block to dereference them because they don't have an associated lifetime and the rust compiler does not check those so it might point to invalid memory addresses or even be a null pointer just like in C and C++
      Btw references can coerce to raw pointers but to convert a raw pointer to a reference you need an unsafe block and specify a lifetime (or none if you want 'static)

    • @josephp.3341
      @josephp.3341 Місяць тому +2

      Also: Option will be optimized to a raw pointer with a null pointer check. Rather than just naively using a tagged union (which is how other some rust enums are implemented). This optimization actually works for any enum with the same shape as Option.

  • @karimjedda
    @karimjedda Рік тому +5

    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.

  • @Gennys
    @Gennys 6 місяців тому +5

    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.

    • @dario.lencina
      @dario.lencina  6 місяців тому +1

      Thank you for bringing this to my attention. I appreciate your careful listening and your point is well-taken. I intended to compare the libraries available in Rust with those in Java, which indeed are distinct and should not have been referred to interchangeably. It’s important to be precise when discussing the characteristics and capabilities of different programming languages, and I’ll make sure to be more specific in future discussions. Thanks again for your feedback!

  • @vitalyl1327
    @vitalyl1327 Місяць тому +3

    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.

  • @morgomi
    @morgomi Рік тому +3

    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.

    • @dario.lencina
      @dario.lencina  Рік тому +1

      Welcome to the party brother !! 🥳🎉

  • @olexandrkostiuk9653
    @olexandrkostiuk9653 Рік тому +4

    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!

  • @kamertonaudiophileplayer847
    @kamertonaudiophileplayer847 Місяць тому +1

    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.

  • @computerfan1079
    @computerfan1079 Рік тому +3

    I laughed out loud multiple times. I see your channel growing a lot

    • @dario.lencina
      @dario.lencina  Рік тому

      even as I was editing the video the part with the for loop "benchmark" had me laughing!!

  • @andrebrait
    @andrebrait Місяць тому +2

    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.

    • @dario.lencina
      @dario.lencina  Місяць тому

      Plosives are awesome mate PPPPPPPPP

    • @dario.lencina
      @dario.lencina  Місяць тому

      I did figure out how to filter those out in newer videos

  • @kobibr9362
    @kobibr9362 8 місяців тому +2

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

    • @dario.lencina
      @dario.lencina  8 місяців тому

      You are saying that we could use Boxes to create dangling pointers? Wouldn’t the borrow checker prevent it?

    • @henrycgs
      @henrycgs Місяць тому +1

      nope, it's impossible to create dangling pointers in safe rust. if you put something in a box, the box owns the value and you can't take it out without dropping the box

  • @kuqmua755
    @kuqmua755 Рік тому +2

    great video! about dead locks - is there any abstraction around rust Arc 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

    • @dario.lencina
      @dario.lencina  Рік тому +2

      Hey @kuqmua! I found RwLock so that you can only get one write lock at the time which helps! doc.rust-lang.org/std/sync/struct.RwLock.html
      This type of lock allows a number of readers or at most one writer at any point in time. The write portion of this lock typically allows modification of the underlying data (exclusive access) and the read portion of this lock typically allows for read-only access (shared access).

  • @dario.lencina
    @dario.lencina  Рік тому +1

    Here's my cheatsheet so that you can follow along! security-union.github.io/rust-vs-java/

  • @michaelutech4786
    @michaelutech4786 3 місяці тому +2

    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)

    • @dario.lencina
      @dario.lencina  3 місяці тому +1

      Ah, the Java conundrum-it's like that reliable old car that never quite gives you the thrill of a shiny new sports car, but gets you from point A to point B without too much fuss. Yes, it’s noisy, requires you to fill out a bit too many forms (boilerplate), and occasionally leaks oil (memory leaks), but hey, at least it’s dependable, right?
      But let’s talk about these new kids on the block-Rust, Go, Zig, Swift. It’s like comparing that old reliable car to the latest models with all the fancy gadgets. Rust is like the safety-first SUV with the borrow checker ensuring you don't crash into memory bugs, though sometimes it feels like it's overprotective and insists you wear a helmet while sitting in your living room.
      Zig? Now that’s the minimalist sports car. It’s sleek, unopinionated, and fast, with just enough safety features to keep you from wrapping it around a tree. It's the kind of car that lets you feel every curve of the road, giving you full control while whispering sweet nothings about manual memory management and low-level control.
      Swift, on the other hand, is the hybrid-efficient, a bit of a control freak with its reference counting, but still pretty smooth and eco-friendly. It’s not going to win any races against Zig’s raw speed, but it’s not about that life anyway.
      And Go? It’s the utilitarian truck-practical, straightforward, gets the job done without too much flair. But you didn’t mention it, probably because Zig’s minimalist appeal has stolen the spotlight.
      In the end, it all boils down to what you value most in your coding joyride. Rust’s safety-first approach, Zig’s minimalist speed, Swift’s balanced efficiency, or Go’s straightforward reliability. Each has its quirks, just like our old friend Java, but the thrill of the ride is in finding the one that matches your style. Enjoy the journey!

    • @michaelutech4786
      @michaelutech4786 3 місяці тому

      @@dario.lencina "Rust [..] SUV" - To me Rust feels like the UK model of a french car with hydrolic suspension (like these futuristic Citroën guys in the 70's). It's undeniably fantastic, but it's like you first have to forget what a car is before you can love it.
      Zig to me feels like opening a new gamer PC without colors after having tried to repair a Macbook. One philips screwdriver is all you need. Not sleek, not too fancy, not elegant, but easy to understand and powerful.
      But I agree, the fun is not in the language, it's in the act of coding.
      Really like your videos, you're doing a great job here!

    • @gammalgris2497
      @gammalgris2497 Місяць тому +1

      Dunno. If you have issues with boilerplate code then blame the libraries/ frameworks and your coding guidelines you adhere to. There are various ways to abstract boilerplate away. I myself ditched some which I used over the years with java.
      Zig sounds interesting. I would rather avoid rust because of the ownership and borrowing concepts.

  • @vitaliikocherga3954
    @vitaliikocherga3954 20 днів тому +2

    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

    • @dario.lencina
      @dario.lencina  20 днів тому

      Thanks for the clarification 👍👍

  • @kuqmua755
    @kuqmua755 Рік тому +1

    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.

    • @dario.lencina
      @dario.lencina  Рік тому +1

      You got it chief!! I just added it to the queue, I'll include timeouts and some other common pitfalls!!

    • @coffee-is-power
      @coffee-is-power Місяць тому

      The way i do timeouts is using select and i put a sleep alongside the other future inside it, select basically short circuits when a future finishes and aborts the other futures, so if you put a tokio::sleep and it finishes first it means that it timed out

  • @vencedor1774
    @vencedor1774 22 дні тому +1

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

  • @masterchief1520
    @masterchief1520 Місяць тому +1

    For what go provides and the effort to use those features. It beats everything else. How many of us write systems software. If you're working for enterprise, java is the only way. Sure.

  • @krellin
    @krellin 8 місяців тому +1

    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.

    • @dario.lencina
      @dario.lencina  8 місяців тому

      That’s right my friend! Both are awesome tools!

    • @dario.lencina
      @dario.lencina  8 місяців тому

      Being analytical as opposed to fanboys is always better

  • @coffee-is-power
    @coffee-is-power Рік тому +1

    crossbeam is not necessary, it's already inside the std library on std::sync::mspc

    • @dario.lencina
      @dario.lencina  Рік тому

      Nice!! Good to know 🤗🤗🤗

    • @henrycgs
      @henrycgs Місяць тому +1

      wrong, crossbeam is mpmc (multiple producers/multiple consumers) whereas the one in std is mpsc (multiple producers/single consumer).

  • @RhinoInfo
    @RhinoInfo Рік тому +4

    hi . a great video man . actually i would love to switch to rust . but i don't wanna dive wrong to the lang . could you please make a roadmap vid . so you share u'r experience with us . thanks for the vid again

    • @dario.lencina
      @dario.lencina  Рік тому +4

      Hey @Rhino, I'll definitely do this, the most common pitfall (imo) is to try to learn smart pointers and lifetimes in too much detail as opposed to copying objects around just to get started. In the mean time I recommend that you read doc.rust-lang.org/book/ it should take less than 4 hours and it provides a great "getting started" guide.
      Thank you so much for your feedback!

    • @v01d_r34l1ty
      @v01d_r34l1ty Рік тому +2

      @@dario.lencina This is definitely an underappreciated comment. I've tried time and time again for about 3 years now to learn Rust. Kept giving up on it very quickly because ultimately every book gets right into the nitty gritty. On New Years, I was alone with my little bro, so I decided to try Axum again and successfully built a static web server with various API handlers! I learned more doing that than anything else so far.

    • @dario.lencina
      @dario.lencina  Рік тому +1

      @@v01d_r34l1ty neat!! 🤗👏 good for you, is it a public GitHub project that you can share?

    • @v01d_r34l1ty
      @v01d_r34l1ty Рік тому +1

      ​@@dario.lencina Not yet! It will be once I get JSON web tokens and authentication implemented. I'm trying to make a very basic chat application (demo video on my channel).

    • @dario.lencina
      @dario.lencina  Рік тому +1

      @@v01d_r34l1ty sweet!!

  • @loophole3763
    @loophole3763 8 місяців тому +1

    so , first c, then java then rust,
    then life is set if the brain is good?

    • @dario.lencina
      @dario.lencina  8 місяців тому

      🤗🤗yes, it is the only way to illuminate and achieve nirvana

    • @henrycgs
      @henrycgs Місяць тому

      @@dario.lencina and after you achieve nirvana, you can use haskell.

    • @vencedor1774
      @vencedor1774 22 дні тому

      Before C it comes machine code and assembly, in that order.

  • @rhysmuir
    @rhysmuir 2 місяці тому +1

    Java /JVM is the only language I have come across that requires end user to modify the available memory.

    • @dario.lencina
      @dario.lencina  2 місяці тому

      You mean adding the jvm flags to set limits like Xms?

    • @rhysmuir
      @rhysmuir 2 місяці тому +1

      @@dario.lencina yep. Maybe I’m just lucky (or unlucky), but Java based programs are the only ones I’ve come across where the end user might need to modify such settings - terrible experience for the layperson

    • @dario.lencina
      @dario.lencina  2 місяці тому

      @rhysmuir hahaha agreed

    • @ArturdeSousaRocha
      @ArturdeSousaRocha Місяць тому +1

      ​@@rhysmuirGo programs may benefit in GC performance if you give them a memory limit that causes them to start collecting earlier. Perhaps it's a corner case but it is mentioned somewhere on their website.

  • @dr.rainereschrich1549
    @dr.rainereschrich1549 7 місяців тому +1

    You should also compare rust to Java + GraalVM Native image!

    • @dario.lencina
      @dario.lencina  7 місяців тому +1

      Wow 👀👀👀I need to look into that!! Thanks for sharing

  • @JuddMan03
    @JuddMan03 Місяць тому +3

    Dudes trying to eat the mic

  • @Razpirato
    @Razpirato Рік тому +3

    Nice video but you need better mic etiquette. Constantly getting “plosives”.

    • @dario.lencina
      @dario.lencina  Рік тому

      Point taken, I’ll add a pop filter to deal with this, thanks for watching

    • @dariolencina3709
      @dariolencina3709 Рік тому

      Is this better ua-cam.com/video/LWwOSZJwEJI/v-deo.html&ab_channel=SecurityUnion (added a pop filter)?

  • @jadabloomflannagan8818
    @jadabloomflannagan8818 3 дні тому +1

    Allen Ronald Thompson Eric Smith Cynthia

  • @codeman99-dev
    @codeman99-dev 9 місяців тому +1

    My guy. Turn off the dynamic zoom. Very distracting.

    • @dario.lencina
      @dario.lencina  9 місяців тому

      Thanks mate, I’ll consider it. Believe or not some people actually like it ?

    • @codeman99-dev
      @codeman99-dev 9 місяців тому +1

      @@dario.lencina interesting.
      I guess someone must. I can't watch Networkchuck because of his dual camera setup. He has quite the following though.

    • @dario.lencina
      @dario.lencina  9 місяців тому

      @99codemister I’ll make sure to make them less distracting

  • @masterchief1520
    @masterchief1520 Місяць тому +1

    Can you not keep looking towards your second monitor? 😂. Directly look at us when you're talking 👀

    • @dario.lencina
      @dario.lencina  Місяць тому

      Got it ✌️feedback taken

    • @ArturdeSousaRocha
      @ArturdeSousaRocha Місяць тому

      I've been in so many MS Teams videoconferences that it looks normal to me. 😆

  • @Gabriel-zr4kz
    @Gabriel-zr4kz 5 місяців тому +1

    Java is the best language in my Opinion (at least for learning), everything is literal and verbose. I hate programming languages like Python and Ruby, they seem to complicated for me and I don't know why (perhaps abstraction).
    My first language was Js/Ts but once you deal with maps, reduces it gets kinda weird. I'm a SDE nowadays and I only learned to program after I learned java. In my opinion the annoying boilerplate makes sense in my head.

    • @dario.lencina
      @dario.lencina  5 місяців тому +1

      Java does have its merits with explicit verbosity, which some find reassuring like a well-detailed map.
      Yet, isn't it thrilling to sometimes navigate the programming jungles with just a compass?
      Python and Ruby are like that, offering a concise syntax - it’s less about the roads taken and more about the adventure.
      Admittedly, Java's boilerplate can feel like a safety harness, but maybe after scaling the cliffs with JavaScript's flexibility, that harness just feels a bit too snug?
      As an SDE, you've mastered different terrains, so why not enjoy the view from all perspectives?

    • @Gabriel-zr4kz
      @Gabriel-zr4kz 5 місяців тому +1

      ​@@dario.lencina What a comment! Yes .map in JS are pretty useful, but they only made sense when I made them in Java HAHA. like every other data structure One example is when I do Hackerrank/LeetCode challenges I do them in Java because it's easy for me and I'm a fullstack with strong frontend side and don't know why.
      I do well with C and C++ codes seems more well, but easier than Ruby/Python.

    • @vitalyl1327
      @vitalyl1327 Місяць тому +1

      Java is better but still nowhere near the right kind of verbose. You'd appreciate Oberon far more. Or even Ada.

    • @dario.lencina
      @dario.lencina  Місяць тому

      @vitalyl1327 did you even try rust?

    • @vitalyl1327
      @vitalyl1327 Місяць тому +1

      @@dario.lencina we're talking about a very specific language property here. Rust is far out of this kind of domain. Java is somewhat (poorly) applicable.

  • @jonnyso1
    @jonnyso1 Місяць тому +2

    Ironically, I think that someone who likes Rust is more likely to prefer Java over the javascripts and pythons.

  • @doylemcguire1588
    @doylemcguire1588 Рік тому +1

    Promo sm 😩

  • @ahuramazda9202
    @ahuramazda9202 Рік тому +2

    A nonsensical and trivial comparison, and of course wrong.

    • @dario.lencina
      @dario.lencina  Рік тому +1

      Lol, thanks for your feedback son, time to go eat your Java Beans 🫘

  • @atheistbushman
    @atheistbushman Місяць тому +1

    I find Kotlin much more productive and elegant than Java

    • @dario.lencina
      @dario.lencina  Місяць тому +2

      Aw mate that is a fact, I think I should do Kotlin vs Rust it is a much fair fight

    • @atheistbushman
      @atheistbushman Місяць тому

      @@dario.lencinaThat would be great! There is active development of "kotlin native" thus no need for the JVM
      I read that Ktor (a HTTP server) can be compiled to navive binaries - but I have not tried it yet.

    • @vencedor1774
      @vencedor1774 22 дні тому +1

      @dario.lencina kotlin's just Java but typed differently

    • @dario.lencina
      @dario.lencina  22 дні тому

      @vencedor1774 hey mate, I think that it is another jvm language and they do share similarities, but my understanding is that it does provide very unique features!

    • @atheistbushman
      @atheistbushman 21 день тому

      @@vencedor1774 Null safety does not exist in Java

  • @michaelutech4786
    @michaelutech4786 3 місяці тому

    "Arc" is exactly why I strongly dislike Rust. I know how semaphores work, I know how automatic reference counting works. This looks like a type declaration, but I have no idea what "Arc" actually is. I know some 20 programming languages and cannot even guess what this is.
    I can see how you can get to love Rust just by using it long enough. Just like with Objective-C or perl. But is that really necessary? Why are these guys making it so hard? Objective-C did it because it comes from C and Smalltalk, no wonder the result is strange. Perl comes from the shell, awk and regexp - ok, get it. What is Rust's excuse?

    • @dario.lencina
      @dario.lencina  3 місяці тому +1

      Rust's excuse? Well, it's kind of like that eccentric genius at a party who insists on explaining quantum mechanics after a few too many drinks. It's trying to keep everyone safe and sound while wielding the power of concurrency without shooting itself in the foot. "Arc" is Rust's way of saying, "I can handle sharing this data safely across threads, trust me." And "Mutex"? Well, that's its way of locking the cookie jar so no one gets their hand stuck.
      In essence, Rust is trying to give you the best of both worlds: the performance of low-level programming with the safety of high-level abstractions. Sure, it’s a bit like learning to juggle flaming swords at first, but once you get the hang of it, you'll be amazed at how much safer and faster your programs can be. Plus, it’s a great conversation starter at parties-if you're into that sort of thing.

    • @michaelutech4786
      @michaelutech4786 3 місяці тому +2

      @@dario.lencina The Mojo guys are copying a lot from Rust and seem to be getting a far better result simply by choosing better defaults and taking better care for naming and keeping the syntax clean. I don't think that Rust is conceptually hard to understand, not compared to what such complexities buy you in terms of security. What bothers me is that it's often unnecessarily cryptic and quirky.
      I'm not a Rust expert, so my judgement may be flawed. But in this concurrency example, there seem to be three ways of handling it: (1) don't and expose the OS interface (2) create an intuitive abstraction (f.e. GCD, MQ, coroutines, ...) or (3) invent some quirky wrappers and name everything cryptically while mixing (1) and (2), which seems to be the Rust way.
      But that also exposes a problem with memory management. Once you impose a management paradigm, you just have to also manage everything that depends on memory management. That in turn is excessively difficult, because something like concurrency has many different solutions with very different properties that you would have to cover in a way that either hides the differences or makes it really complicated to use.
      But again, I might be overly critical and just would need some more time spent with Rust to appreciate it. I just cannot bring myself to like it - yet.

    • @Andrew-jh2bn
      @Andrew-jh2bn Місяць тому +1

      I mean, this is syntax for a "generic", almost identical to what is used in Java and c++. Granted, rust does tend to use genetics more than Java does.

    • @dario.lencina
      @dario.lencina  Місяць тому +1

      Yes, people do use channels to do message passing as opposed to arc mutex as much as possible

    • @michaelutech4786
      @michaelutech4786 Місяць тому

      @@Andrew-jh2bn "this is syntax for generic" - I don't mind the syntax (in this example). In this example, the problem is that I look at "Arc" and I don't understand why I should ever write this code. A mutex is something the OS or a runtime uses to obtain mutually exclusive access to something. I'm not choosing what type a mutex is, it's the OS, a runtime, the language or whatever implements mutual access. Reference counting is a garbage collection method, one of the faster versions. I didn't know Rust is doing GC. But even if so, if Rust is doing GC, why do I have to provide a mutex? Why do I need an instance of a RC? It's either manual or automatic. If it's manual, I have to do it, if it's automatic then the tool does it. This seems to be both.
      I'm certain there are good reasons for all of that and there will be good answers to my questions that will make my questions look stupid. All I had to do is to learn Rust in depth and get used to it and everything would be clear. Just like in C++, Perl and Objective-C or even in Assembler. I went through that process many times.
      Right now I'm learning Zig, and there too you have to learn your letters. But until you're getting there, you can just read code and usually when you look at Zig code, you just understand it. You don't need to come up with "Arc", at worst you need an "Allocator". I look at this word and I immediately understand what it is. I also immediately understand the idea behind passing an allocator to a function. That makes sense, give the code a tool to allocate memory instead of letting the function choose how to malloc something.
      Borrowing does not work in a multi threaded context. I understand that. So in Rust you have to drag out your data from the borrowing chain to concurrently use it. Ok fine. But how is this "Arc" object, sorry we don't do object, the thingy, how is it helping me there? I just remove the automatism (borrowing), so I'm using a reference counting GC now? Ok, why not. But how? This is a whole lot of questions that a piece of code does not have any answers to.
      In Java, you enclose something in a synchronized block on any object, ok. In JS, you only have one thread, ok. In Obj-C you have ARC and dispatch and Obj-C takes care of it. In C you do it yourself. In all of these environments, concurrency is hard to do (right) but easy to understand. In Rust it's still hard to do after it was hard to understand.
      (Don't want to bicker here, just trying to make my point clear)

  • @ievgenmajor3301
    @ievgenmajor3301 Місяць тому +2

    Not only OpenJdk, but also Temurum, Coreto and others

    • @dario.lencina
      @dario.lencina  Місяць тому

      I do over Corretto which is the Amazon jdk, pretty amazing stuff!!

  • @ievgenmajor3301
    @ievgenmajor3301 Місяць тому +1

    FlameGraph shows call stack, not object references.

    • @dario.lencina
      @dario.lencina  Місяць тому

      I think you can do both allocations and call stacks mate

  • @igorshingelevich7627
    @igorshingelevich7627 3 місяці тому +1

    Good one!