Skip to content
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

C++ or C# as scripting language #37

Open
cvet opened this issue Nov 23, 2018 · 13 comments

Comments

@cvet
Copy link
Owner

commented Nov 23, 2018

AngelScript is too limited in functionality.
C++ don't have interpreter with VM and can't be used as scripting language, it's too dangerous.
But if we compile code to JavaScript using Emscripten and then run it under some JS engine (like SpiderMonkey) its solve this problem.
Also WebAssembly is pretty fast.

@cvet

This comment has been minimized.

Copy link
Owner Author

commented Nov 23, 2018

Compile scripts using Emscripten, run using this (as variant) https://github.com/WAVM/WAVM
And we will have at least two programming languages for work - c++ an js.
Also we can run code in browser engine directly on web platform.

@cvet

This comment has been minimized.

Copy link
Owner Author

commented Nov 24, 2018

WAVM depends from LLVN and it's too heavy for client builds.
I've take Duktape as JS engine https://github.com/svaarala/duktape
Here I'll work with Duktape
https://github.com/cvet/fonline/tree/CppScripting
And here i'll try experiment with WAVM
https://github.com/cvet/fonline/tree/CppScriptingWasm

@cvet

This comment has been minimized.

Copy link
Owner Author

commented Nov 25, 2018

I think better C# as scripting language.
Then translate it via https://github.com/bridgedotnet/Bridge to JavaScript and run it via https://github.com/svaarala/duktape in server/client.
Experiment branch is here
https://github.com/cvet/fonline/tree/CSharpScripting

@cvet cvet changed the title C++ as scripting language C++ or C# as scripting language Nov 25, 2018

@cvet

This comment has been minimized.

Copy link
Owner Author

commented Nov 25, 2018

Mono is better, but I don't know can I run it on Web. Need try.

@cvet

This comment has been minimized.

Copy link
Owner Author

commented Nov 27, 2018

Mono integration branch
https://github.com/cvet/fonline/tree/CSharpScriptingMono
Mono doesn't have CMake so need improve it first.

@cvet

This comment has been minimized.

Copy link
Owner Author

commented Nov 30, 2018

I almost compile mono on all platforms for link it to engine statically, thats good.
I had to create cmake for this because mono uses autoconf.
Next steps it's replacing mono with AS and crate autoconverter script for translate AS to C# (maybe not fully, but most part).

@cvet

This comment has been minimized.

Copy link
Owner Author

commented Dec 5, 2018

Added VS Code as default IDE for fonline engine.
Also improved extension for validate/build server/client/mapper code (F7 or green triangle).

@blockspacer

This comment has been minimized.

Copy link

commented Aug 24, 2019

cling based C++ as scripting language / hot code reload
Why? Able to run C++ script in runtime or compile it for max speed ( as in example https://github.com/derofim/cling-cmake )
Also: May be used to improve modules compile time

HOT code reload
possible approaches:

store app state
fix cling undo for files
https://root-forum.cern.ch/t/loading-unloading-class-as-interpreted-macro-in-cling-multiple-times/32976/2

execute cling code to change callbacks & variables
nested cling::Interpreter with multiple cling::MetaProcessor
IDK how to do it, but you can create child cling::Interpreter

@cvet

This comment has been minimized.

Copy link
Owner Author

commented Aug 29, 2019

cling based C++ as scripting language / hot code reload

Thanks, I look into it.

@cvet

This comment has been minimized.

Copy link
Owner Author

commented Sep 12, 2019

I change decision again, I want C++ scripting with llvm/clang with static/dynamic linkage with engine (cling will be included too). There are not so safe as C#/Mono but who cares.

@cvet

This comment has been minimized.

Copy link
Owner Author

commented Sep 15, 2019

AngelScript stays and Mono/C# too :)
I targeting on four scripting languages for now:

  • native c++17 for speed, lightweight, powerful and pain of course
  • legacy AngelScript for many already written scripts
  • safe and modern C#/Mono for regular scripting
  • and old schooled StarTrek for run Fallout on engine out of the box
    Three last will be optional to decrease build outputs, and linked during Editor build process.
    New fonline engine workflow I describe later, but in two words - all work (asset management, build pipeline tuning and etc) will be in editor (plus your proffered IDE of course) and then editor will build bundled server and client binaries using llvm and precompiled engine/script libs by pressing one button. This will be pretty same as in modern game engines like Unity and Unreal Engine.
@blockspacer

This comment has been minimized.

Copy link

commented Sep 15, 2019

I change decision again, I want C++ scripting with llvm/clang with static/dynamic linkage with engine (cling will be included too). There are not so safe as C#/Mono but who cares.

If you want to use cling, maybe following will be useful:
https://github.com/blockspacer/CXXCTP/blob/master/src/template_engine/engine_main.cpp#L20

Note argRefToCling function, it allows to pass C++ variables into Cling (or maybe it is possible to do it easier).

// Or use macro / codegen
#define ARG_REF_TO_CLING(varType, varName) argRefToCling(varType, #varName, (varName))

Also note that usage example is reflection/codegen engine ( https://github.com/blockspacer/CXXCTP ), may be useful for game engine/level editor/e.t.c.

@cvet

This comment has been minimized.

Copy link
Owner Author

commented Sep 16, 2019

@blockspacer Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.