4

First off, I'm aware that there are many questions related to this, but none of them seemed to help my specific situation. In particular, lua and python don't fit my needs as well as I could hope. It may be that no language with my requirements exists, but before coming to that conclusion it'd be nice to hear a few more opinions. :)

As you may have guessed, I need such a language for a game engine I'm trying to create. The purpose of this game engine is to provide a user with the basic tools for building a game, while still giving her the freedom of creating many different types of games.

For this reason, the scripting language should be able to handle game concepts intuitively. Among other things, it should be easy to define a variety of types, sub-type them with slightly different properties, query and modify objects dynamically, and so on.

Furthermore, it should be possible for the game developer to handle every situation they come across in the scripting language. While basic components like the renderer and networking would be implemented in C++, game-specific mechanisms such as rotating a few hundred objects around a planet will be handled in the scripting language. This means that the scripting language has to be insanely fast, 1/10 C speed is probably the minimum.

Then there's the problem of debugging. Information about the function, stack trace and variable states that the error occurred in should be accessible.

Last but not least, this is a project done by a single person. Even if I wanted to, I simply don't have the resources to spend weeks on just the glue code. Integrating the language with my project shouldn't be much harder than integrating lua.

Examining the two suggested languages, lua and python, lua is fast(luajit) and easy to integrate, but its standard debugging facilities seem to be lacking. What's even worse, lua by default has no type-system at all. Of course you can implement that on your own, but the syntax will always be weird and unintuitive.

Python, on the other hand, is very comfortable to use and has a basic class system. However, it's not that easy to integrate, it's paradigm doesn't really involve type-checking and it's definitely not fast enough for more complex games. I'd again like to point out that everything would be done in python. I'm well aware that python would likely be fast enough for 90% of the code.

There's also Scala, which I haven't seen suggested so far. Scala seems to actually fulfill most of the requirements, but embedding the Java VM with C doesn't seem very easy, and it generally seems like java expects you to build your application around java rather than the other way around. I'm also not sure if Scala's functional paradigm would be good for intuitive game-development.

EDIT: Please note that this question isn't about finding a solution at any cost. If there isn't any language better than lua, I will simply compromise and use that(I actually already have the thing linked into my program). I just want to make sure I'm not missing something that'd be more suitable before doing so, seeing as lua is far from the perfect solution for me.

cib
  • 2,124
  • 2
  • 21
  • 23
  • 1
    Did you already create the engine? Have you looked at engines such as OGRE and how they approach the issues you're mentioning? I don't know how much experience you have, but I sounds like you're getting way ahead of yourself. If you have loads of experience, feel free to ignore me. But in any case I'm hard pressed to come up with a suggestion that suits all your needs. – Bart Jun 16 '11 at 00:16
  • 1
    By reading the question title, I was about to say Lua. If you say no to Lua, then I might reluctantly suggest looking at [Go](http://golang.org/). – c00kiemon5ter Jun 16 '11 at 00:19
  • @Bart: You're correct, I am not very experienced in this regard, which is exactly why I'm asking here. As I said, it's not unlikely such a language doesn't exist. However, I do know quite a bit about how languages work, and I have a very specific idea about what I want. Lua sounds like a good choice, but what irks me about it is that it doesn't have any comfort whatsoever(I mean, the lack of += is a very basic fault) and I really would like to create a system that is fun to use, rather than making the user put up with all of lua's little quirks. – cib Jun 16 '11 at 01:01
  • 2
    @cib Then have a good look at what's already out there. Look at engines (such as OGRE for example, but there are others) and how they are structured, as well as what they actually expose through scripting. I think that would already answer some of your questions and might ease the "pressure" you're putting on your scripting requirements. Of course that does not solve some of the "shortcomings" you mention, but with a bit more knowledge you can take it from there and see if there are valid alternatives that are closer to what you would like. Good luck. – Bart Jun 16 '11 at 01:07
  • you may also want to consider [Angelscript](http://www.angelcode.com/angelscript/). Take a look at [this blog post](http://blog.wolfire.com/2010/01/Choosing-a-scripting-language) where I came across it. – c00kiemon5ter Jun 16 '11 at 01:11
  • @Ivan: Yes, angelscript seems like a nice language, although I'd probably prefer lua simply for the better speed. – cib Jun 16 '11 at 01:25
  • Lua and Python do have type systems, in fact they are very strong type systems, its just that it happens at run time. Its pretty much a given that any scripting language will not have static typing. They either use the TCL's "everything is a string", perls "make it the the type I want", or Lua,Python,ruby etc.s "I check before I use it". – James Anderson Jun 16 '11 at 01:47
  • I should really say "class system" then. Lua has a set of standard types, but it has no such things as inheritance. My high expectations towards a scripting language may also stem from the fact that I've been using a scripting language that has dynamic typing with compile-time type-checks for quite a while now. – cib Jun 17 '11 at 19:41

4 Answers4

2

Try the Ring programming language http://ring-lang.net

It's general-purpose multi-paradigm scripting language that can be embedded in C/C++ projects, extended using C/C++ code and/or used as standalone language. The supported programming paradigms are Imperative, Procedural, Object-Oriented, Functional, Meta programming, Declarative programming using nested structures, and Natural programming.

The language is simple, trying to be natural, encourage organization and comes with transparent implementation. It comes with compact syntax and a group of features that enable the programmer to create natural interfaces and declarative domain-specific languages in a fraction of time. It is very small, fast and comes with smart garbage collector that puts the memory under the programmer control. It supports many programming paradigms, comes with useful and practical libraries. The language is designed for productivity and developing high quality solutions that can scale.

The compiler + The Virtual Machine are 15,000 lines of C code

Embedding Ring Interpreter in C/C++ Programs https://en.wikibooks.org/wiki/Ring/Lessons/Embedding_Ring_Interpreter_in_C/C%2B%2B_Programs

msfclipper
  • 96
  • 3
2

You might consider mono. I only know of one success story for this approach, but it is a big one: C++ engine with mono scripting is the approach taken in Unity.

Michael J. Barber
  • 24,518
  • 9
  • 68
  • 88
1

For embeddability, you might look into Tcl, or if you're into Scheme, check out SIOD or Guile. I would suggest Lua or Python in general, of course, but your question precludes them.

Jon Purdy
  • 53,300
  • 8
  • 96
  • 166
  • I'm actually working on a language right now that's very well suited to this sort of thing, but unfortunately it's not yet mature enough to be used for production. – Jon Purdy Jun 16 '11 at 00:25
  • I appreciate your input, but the programming languages you mentioned seem all to be relatively slow. The problem here is that my speed requirements seem to exclude most dynamic languages except luaJIT. – cib Jun 16 '11 at 00:55
  • 1
    @cib: You really have to test and profile before asserting that they're too slow. The languages I suggest are the only tools I know of offhand. Tcl and Lua were both designed with embedding foremost. Lua is *the* go-to language for this sort of thing in general, its unsuitable debugging capabilities aside. It's a real shame I can't point you to my language project yet. I guarantee you'd love it. – Jon Purdy Jun 16 '11 at 01:01
  • As a matter of fact, I had the idea of creating a language myself. Of course, if I did that, I'd probably never get to actually working on my current project. Still, I'm interested in what you're working on, is there a site? – cib Jun 16 '11 at 01:06
  • @cib: Creating a language yourself isn't as bad an idea as you might think, provided you only add features that you absolutely need, when you absolutely need them. YAGNI is the defining principle, or else you'll never get anything done. And I'm making a site soon; I'll link you when it's up. – Jon Purdy Jun 16 '11 at 01:35
1

Since noone seems to know a combination better than lua/luajit, I think I will leave it at that. Thanks for everyone's input on this. I personally find lua to be very lacking as a high-level language for game-programming, but it's probably the best choice out there. So to whomever finds this question and has the same requirements(fast, easy to use, easy to embed), you'll either have to use lua/luajit or make your own. :)

cib
  • 2,124
  • 2
  • 21
  • 23
  • Since I answered my own question, I'll wait a bit to see if anyone objects to what I said here before marking it as the accepted answer. – cib Jun 17 '11 at 19:48
  • I would suggest also posting this question on [gamedev](http://gamedev.stackexchange.com/ "gamedev.stackexchange.com") as well. It is another stack exchange site that is more specific to what you are looking for. – ikottman Jun 17 '11 at 20:01
  • Lua was never intended as high level language for games in the first place but as glue one. It is used in gaming because of its small size and speed (not even mentioning luajit). – minerals Aug 03 '17 at 13:24