CppCon 2018: Borislav Stanimirov “DynaMix: A New Take on Polymorphism”

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 ก.ค. 2024
  • CppCon.org
    -
    Presentation Slides, PDFs, Source Code and other presenter materials are available at: github.com/CppCon/CppCon2018
    -
    Software with very complex business logic, such as games, CAD systems, and enterprise systems, often needs to compose and modify objects at runtime - for example to add or override a method in an existing object. Standard C++ has rigid types which are defined at compile time and make this hard. On the other hand languages with dynamic types like lua, Python, and JavaScript make this very easy. Therefore, to keep the code readable and maintainable, and accomplish complex business logic requirements, many projects use such languages alongside C++. Some drawbacks of this approach include the added complexity in a language binding layer, the performance loss from using an interpreted language, and the inevitable code duplication for many small utility functionalities.
    DynaMix is a library which attempts to remove, or at least greatly reduce, the need for a separate scripting language by allowing the users to compose and modify polymorphic objects at runtime in C++. This talk will elaborate on this problem and introduce the library and its key features to potential users or people who might benefit form the approach with an annotated example and a small demo.
    -
    Borislav Stanimirov, Bulgaria
    Borislav has been a C++ programmer for 15 years. In the past 11 he has been programming video games. He has worked on C++ software for all kinds of platforms: desktops, mobile devices, servers, and embedded. His main interests are software architecture and design, and programming languages.
    -
    Videos Filmed & Edited by Bash Films: www.BashFilms.com
    *-----*
    Register Now For CppCon 2022: cppcon.org/registration/
    *-----*

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

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

    That dynamic hot patching is amazing - this is as close to the convenience of a scripting language as you could get in C++

  • @zhaoli2984
    @zhaoli2984 5 ปีที่แล้ว

    Nice, my favorite of CppCon2018 so far (haven't finished all of them). Does the library use function pointers underneath and stores them in a 2D array, then those macros are used to invoke the right function?

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

    I think, I didn't get it. Is it faster than virtual function calls? Maybe I need another look at it.

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

      No it's slower because it's more flexible to use.
      I guess you don't know ruby or objective-c or any other modern script language with flexible object system.
      You can dynamically do things that look like changing the objects class type on the fly. And having a multiple inheritance system that is used like duck typing. As borislav said, you might need it or might not.

    • @OperationDarkside
      @OperationDarkside 5 ปีที่แล้ว

      @@llothar68 Thank you. I haven't used the languages you mentioned. I really need to look it up, to understand it.

  • @jokinglimitreached1503
    @jokinglimitreached1503 5 ปีที่แล้ว

    this seems interesting. I'm concerned about the quality of the library if it's made by one person

    • @onqtam
      @onqtam 5 ปีที่แล้ว +3

      I'm not sure if I should take into account your nickname :D
      The internet is full of projects spread across the quality spectrum - from extremely high quality all the way down to dog#$&* (probably the majority) - regardless if they are made by one person or not. That is where our capacity for reason comes in - we should use our heads to evaluate each project on a case by case basis.
      Have a look at the code on GitHub - I'm one of its users and I've dug into it a number of times to propose improvements and I can say without a doubt - this is some of the most readable and well written C++ I've encountered.

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

      @@onqtam и аз съм българин, предполагам че сте по името. I'm still a student so I can't really evaluate a library myself, but I really like the ideas in DynaMix. If the library could get evaluated by a committee or trusted developers, I would like to use it in my future career. (btw, my name is a joke, and each comment should be looked at case by case if it's sarcasm or not :) )

    • @onqtam
      @onqtam 5 ปีที่แล้ว +3

      @@jokinglimitreached1503 Touché :D
      As far as being reviewed - it proved to be hard to grasp (it cannot be explained in a single sentence such as a "library for signals/threading/processes") and when it was submitted for peer-review to boost it was neglected for a few years until Borislav gave up on the idea. A review of this library would require more effort compared to most other libraries - this entire talk is just about the "What" and "Why" behind the creation of dynamix - the "How" (the implementation) is a longer discussion.

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

      @@jokinglimitreached1503
      Yes. Sadly no Boost committee member dared to review it :)
      Still, as I mentioned in the talk, the library has had its real world usages. There are teams out there who have reviewed the library and deemed it appropriate for their needs. This can be thought of as a committee, I guess. I would even dare to say that being used in a real world project is a more credible testament to the usability than a review, however thorough, done in isolation for the review's sake.
      Also there's this thing called MeetingC++ Certified Libraries. Sadly it's not popular, but nevertheless the library was reviewed there and was approved: meetingcpp.com/CertifiedLibraries/

    • @jokinglimitreached1503
      @jokinglimitreached1503 5 ปีที่แล้ว

      @@bstanimirov Amazing! Thank you for answering. Късмет с популяризирането на DynaMix към повече девелопъри

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

    I'm sorry but these ideas are just bad on a conceptual level.
    People don't use scripting languages because of their loose take on OOP. That's just lying nonsense. They use them for fast iteration time, simplicity and because users cannot mess with memory. Those users don't necessarily know what OOP is.
    * Duck typing interfaces are horrible. Never use this. Interfaces are the specification, otherwise you're programming by convention.
    * Dynamic mixins have no business in a statically typed language. They are a way to monkey patch functionality for flimsy dynamic languages.
    * This library basically takes a perfectly fine static language and turns it into dynamic poop. You are trading compile time errors for runtime errors.
    * UFCS is the worst thing ever. It's a confusing way to achieve nothing.
    * The use case this is supposed to solve has been worked out, used and improved throughout the past 20 years in game development. It's called Component System, search for it.
    Yuck!

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

      The use case is dynamic polymorphism. Component systems, as in entity-component-system, is not polymorphic. If you try using it to achieve dynamic polymorphism, you will end up with something similar to this library. For example the Interface to Component pattern or... pretty much this library.
      But yeah, I know people who hate duck typing and dynamic polymorphism exist and I can't change their mind. Religion is rampant in software development. Que sera sera