Since I’m having untracable issues with Lua due to its API and lackluster documentation, I’ve decided to drop it from my game engine (PixelPerfectEngine) in favor of some easier to use alternatives.

What I need is:

  • open source
  • small footprint even if it at the cost of some complexity (I need it as a scripting engine, not as a replacement for compiled application languages)
  • integer support (I don’t care if I could just round it on the backend)
  • C or C++ ABI
  • can be embedded into a software (yes, there are people that suggest you to use janky solutions like passing data in files and command line)

Even a better Lua implementation would suffice, and if I had the time, I would port the official one to D (my main language), while getting rid of the godawful stack method of control.

  • MJBrune@beehaw.org
    link
    fedilink
    English
    arrow-up
    9
    ·
    11 months ago

    gdscript is awesome but isn’t plug-and-play embed like Lua is. Here is an example of gdscript being pulled into another environment https://github.com/gdscript-online/gdscript-online.github.io This kind of breaks your last bullet point though since it’s not as developed as it should be but still possible to actually embed.

    angelscript is interesting http://www.angelcode.com/angelscript/ and hits all the points you made.

    squirrel also is interesting and is lua inspired. http://squirrel-lang.org/ It’s fairly well used.

    https://github.com/dbohdan/embedded-scripting-languages is a large list of embedded languages that should be easy enough to embed.

  • porgamrer@programming.dev
    link
    fedilink
    arrow-up
    6
    ·
    edit-2
    11 months ago

    This is not a recommendation, but just a couple of days ago someone linked to this project, claiming similar goals to lua, great performance, and gradual typing:

    https://cyberscript.dev/

    I can’t tell you what it’s actually like though.

    A more established, proven option is Haxe. Haxe has a lot of libraries but I think it’s specifically designed to be batteries-optional. This Haxe VM in particular looks pretty impressive:

    https://hashlink.haxe.org/

    Haxe has the distinction of having been used to ship loads of successful games made by small teams with custom engines.

    Another option designed for simplicity, low-complexity and easy embedding is wren:

    https://wren.io/

    Implementation is apparently only 4000 lines.

  • Shareni@programming.dev
    link
    fedilink
    arrow-up
    3
    ·
    11 months ago

    Check out scheme. The syntax is incredibly simple. Watch like the first 20 minutes of a first sicp lecture, and you’ll know enough lisp to read basic scheme.

    Macros are magic, and I’m guessing they would be really useful for you to abstract interactions with the engine. Check out the for macro and how it’s compared to the standard loop macro. Both implement a DSL to make iteration both simpler and easier to read (if you understand the specific language of the macro).

    • open source
    • Licence will depend on the implementation, but I think most are open source. Guile was the GNU champion in the embedded language war. Also, you can go full GNU with GNU make, GCC, and GNU guile.
    • small footprint even if it at the cost of some complexity (I need it as a scripting engine, not as a replacement for compiled application languages)
    • Scheme’s whole thing is to be minimal, while letting you make anything you need. For example the r5rs specification is 50 pages long, and I think has recursion as the only iteration method. Specific implementations add additional features like while loops.
    • integer support (I don’t care if I could just round it on the backend)
    • I’m not sure what you mean by int support, but there should be exact/inexact and “convert between them” functions for numbers. Check out the scheme specs and implementation docs for specifics.
    • C or C++ ABI
    • interop also depends on implementation, but guile should be pretty good.
    • can be embedded into a software (yes, there are people that suggest you to use janky solutions like passing data in files and command line)
    • there are a few schemes made specifically for embedding

    Documentation is really varied. Also, schemes usually don’t have all that much online info available, but the bigger ones have good communities.

    Just to warn you, you’re probably going to end up using Emacs if you decide to work with scheme. Doom Emacs is great. For magic check out lispy and paredit.

    • ZILtoid1991@kbin.socialOP
      link
      fedilink
      arrow-up
      1
      ·
      11 months ago

      Wren would be an ideal candidate, it even has a D port (not a binding, a full port), except for the lack of integer support.

  • sik0fewl@kbin.social
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    11 months ago

    I’ve used Squirrel a bit ages ago and it worked quite well. Similar to Lua, but OOP and more C-style syntax.

    I’m surprised Lua isn’t working out for you, though. It seems like such a simple language. Although I just admit I’ve never used it before.

    • ZILtoid1991@kbin.socialOP
      link
      fedilink
      arrow-up
      2
      ·
      edit-2
      11 months ago

      The main issue with Lua isn’t the language, but the API, which doesn’t want to play nice with my program, and is poorly documented with the assumption that people only want to use the API in the simplest possible way, even at the cost of not using certain functionality.

  • mercator_rejection@programming.dev
    link
    fedilink
    arrow-up
    1
    ·
    11 months ago

    I have used DukTape in the past, it is an ECMAScript (javascript) implementation. The API is amazing, very consistent parameter and naming schemes, uses a stack based approach (feels like a better version of how lua goes about things). It is designed to be embedded. Documentation for the API is some of the best you will see, lots of good examples. It even has a debugger that you can hook into.