‹ BackHN Continuity

Thread

Using any C++ library in Godot

168 points · 66 comments · czoido

  1. voodooEntity · · focus · HN ↗
    Was playing arround recently building an RTS with godot until i just hit the ceilling of what i could handle with gdscript performance wise.

    Than started to move alot of heavy logic to c++ simulation : tedious indeed but the results speak for themself.

    Basically allows me to use godot for things like menus dialogues and similar stuff while running the true heavy work in a c++ simulation.

    1. 8-prime · · focus · HN ↗
      What motivated you to use c++ rather than C#? Especially when you mention the usage of c++ being tedious, when I would argue using C# is equally straight forward as gdscript is.
      1. windsurfer · · focus · HN ↗
        C# is a "first class" language in Godot and doesn't need a GDExtension, but it's not compatible with web builds yet. There is a draft PR that includes C# support but it adds about +50 MB to a web export and is also missing a few features.
        1. 8-prime · · focus · HN ↗
          I did not know that. Thanks for the info. I always use C# with Godot, but never had a use-case where i needed a web build.
        2. pjmlp · · focus · HN ↗
          And even that doesn't add consoles support, is W4 that far?
          1. windsurfer · · focus · HN ↗
            Console support is accomplished using &quot;Middleware ports&quot; for the Nintendo Switch, Xbox Series X&#x2F;S, and PlayStation 5. <a href="https:&#x2F;&#x2F;godotengine.org&#x2F;consoles&#x2F;" rel="nofollow">https:&#x2F;&#x2F;godotengine.org&#x2F;consoles&#x2F;
            1. pjmlp · · focus · HN ↗
              I know the process, the question was how far .NET tooling support is there, because if they just rewrite everything into C++, there isn&#x27;t much there to talk about.
      2. voodooEntity · · focus · HN ↗
        A combination of two factors that are rather specific to myself. One being that even tho its quite some time ago i have a bit of c++ experience, while i never tried to code C#. So when i got the idea to try to run the heavy simulation in an &quot;extension&quot; it was just a language i was a bit familiar with. Maybe C# would have been the &quot;smarter&quot; choice, i just never digged into it yet.

        The other reason is that in my well closer circle i got quite some people that code c++ on a daily basis and i don&#x27;t know (at least i think so) anyone doin C# actively, so i thought if i would get stuck i have people i can easily ask about my c++ problems.

        So it wasn&#x27;t a &quot;i think c++ is better than c#&quot; decision rather a what do i know and what resources i have available easily.

        1. jdw64 · · focus · HN ↗
          C# is mostly in the Unity community. I agree that GDScript performance isn&#x27;t good.
          1. KronisLV · · focus · HN ↗
            Godot, Unity, Stride, Flax and even jank niche engines like NeoAxis generally have pretty good C# integration!

            If you look more at Stride, you’ll see that even their physics engine is C# which is insane in the best possible way: <a href="https:&#x2F;&#x2F;doc.stride3d.net&#x2F;4.3&#x2F;en&#x2F;Manual&#x2F;physics&#x2F;index.html" rel="nofollow">https:&#x2F;&#x2F;doc.stride3d.net&#x2F;4.3&#x2F;en&#x2F;Manual&#x2F;physics&#x2F;index.html and <a href="https:&#x2F;&#x2F;github.com&#x2F;bepu&#x2F;bepuphysics2" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;bepu&#x2F;bepuphysics2

            Very cool language and as much of a mainstay in gamedev like something like Lua.

            It surprises me that Java never got similarly big despite their GC improvements, though jMonkeyEngine was a nice project last I looked.

            1. torginus · · focus · HN ↗
              Yeah there are some gamedev treasures in C#, owning to the fact that Microsoft created the Xbox Live Indie Games program back in the X360 era, which meant you could ship games to customers with generally little oversight and meddling - this was WAY before Steam did something similar, and even before the iPhone app store.

              The catch was that you had to use C# and XNA (which was a wrapper for gaming related APIs like DirectX, XAudio and XInput, generally considered to be very good). This meant there were a lot of hardcore libs made for C# gamedev (BEPU physics is from that era, and there were things like very good UI frameworks).

              Tons of games were made with XNA, and its open source ofshoots, MonoGame and FNA power some of the greatest indie hits (Stardew Valley, Celeste, Bastion and other Supergiant titles, Terraria come to mind).

              Imo this is one of the main reasons Unity went with C# in the first place.

              1. pjmlp · · focus · HN ↗
                Historical note that Arena Wars, released in the .NET 1.0 days, with thin bindings to OpenGL, was the very first .NET game, years before XNA.

                <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Arena_Wars" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Arena_Wars

                C# being closer to C++, and .NET having direct support for C++ helped quite a bit regarding adoption among game studios.

                Unity started on Mac, and they only adopted .NET when doing the cross platform rewrite.

                I also don&#x27;t remember if there wasn&#x27;t some Mono advocacy at the time, as they became customers in the process.

                Ironically Mono&#x2F;Xamarin is almost gone from official .NET, all these years after the acquisition, with every modern .NET release, another bit falls off.

                We are already on the phase that CoreCLR might take the remaining bits.

      3. pier25 · · focus · HN ↗
        Not sure how relevant this is for this simulation use case but IIRC C# has a bigger overhead when communicating with the core engine compared to GDScript or C++.
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.