I’m developing 2D game with SDL2.0 and I want to embed scripting language to C
I tried java,lua,squirrel.
For me,squirrel is the best for now but there might be exists other better solutions.
however, is squirrel has enough performance?
I will appriciate any suggestion and reason of it.
the purpose of using scripting language is extensibility.
I consider that performance and C like syntax are important.
Recently I found teascript but seems it is still beta version.
My personal preference would be still Lua but with LuaJIT for the easy C interop, so you can wrap SDL objects with metatables and extend them easily. There is also Teal, which does for Lua what Typescript does for JS (add types then compile to Lua) but I haven’t used it.
If the scripts are mostly just calling higher level functions that are implemented in C then the performance of the scripting language might not matter too much.
I use SDL library for drawing, C for hit box calculation, data structure
but I m going to use scripts for some callback function for damage calculation and character motion and game event flow
Is is too much job for Squirrel?
I don’t have any personal experience with Squirrel or Lua so I cannot say anything about their performance. I suspect it will be slower than pure C but how much and whether it will be a problem I cannot say as it will depend on a lot of factors (how many “script callbacks” you have, how often you call them, etc.).
You might want to write some tests to get a feel for what the performance is like. Implement the same functionality in both C and Squirrel and compare. But even if you conclude that Squirrel is 10x slower than C it still doesn’t necessarily mean it will be too slow. If only 10% of the time is spent in Squirrel then changing it to a different language would never be able to accomplish more than a 11% speed increase of the program as a whole (that’s the upper limit, the real speed increase would likely be less).