Rust vs Java: A Staff Engineer's perspective

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

КОМЕНТАРІ • 209

  • @hamdysaadpersonal
    @hamdysaadpersonal 2 роки тому +13

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

    • @dario.lencina
      @dario.lencina  2 роки тому +1

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

  • @RealViPdude
    @RealViPdude 11 місяців тому +72

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

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

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

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

      Exactly and in the worst case you have to type it exactly once per project. Wow , maximum verbosity dude.

    • @curio78
      @curio78 2 місяці тому

      Java has only one drawback, ONE.. that is value object and universal generics for primitives that has taken way too long to be implemented. That is it. But is a huge one. resulting in Java missing the whole AI boom.

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

      @@curio78 No it has another drawback and that's its basically impossible to use without a fully fledged java IDE

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

      @@ghdshds1899 You are using reverse logic. The correctness of the language allows for IDEs to be built to use it. Its correctness means IDE's can actually help with autocomplete, documentation, and hints.
      It is not Java's disadvantage, it is its advantage. If one used an IDE you will realize how bad other languages are. They feel incomplete.

  • @professornumbskull5555
    @professornumbskull5555 2 роки тому +21

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

    • @dario.lencina
      @dario.lencina  2 роки тому +8

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

    • @professornumbskull5555
      @professornumbskull5555 2 роки тому +22

      ​@@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  2 роки тому +1

      Makes sense, 👏🤗 thank you so much

    • @coffee-is-power
      @coffee-is-power 4 місяці тому +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 4 місяці тому +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.

  • @Gennys
    @Gennys 9 місяців тому +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  9 місяців тому +2

      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!

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

    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  Рік тому +6

      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!

    • @kulikgabor7624
      @kulikgabor7624 2 місяці тому

      I think it worth to mention that when you compile you usually run your tests too and if you sum that up rust will be almost there if not better. I had a test which starts redis in a docker, fill it, verify it and the whole test executes under 1 second. Actually my experience is it's much faster to work with rust because of that.

  • @orsivan5731
    @orsivan5731 3 місяці тому +4

    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  3 місяці тому

      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

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

      ​@@dario.lencina sorry, wrong timestamp. I was talking about the dangling pointer example.
      In Java you created a reference of an ArrayList, then created another reference for said list, and you nullfied the first reference and showed ArrayList still exists (as the refcount is not 0).
      Around 8:30 you wanted to show the same thing in Rust, but you just created one reference and the dropped it. There was no second reference.

  • @vitaliikocherga3954
    @vitaliikocherga3954 4 місяці тому +3

    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  4 місяці тому

      Thanks for the clarification 👍👍

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

    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 Рік тому +6

    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!

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

    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.

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

    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.

  • @kamertonaudiophileplayer847
    @kamertonaudiophileplayer847 5 місяців тому +2

    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.

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

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

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

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

    • @henrycgs
      @henrycgs 4 місяці тому +2

      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 роки тому +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 роки тому +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).

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

    Do comparison of web servers between the two esp java, and focus on light webservers without heavy annotation use, like js express. Because i find spring too opinionated

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

      Sounds like a great idea, which other Java servers do you have in mind?

  • @kuqmua755
    @kuqmua755 2 роки тому +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  2 роки тому +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 4 місяці тому

      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

  • @andrebrait
    @andrebrait 5 місяців тому +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  5 місяців тому

      Plosives are awesome mate PPPPPPPPP

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

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

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

    Love the Java reactive with spring web flux.

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

    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 4 місяці тому +2

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

  • @abidapollo
    @abidapollo 11 місяців тому +2

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

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

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

    • @henrycgs
      @henrycgs 4 місяці тому

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

    • @vencedor1774
      @vencedor1774 4 місяці тому +1

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

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

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

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

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

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

      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 4 місяці тому +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

  • @masterchief1520
    @masterchief1520 5 місяців тому +3

    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.

  • @dr.rainereschrich1549
    @dr.rainereschrich1549 11 місяців тому +2

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

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

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

  • @vencedor1774
    @vencedor1774 4 місяці тому +2

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

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

    Although Python does have some memory safety issues, one cannot claim that Python “wouldn’t be memory safe”. For normal usage, there are no memory issues for Python.

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

      Hey DataPastor:
      Thanks for your comment!
      While Python is generally considered a memory-safe language, certain vulnerabilities have been identified, particularly when interfacing with lower-level code or through specific modules. Notable examples include:
      1. CVE-2021-3177: A buffer overflow in Python versions up to 3.9.1, located in the PyCArg_repr function within the _ctypes module. This vulnerability could lead to remote code execution in applications that accept untrusted floating-point numbers, such as passing 1e300 to c_double.from_param. 
      2. CVE-2021-23336: An issue in Python’s http library where the Request class did not properly handle certain characters in the request method, potentially allowing for header injection attacks.
      3. CVE-2020-27619: A vulnerability in the pillow library (a popular imaging library in Python) where a buffer overflow could occur when processing certain PCX files, leading to potential arbitrary code execution.
      These examples highlight that while Python’s high-level nature provides a degree of memory safety, vulnerabilities can still arise, especially when interacting with lower-level components or external libraries. It’s crucial to keep Python environments and dependencies updated to mitigate such risks.

  • @RhinoInfo
    @RhinoInfo 2 роки тому +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  2 роки тому +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 роки тому +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  2 роки тому +1

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

    • @v01d_r34l1ty
      @v01d_r34l1ty 2 роки тому +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  2 роки тому +1

      @@v01d_r34l1ty sweet!!

  • @michaelutech4786
    @michaelutech4786 7 місяців тому +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  6 місяців тому +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 6 місяців тому

      @@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 4 місяці тому +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.

  • @krellin
    @krellin 11 місяців тому +2

    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  11 місяців тому

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

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

      Being analytical as opposed to fanboys is always better

  • @JuddMan03
    @JuddMan03 4 місяці тому +5

    Dudes trying to eat the mic

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

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

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

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

    • @rhysmuir
      @rhysmuir 5 місяців тому +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  5 місяців тому

      @rhysmuir hahaha agreed

    • @ArturdeSousaRocha
      @ArturdeSousaRocha 4 місяці тому +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.

  • @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)?

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

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

  • @codeman99-dev
    @codeman99-dev Рік тому +1

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

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

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

    • @codeman99-dev
      @codeman99-dev Рік тому +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  Рік тому

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

  • @dario.lencina
    @dario.lencina  2 роки тому +1

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

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

    "In-depth comparison"
    Proceeds to compare the behaviour of a java arraylist which is gc-d and locked with a Vec without choosing a smart pointer, thereby defaulting to owned semantics

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

      Yeah what a loser right?

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

      @@dario.lencina I shouldn't be so negative. By UA-cam standards this is really an in-depth comparison. I guess I'm just frustrated with how persistently surface-level Rust discussion is on this platform.

  • @lufenmartofilia5804
    @lufenmartofilia5804 16 днів тому +1

    Java 21 is a bliss and elegant to be fair

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

    Java owned by Oracle. Originally Java invented by Sun Microsystems but the company was acquired by Oracle. Comparison Java with Rust can't be apple to apple. Java is suitable for application development but Rust is for the system development

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

      How about people that make applications with rust 💥💥💥🤯🤯

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

      @ You make an application using Rust. But it’s not the best fit since the best use cases for using Rust are: system(OS kernel, database, etc) and tools(CLI and compiler). Although some articles say Rust can be used for all use cases, we should recheck if is it the proper way to do that.

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

      @@petersburgh78 well, I've built complete web apps in rust and so far so good my friend 😄

  • @Gabriel-zr4kz
    @Gabriel-zr4kz 8 місяців тому +2

    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  8 місяців тому +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 8 місяців тому +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 5 місяців тому +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  5 місяців тому

      @vitalyl1327 did you even try rust?

    • @vitalyl1327
      @vitalyl1327 5 місяців тому +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.

  • @curio78
    @curio78 2 місяці тому

    rust cannot replace c++. A functional language is not good at building large complex monoliths. That is the reason why OOP came to be. Which is why Java is so popular in building large systems.

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

      So you are saying that rust is functional? I think it has some functional methods and traits but it is not even close to Haskell or those pure functional languages

    • @curio78
      @curio78 2 місяці тому

      @@dario.lencina Every language that does not have identity objects where functions can reside is functional. And has the same limitations. What we needed was a better C++ like D-Lang to cover all use cases.
      As far as languages go C# is the most complete languages of them all. Java needs project Valhalla to be implemented to be complete (once that is done There is not a single reason to switch in case of application programming,and should finally replace python in machine learning).
      I always wondered. by D-Lang never caught on. I seems like a logical refinement of C++. I guess there is not a big need for large applications in systems programming. Most of them are small modules cobbled together into a large ecosystem.

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

    Why do you think Rust is faster? Java eventually compiles to native too. the difference really is between having a garbage collector or not.

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

      Hey Curio, you are absolutely right the GC is a big differentiator, also the fact that Java does not run on bare metal, it runs in a VM, an efficient VM but a Vm nevertheless

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

      @@dario.lencina not quite .. java VM is simply a compiler to native code at runtime. the VM its self actually makes run time optimizations to native code generated at run time .. something pre compiled languages can never do. Making at times java run faster than any default optimize C or rust. The difference is only with the garbage collectors. which is on one have an advantage for server workloads while on the other a disadvantage in synthetic benchmarks.
      To expand on this.. java.. gc approach make per execution faster. If implemented correctly. as it does not need to release memory in that workload. But in syntethic bench marks when pushed 100% it suffers a bit. And what I mean by implemented correctly is knowing how java objects are created and its identity concept.
      All this should be moot once value objects should show up in java 24. removing identity constraint on objects. After that.. no pre compile language can hope to match java in performance. For me the current work around is primitive, and was hoping for the universal generics to solve the OOP clean design approach for primitives(well may not be necessary with value objects). Infact every library out there is waiting and waiting for that change to be finished. 8 years and still waiting. You will see most libraries rewritten to take advantage of the performance boost from it.

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

      I am sure that Java will just keep better and better, personally I love both programming languages

    • @curio78
      @curio78 2 місяці тому

      @@dario.lencina is it me imagining or is youtube deleting most of my comments. feels like I am censored.

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

      @curio78 I see your comments

  • @masterchief1520
    @masterchief1520 5 місяців тому +1

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

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

      Got it ✌️feedback taken

    • @ArturdeSousaRocha
      @ArturdeSousaRocha 4 місяці тому

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

  • @jonnyso1
    @jonnyso1 4 місяці тому +3

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

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

    The problem with Java is the library ecosystem and the programmer community. Spring Boot has turned Java into an annotation hellscape, where all objects are effectively static singletons that you can hack around a bit, and the majority of the Java cult are completely incapable of doing anything but cargo cult awful patterns they find in tutorials. Java the language maybe improving but there needs to be a complete repudiation of the current awful dominant stack, and all the competitors that feel the need to ape it. I do like Rust, but I think the majority of programmers will howl in anguish at having to understand the lifetimes of memory and the type system means people will get lost. I honestly think we will all end up being forced into Go, with its Luddite language design and dreadful error handling, just because the Java community is unwilling to instantiate objects and admit that magic frameworks achieve nothing but confusion.

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

      In your entire reply, there are a few sentences where I could replace "java" with "rust" and still have a very valid argument.

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

      @@cosmowanda6460 Tokio trauma?

    • @michimarz
      @michimarz 2 місяці тому

      You don't need to use Spring. Just rely on Java standards.

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

      @@michimarz Actually try that with any plausibly assembled group of Java programmers and you will get howls of anguish. It would be easier to force a new language on them than make them give up the ability to mindlessly paste spring shite from Baeldung into your codebase.

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

      @@rjScubaSki That's an interesting issue. I'm not very familiar with management habits at modern software companies, but isn't there any civilised way to force or encourage your own employees to obey the rules you set for the projects your company carries out?

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

    Promo sm 😩

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

    Very incompetent developer. Why are you using ConcurrentLinkedQueue if you should use some favour of BlockingQueue? In java there is no dangling pointer at all, you did typical thing called even in cpp world - aliasing. Gents, don’t watch videos of super duper principals, who learned languages using youtube tutorials themselves.

  • @michaelutech4786
    @michaelutech4786 7 місяців тому

    "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  6 місяців тому +2

      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 6 місяців тому +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 5 місяців тому +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  5 місяців тому +1

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

    • @michaelutech4786
      @michaelutech4786 5 місяців тому

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

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

    I find Kotlin much more productive and elegant than Java

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

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

    • @atheistbushman
      @atheistbushman 4 місяці тому

      @@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 4 місяці тому +1

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

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

      @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 4 місяці тому

      @@vencedor1774 Null safety does not exist in Java

  • @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 🫘

  • @ievgenmajor3301
    @ievgenmajor3301 5 місяців тому +1

    FlameGraph shows call stack, not object references.

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

      I think you can do both allocations and call stacks mate

  • @ievgenmajor3301
    @ievgenmajor3301 5 місяців тому +2

    Not only OpenJdk, but also Temurum, Coreto and others

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

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

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

    Good one!