-
-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make C++ as first-class language to choose in the Attach Node Script dialog #573
Comments
I think this can be (partially) implemented as #119 / godotengine/godot#11080 , also see #565. Formally, I think GDScript could be already considered as a C++ scripting language to some extent as it acts as a wrapper over C++, but I get what you suggest. |
I was thinking of this idea a few years back, but i could never put it into words concisely. I think I ended up not posting it or closing my issue. I can't remember. Kudos to @nonunknown for having a good mock-up picture!! |
Technically speaking, there is already a system for registering third-party languages as built-in languages based on a plugin: PluginScript (the thing that the Python bindings use). Both NativeScript and PluginScript both run off the GDNative C API. Anyway, while I do believe you could theoretically make C++ an integrated language that way, there would be two weird details about it.
* Yes, you could just mandate that C++ scripts have to be header-only or something, but then you're also blocking the engine from being able to include and use most third-party C++ code. NativeScript doesn't have this limitation. Given the vast difference in quality between NativeScript C++ (good) and PluginScript C++ (bad), and because we already have a proposal for NativeScript C++, this proposal could be, in my opinion, closed as its scope is already covered by another proposal. |
maybe a new kind of file: .cph (cplusheaders) which points to all files related to a cpp -> (hpp and h) |
Note that C++ can be used as scripting language (via Cling interpreter) and how to do it is described at godotengine/godot#31630 (comment) Main benefit from Cling-based approach in ability to disable C++ interpreter and compile C++ as usual for max. speed (example: code in C++ without re-compile in dev. mode, but compile C++ as usual in release builds). Is anyone interested in proof-of-concept demo that uses Cling interpreter? |
@willnationsdev @Calinou I was thinking here, maybe this language makes possible to have what we need/want https://marcobambini.github.io/gravity/#/ this means we can easily have a language attached to a node, that doesnt need to recompile anything and its very c++ like. Any thoughts on it? |
@nonunknown That's unrelated to this proposal, which is about having "proper" C++ as a first-class language. I don't think we need to officially support yet another uncommon language in Godot 🙂 |
well I understand it, I just mentioned it cuz I thought using c++ as first-class wouldnt be possible! |
@nonunknown If anything, someone could create GDNative bindings to Gravity and it would be yet another option people can use just like C++, Nim, D, Rust, Haskell, etc. The notion of using C++ as a "first-class" language is more about improving the usability of NativeScript itself to make it behave more like a "first-class" language. Theoretically, if #119 gets implemented, you could teach the editor to also detect the presence of GDNativeBuild script types and generate new options in the "add a script" popup that would generate language-specific source code files and a At that point, the barrier between what is and isn't a first-class language becomes so miniscule that it hardly matters ("Oh no, I have to have a .gdns file paired with each of my .h/.cpp files. C++ isn't a legit first-class language! Booooo", etc.). |
Hi, just my 2 cents on this topic: Here is what I would consider "first class citizen C++":
The good news is I think Godot already has everything needed to achieve this \o/
Finally the whole thing should be packaged and provided through the Godot AssetLib, so C++ support would be trivially simple to install ^^ @Zylann since you are the more active on godot-cpp, I'm curious on what you think this ;-) |
There's https://gitlab.com/turtlewit/godot_cpp_helper_plugin which can help this already I think, not sure if this was mentioned before. |
@Xrayez wow thanks for the link, this is a super cool project ! (I'm just sorry I don't know Kat Witten's github nick to congratulate here her 😃 ) |
From the first post:
And you want C++? It can be made much friendlier with a bunch of tooling, but keep in mind C++ is a beast many consider to be broken. I personally like it, but IMO it's really not the best language if your goal is to focus on making a game, which is why even Unreal put so much effort into developping Blueprints, and right now is apparently preparing a new scripting language. It's not a choice to take lightly just because "C++ is fast". From touilleMan:
That would unlock a lot of nice things, but I'm not sure this will ever happen because Godot was absolutely not written for this, but it's not impossible (my previous engine was basically built that way). The hard part is keeping libraries compatible because compared to C, the ABI can break for every tiny version or even compiler versions, such that to share something, you would do so by source code and not prebuilt binaries, and let the user build it assuming they have the right compiler (which can be problematic for plugins).
Godot needs to integrate a language server client to have rich coding experience and implement a debugger interface for known C++ debuggers. But honestly, I would still not use Godot as a C++ code editor, there are much better external editors for this at the moment.
That could work for game scripts but much harder for plugins or tool scripts because the libraries (and then all tool scripts currently loaded) have to be pulled off somehow, just so Godot can overwrite the library.
This allows to make
I'm not well versed into PluginScript but from what I've seen so far, it's not designed to handle compiled languages that "talk to C directly", but rather more oriented toward dynamic languages, which doesn't fit C++. So I'm really not sure about it being a candidate here.
Again assuming all toolchain is correctly setup it's no big deal, although you'd need more than just a boolean, you need colored error logs and the ability to click on one to go to a file etc... My concerns about C++ and Godot are actually quite different from wanting to "make it more like a scripting language". It's more about the fundations.
The rest is about tooling, like this issue mostly notes. I think a lot needs to be defined beyond just the option of adding a "C++ script". |
Closing as obsolete as of the new GDExtension system. It actually goes in the opposite direction, GDExtension classes behave more like engine built-in types, while GDNative classes behave more like scripts you attach. |
Describe the project you are working on:
A 3D Platformer
Describe the problem or limitation you are having in your project:
I Would like to have some features done in c++
Describe the feature / enhancement and how it helps to overcome the problem or limitation:
Make c++ scripting language as a option to attach into nodes like csharp. Actaully the way to make cpp files needs to do a lot of configurations,compilations, and so on to simply make one script. So by adding it as a language option would work like csharp works, just select it and code!
Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
If this enhancement will not be used often, can it be worked around with a few lines of script?:
It will be used often
Is there a reason why this should be core and not an add-on in the asset library?:
This is already possible but for someone who wants to focus on game-making its not intuitive
The text was updated successfully, but these errors were encountered: