C++ or Java for commercial software?

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 ก.ค. 2024
  • In my 30 years at Microsoft, Amazon, and Google, priorities for code changed dramatically. Speed of development and ease of maintenance became far more important than resource efficiency.
    This video talks about the pro's and con's of garbage collected [GC] (e.g. Java) and non-garbage collected (e.g. C++) languages, and explains why these days most commercial software is best written in a garbage collected language like Java or C#!
    TABLE OF CONTENTS
    00:00 Introduction
    00:55 Explicit resource control in practice
    02:21 Explicit resource code snippet
    03:29 Garbage collected code snippet
    04:02 What garbage collection does
    04:52 Benefits of coding in a GC language
    05:21 The downsides of GC
    07:20 Why GC downside isn't in explicit code
    08:43 Changes in the world making GC less problematic
    09:55 Summary
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 22

  • @teacherinthailan6441
    @teacherinthailan6441 2 ปีที่แล้ว +1

    Thank you so much for sharing your wisdom. It's very much appreciated.

    • @TheDeliberateEngineer
      @TheDeliberateEngineer  2 ปีที่แล้ว

      Thank you for letting me know it's useful, and for watching!

  • @scoberry
    @scoberry ปีที่แล้ว +1

    Hey, John. Sorry, random bug spot: at 3:14 or so, there's an extra return on line 15 that means the function can't ever execute successfully. (It's a good example of how the volume of error-handling code can allow bugs to creep in. ;-) )
    I hope everything's going okay with you.

    • @TheDeliberateEngineer
      @TheDeliberateEngineer  ปีที่แล้ว +1

      Nooooooo well I am too lazy to go back and fix it, but thanks for finding it! Life is good, hope the same is true for you!

    • @scoberry
      @scoberry ปีที่แล้ว

      @@TheDeliberateEngineer Good. Yeah, things are going well. The commute's long, though. I'll have to do something about that eventually -- probably give it a few years after the house is paid off (that part's soon), then think about where we want to live.

  • @mattwilliams6500
    @mattwilliams6500 2 ปีที่แล้ว +3

    I will say as a C++ embedded dev that modern post-2011 versions of C++ completely stopped the need for new and delete for that reason you listed, even in a resource constrained environment the modern features of smart pointers and Rule of 5/RAII seem to solve that. Really there are issues with modern C++ but a lot of that has to do with backwards compatibility or confusing newer features. The biggest weakness is the build system/package management. Java is fast enough in most cases and was better for backend stuff especially compared to pre-11 C++, but now I find Java does not have the web advantage. It's easier to do most web stuff in JavaScript and mix that with whatever your team needs/is comfortable with in my experience. 👍

    • @TheDeliberateEngineer
      @TheDeliberateEngineer  2 ปีที่แล้ว +2

      C++ 11 was the last C++ I used, and it definitely made a lot of the memory management easier for most cases, as you say! I haven't used Javascript yet, it's always been on the "I should do that sometime" but typically I'm a layer deeper in the stack. But, someday!

  • @mohabkhaled1391
    @mohabkhaled1391 2 ปีที่แล้ว +1

    Thank you john, this is an important one and as usual the long-hands on experience reflected on this controversial subject in a way that begins with the real world while noticing how things move in history (i think mentioning moving from a position where resources were limited to the current state where there are resource-rich environments is an important insight), this is the first time i know you also reached to work with OSs, if anything to suggest here is shedding light on the terms appeared in the video (perhaps in an exclusive way without going in-depth - memory management, resource allocation, garbage collectors ..etc.), this is because there are people capitalize on deliberately obscuring these things, i get confused whenever there is a discussion about why we should switch from X-lang because of memory management, or how X compiles, or type safety (and i know some of these topics are crucial, and some of - like what we saw on this episode- have a specific context), at least what you think make important research topics for building commercial-grade software (from a programming language/operating system point of view) .
    As usual thank you john for the great insights, and have a nice day !

    • @TheDeliberateEngineer
      @TheDeliberateEngineer  2 ปีที่แล้ว +1

      Thanks for the comments and suggestions! I never know quite where to draw the line with terminology. I used to explain everything, but then half of the time anyone spent listening to me was things they already knew. Is there any particular term or sub-topic that you think is worth spelling out a bit (say in a pinned comment) or having a separate video on?

    • @mohabkhaled1391
      @mohabkhaled1391 2 ปีที่แล้ว

      @@TheDeliberateEngineer thanks for the response john!, it' the other way around, the thing is that we (beginners moving to mid) got surprised with new topics that is a step deeper than the usual development (say memory management or multi threading), it's important to list these topics so we can dive deeper into them, the case that i want to avoid is being surprised or confused with a new term that i have zero knowledge about, knowing what are these lower-level topics that you consider important for programmers would help even if you don't specifically explain them in depth, the case that i want to achieve is when i hear them at least i would remember that "Oh! this something john mentioned that i probably had to dig deeper" instead of being totally blanked.

  • @Antox68
    @Antox68 11 หลายเดือนก่อน

    From my experience C++ isn't much harder to write than java if you do it right. In most cases you don't need to use pointers. You can just instantiate objects on the stack and use move() and references when needed. In case you do need to use pointers, you can always use smart pointers.

  • @ZachStein
    @ZachStein 2 ปีที่แล้ว +2

    I think the comparison is fair, I think I typically reach for garbage-collected languages first because of the productivity. I think you hit the nail on the head about productivity, testability, and how modern hardware is less resource-constrained. I think like most things in our world the answer is "It depends" which isn't really the most satisfying thing to most people these days because that implies there's nuance and people want "Yes or No". I tend to reach for something else when latency is critical and resources are more constrained. Although these days with where my career is currently, it tends to be exclusively garbage collected.
    One other interesting thing that could be covered is some languages, I know specifically Java for example allow you to call out to external native libraries (Foreign functions) written in other languages. I've written Java applications before that use JNI for near-hardware type things (One example that comes to mind is an application I worked on that used JOGL for rendering), so you can get some of the best of both worlds.

    • @mohabkhaled1391
      @mohabkhaled1391 2 ปีที่แล้ว

      thank you Zach for the insight, mentioning working with computer vision, there is a software (Unity Unreal Engine) that is written in C# which is not the fastest language so to speak, now this specific software is really a good one and renders very detailed views without any noticeable delays or glitches (in fact without anything at all, it's one of the best), now if that is the case, and knowing computer vision consumes lots of resources, and extending some points made in the video, could we say that C++ place in computer vision is coming from an era when constraints were tight, and debating about how fast it is against others from an industry point loses some of it's solidarity?

    • @TheDeliberateEngineer
      @TheDeliberateEngineer  2 ปีที่แล้ว

      Thanks for the detailed thoughts! I'm with you, the answer is almost always "it depends, what do you care about?"

  • @DiogoBaeder
    @DiogoBaeder ปีที่แล้ว

    Rust brings the best of both worlds: the avoidance of garbage collection, but without needing explicit de-allocations, just by controlling ownership of variables and dropping (de-allocating) them automatically when not used anymore.

  • @groovy-kb8km
    @groovy-kb8km 2 ปีที่แล้ว +1

    What do you think about Cython as alternative of Python? As far as I know, cython is as fast as C++ and easy to be compiled from pure python code. So I think Cython has two advandates: Easy implementation and Fast running time. What do you think? (I am just junior developer so my explanation should be not correct)

    • @CSm.a
      @CSm.a 2 ปีที่แล้ว +2

      Cython's speed is 2x-3x of interpreted python yet no near java neither c++. Also try pypy it also fast and way easier to use relatively cython.

    • @TheDeliberateEngineer
      @TheDeliberateEngineer  2 ปีที่แล้ว

      Unfortunately I'm not familiar with python or its variants, so we'll have to hope someone else chimes in!

    • @groovy-kb8km
      @groovy-kb8km 2 ปีที่แล้ว

      @@CSm.a thanks! should we modify pure-python code into pypy-style if we want to use pypy?

    • @CSm.a
      @CSm.a 2 ปีที่แล้ว

      @@groovy-kb8km not really you can just install pypy compiler and use it

  • @Sanyu-Tumusiime
    @Sanyu-Tumusiime ปีที่แล้ว

    i prefer C++. here's why.
    harder language --> more talented people. aka. your peers are going to be smarter and you'll benefit from that.
    better performance --> why bother sacrificing performance when you don't need to. just work around it and get better.
    control --> you're better off just writing longer code. it doesn't matter if it's harder, just learn it and get over it. if not, you'll have your smarter peers to help you out.
    just my 2 cents. don't bother with gabage collected language. you're better off just sticking with something faster and something with smarter people writing it.

    • @TheDeliberateEngineer
      @TheDeliberateEngineer  ปีที่แล้ว +4

      I can't fault you for preferring C++, and I'm with you on the 'better performance' for carefully written code. I don't think the other two are universal, though. I know some brilliant people who write in garbage collected languages. At most of the places I've worked, performance is far less important than correctness and maintainability.