C ++ built-in scripting language for game development - cannot find anything that I like

I am desperate for a fast , C-like syntax , easy to embed , easy to wrap strong> scripting language to embed in my C ++ games.

So far I have tried:

  • Lua : it works, but wrapping C ++ global functions around it is painful, and wrapping objects around is even harder. Also, I really dislike the Lua syntax.
  • AngelScript : Failed to get it to work. The documentation for beginners is absolute, because the first examples are not compiled, and you need to create many add-ons first. Wrapping around C ++ objects and functions looks simpler than Lua, but it can still be cleaner. The syntax looks fine.
  • ChaiScript : failed to get it to work. I got a lot of errors with both git and git C ++ 11 versions. I don’t want to use the boost version since I don’t want to introduce boost as a dependency in my project. The wrap looks simple, and the syntax is fine.

I also researched:

  • Pike : the syntax looks good, but I did not find any embed documentation.
  • Squirrel : I don't like the syntax, and the attachment / wrapper is just as annoying as Lua is when dealing with the stack.

So:

  • Is there any good fast , C-like syntax , easy to embed , easy to port .?
  • If not, what are the best learning resources for creating a scripting language? I like to reinvent the wheel, and this can be an interesting learning experience.
+6
source share
8 answers

For syntax like C, checkout

  • Ch - commercial, embedded C-interpreter
  • CINT C / C ++ interpreter open source
  • Pawn - "a simple, faceless, 32-bit extension language with type C syntax"

Probably not for you, but since this question may appear on the list of alternatives that others might be interested in, I offer you QtScript , which gives you Javascript-like syntax. The wrapper may be simple, but for this you need to use the Qt frame, especially the concept of signals and slots.

There's also SpiderMonkey , the JS engine from Firefox.

+3
source

You can look at using JavaScript. A V8 script engine can be built into your program, and there is documentation on how to infer your types .

+4
source

You might be interested in Dao ( http://daovm.net , https://github.com/daokoder/dao ).

Tao is implemented in the C standard with minimal dependency (if you exclude additional modules and tools). It is lightweight and efficient with good support for deployment and expansion. Its interface for calling C functions is not stack based. Here is a simple example:

#include "stdio.h" #include "daoValue.h" static void Square( DaoProcess *proc, DaoValue *param[], int nparam ) { daoint num = param[0]->xInteger.value; DaoProcess_PutInteger( proc, num*num ); } int DaoOnLoad( DaoVmSpace *vmspace, DaoNamespace *nspace ) { DaoNamespace_WrapFunction( nspace, Square, "Square( num : int ) => int" ); return 0; } 

You may notice that there is no template code for checking parameter types in a wrapped function. This is because this function is registered as Square(num:int)=>int , which means that this function can only accept an integer as a parameter and is guaranteed by the Dao runtime.

You may also be interested to know that it also has a Clang-based tool for automatically / semi-automatically generating C / C ++ bindings.

Disclaimer: I am the author of this language.

+3
source

You can just use C ++ using something like Cling .

You get familiar syntax and easy integration with your static C ++ program.

Qt + Cling, C ++ interpreter based on LLVM (2:05)

+2
source

Besides what others have suggested, there is also Cling , which is considered experimental. Scripting is not easy, but for now, you can resort to LLVM , at least for the inside. The design of the programming language is briefly discussed in the old "Algorithms + Data Structure = Programs" by N. Wirth (but check the content section in the last issue, which was deleted), and if you are looking for an author on Google, in the end, of course, with some other publications on the topic.

+1
source

I started using python as a scripting language, I used boost python in my program (and not in the game) and am quite happy with it. If you want to try creating your own script, you can try boost spirit

0
source

You may be interested in ObjectScript.

ObjectScript, OS, for short, is a new programming language. It is free, cross-platform, lightweight, embedded and open source. It combines the advantages of several languages, including: JavaScript, Lua, Ruby, Python and PHP. The OS has Javascripts syntax, the lua multiple-output function, Ruby's syntactic shugar, and magic methods from PHP and Ruby - and more!

The minimum ObjectScript program used may look like this:

 #include <objectscript.h> using namespace ObjectScript; int main(int argc, char* argv[]) { OS * os = OS::create(); // craete ObjectScript instance os->require("main.os"); // run ObjectScript program os->release(); // release the ObjectScript instance return 0; } 
0
source

Source: https://habr.com/ru/post/949536/


All Articles