• Stars
    star
    644
  • Rank 69,893 (Top 2 %)
  • Language
    C++
  • License
    MIT License
  • Created over 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

πŸ₯ A new take on polymorphism

DynaMix

Language Standard License Build

IMPORTANT v2 is here. It is a big change. The last v1 release was v1.4.0

DynaMix (Dynamic Mixins) is an alternative take on object oriented programming and dynamic polymorphism. It lets users compose and modify polymorphic objects at run time. The main target language is C++, but C is also supported.

The library is a means to create a project's architecture rather than achieve its purpose. It helps with extensibility, readability, scalability and interoperability. It focuses on maximal performance and minimal memory overhead.

DynaMix is applicable for the software architecture of systems with complex objects including, but not limited to:

  • Games (especially role-playing ones or strategies)
  • CAD systems
  • Enterprise systems

The library uses the type dynamix::object as a placeholder, whose instances can be extended with existing classes (mixins), thus providing a particular instance with the mixin features of all those types. Likely the most important types of mixin features are messages: functional objects which in C++-OOP terms can be thought of as methods. Mixin features are overridable and use late binding and singular dispatch. Unicasts and multicasts are possible.

Here is a small example of what code may look like using the library:

    // assuming my_objects.get_ally(0); is a way to get an ally to the
    // main character in a game
    dynamix::object& obj = my_objects.get_ally(0);

    // now let's make the object think some positive thoughts about the
    // main character

    think(obj); // C++ doesn't allow us to have obj.think().
                // DynaMix's messages are like standalone functions

    // composition
    mutate(obj, dynamix::add<flying_creature>());

    // object can now respond to fly()

    fly(obj); // ...instead of obj.fly()

    // mutation
    mutate(obj
        , dynamix::remove<ally>()
        , dynamix::add<enemy>()
    );

    think(obj); // the same object now thinks negative thoughts about the main
                // character, since it's no longer an ally, but an enemy

Here are some of the key features of the library:

  • Compose objects from mixins at run time
  • Physically separate interface and implementation
  • Non-intrusive – mixins don't need to have a common parent or any special code inside
  • Mutate "live" objects by changing their composition at run time
  • Use std::polymorphic_allocator to allow fine-tuning allocations and achieving cache locality in critical parts of the code
  • Create shared libraries and plugins which can enrich or modify objects, without modifying (or even rebuilding) the executable.
  • Add "hotswap" to a project while developing
  • Have complete runtime reflection by symbols or strings
  • Messages:
    • Fast polymorphic calls – comparable to std::function
    • Have multicast messages, which are handled by many mixins within an object
    • Thread safe message calls – as thread safe as the underlying methods.

Created with DynaMix

The following projects are known to use DynaMix as a key piece of their software architecture:

  • A3I by ViewRay (Released 2022) - A medical system for cancer treatment. Uses v2
  • huse - a polymorphic serialization library. Uses v2
  • Heroes of the Dark by Gameloft (Released 2021) - An RPG for Android, iOS, and Windows. Uses v1
  • War Planet Online: Global Conquest by Gameloft (Released 2017) - An MMORTS for mobile devices and PCs. Uses v1
  • Blitz Brigade: Rival Tactics by Gameloft (Released 2017) - A multiplayer RTS for Android, iOS, and Windows. Uses v1
  • Swords & Crossbones: An Epic Pirate Story by Epic Devs LLC (Released 2014) - A strategy/exploration game for Android, iOS, and PC. Uses v1
  • Earthrise by Masthead Studios (Released 2011) - An MMORPG (no longer supported). Uses an early proprietary prototype version of the library with a similar interface and a different implementation.

Documentation

The documentation is part of the repo in the doc/ directory.

Contributing

Contributions in the form of issues and pull requests are welcome.

License

License

This software is distributed under the MIT Software License.

See accompanying file LICENSE or copy here.

Copyright Β© 2013-2023 Borislav Stanimirov, Zahary Karadjov

Logo

License: CC BY 4.0.

The DynaMix logo is licensed under a Creative Commons Attribution 4.0 International License. Copyright Β© 2018 area55git

V1

DynaMix v2 is a complete rewrite and though it has the same idea as v1, it is incompatible with it, and has a different interface, and different implementation for most features, and different terminology for some.

The last release of DynaMix v1 was v1.4.0. The documentation is available here

A list of the most notable differences between v1 and v2 can be found here.

Boost.Mixin

DynaMix was initially developed as Boost.Mixin but is now a separate library that doesn't depend on the Boost libraries Collection.

Footer

More Repositories

1

picobench

A micro microbenchmarking library for C++11 in a single header file
C++
185
star
2

itlib

A collection of std-like single-header C++ libraries
C++
110
star
3

boost.mixin

Boost.Mixin is a C++ implementation of the Mixin idiom
C++
43
star
4

html5-gui-demo

Demos for using HTML 5 as a GUI for C++ apps
C++
41
star
5

mscharconv

<charconv> from Microsoft STL, but multi-platform
C++
37
star
6

mtime_cache

CLI gem to help make use of build artifacts cache in a CI system
Ruby
24
star
7

git-lfs-download

Download full or partial git-lfs repos without temporarily using 2x disk space
Ruby
21
star
8

cef-demos

Some demos and experiments with CEF
C++
19
star
9

cef-cmake

CMake helpers for CEF (the Chromium Embedded Framework)
CMake
18
star
10

b_stacktrace

A minimalistic single-header multi-platform C89 lib for stack tracing
C
12
star
11

yama

Yet Another MAthematical library
C++
11
star
12

cpp-dynamic-polymorphism

List of resources about modern dynamic polymorphism in C++.
11
star
13

dllpatch

CLI util: Poor man's rpath for Windows executables.
C++
9
star
14

fishnets

A WebSocket server and client library for C++17
C++
9
star
15

xec

A small library for multi-threaded execution contexts and task executors
C++
8
star
16

VSOpenFileFromDir

VSCode-style open file (ctrl-p) functionality for Visual Studio
C#
7
star
17

jalog

Just Another Logging library for C++
C++
7
star
18

furi

A header-only URI library for C99 and C++17
C
7
star
19

xmem

An alternative memory and smart pointer library for C++
C++
6
star
20

cmake-pch

A simple modern CMake (3.2+) script which adds a precompiled header to a target
CMake
6
star
21

kuzco

No touchy! Immutable state for C++
C++
5
star
22

huse

A C++ library for HUman-readable SErialization
C++
5
star
23

envo

An environment variable manager
Ruby
4
star
24

crake

A CMake generator written in Ruby
Ruby
4
star
25

doctest-util

Utilities for C++ unit testing with doctest
C++
4
star
26

cfc-demos

Demos for my talk CPU-Friendly Code
C++
4
star
27

mathgp

MathGP - a simple math library for game programming
C++
4
star
28

trex

πŸ¦– A header-only type registry library for C++11
C++
4
star
29

ibob.github.com

Personal website
HTML
4
star
30

icm

A collection of CMake modules
CMake
3
star
31

cpp-lib-template

A template for a C++ library
CMake
3
star
32

dynamix-c

A dynamic polymorphism library for C
C
3
star
33

BlockOut3000

A small 3D puzzle game
C++
3
star
34

maibo

Yet another C++ multi-platform multimedia library
C++
2
star
35

confy

A C++17 application configuration library
C++
2
star
36

doctest-lib

A CMake wrapper of https://github.com/doctest/doctest/ to make life easier
C++
2
star
37

c-utf8

utf8 ⇔ utf32 (Unicode) conversion for C an C++
C++
2
star
38

word-grid

A word game where you find words in adjacent cells in a grid
C++
2
star
39

vec-span-demo

Demo code for my talk "Beyond std::vector and std::span"
C++
2
star
40

natvis-join

A tool which joins multiple .natvis files into a single one
Ruby
2
star
41

jsc-standalone

Binaries for using Apple's JavaScriptCore as a standalone library
C
2
star
42

evoshooter

Global Game Jam project
C++
2
star
43

boost-trim

A trimmed-down subset of boost
C++
2
star
44

advent-of-code

My Advent of Code solutions
Ruby
1
star
45

ubsan-fp

A false positive in the undefined behavior sanitizer (pre clang 9)
CMake
1
star
46

splat

Small platform or compiler-specific macros and helpers for C and C++
C
1
star
47

mixquest

A game-like demo of DynaMix
C++
1
star
48

clang-fwd-decl-bug

clang fails to compile a forward declared template argument
C++
1
star
49

flashcards

A generator of flashcards
JavaScript
1
star
50

trie-map-bench

Comparing a trie map to other associative containers
CMake
1
star