Good Scripting Language for C

Started by
12 comments, last by Serapth 8 years, 9 months ago
Hey guys, I have decided that I am going to look more into C programming, now my next question is: What scripting languages can be used with C? What would be the best (in your opinion) for making games? Should I master C before I start scripting, or learn the two together?

Sorry if these sound like stupid questions haha, I just want to make sure I'm learning useful things and implementing them correctly.
Advertisement
Lua is a fairly popular choice and from experience is fairly simple to integrate. Some games use Python as a scripting language, but I don't personally have experience with that, so I couldn't tell you which is better. I will say that the documentation for Lua's C binding is quite comprehensive.

That's a rather generic question and answers will vary a lot depending on what you want to do. But generally speaking Lua would be a safe bet for many use cases. I'd go with C++ rather than C for making games (or with a different language entirely, if your goal is not working in the industry), and I'd go with learning one language at a time in order to not get confused. For any game project you'll also have to learn a bunch of APIs, adding a scripting binding on top of that may just be overkill unless you have a specific reason for it (for example if you are working with non-technical artists and want them to create gameplay functionality).

Hey guys, I have decided that I am going to look more into C programming, now my next question is: What scripting languages can be used with C? What would be the best (in your opinion) for making games? Should I master C before I start scripting, or learn the two together?

Sorry if these sound like stupid questions haha, I just want to make sure I'm learning useful things and implementing them correctly.

If you havent learned C or C++ well yet don't even attempt to embed a scripting language. That's like trying to invent a car before you've invented the wheel. Perhaps a fun exercise, but doomed to failure.


Some games use Python as a scripting language, but I don't personally have experience with that, so I couldn't tell you which is better.

Lua is smaller, faster and easier to embed than Python, but Python has much more language features, libraries and AFAIK a bigger community. This is the reason that people frequently use Lua as only a scripting language on top of a large engine whereas Python can more often be found to be used as the main programming language of a piece of software.


Should I master C before I start scripting, or learn the two together?

Master? No, but you certainly need to be proficient in it. How much experience do you have with programming in C?

Highly opinionated but somewhat relevant.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

Master? No, but you certainly need to be proficient in it. How much experience do you have with programming in C?


On and off only a couple of months, deffinately not enough to move on, I still need to learn APIs I'd guess and more about everything haha. I've only got the bare bones

I recommend taking a different approach. Just as you can embed a scripting language into a C/C++ application, the reverse is also true: You can embed C/C++ libraries into your applications written with a scripting language.

The advantage here is that instead of doing all the boilerplate in a language that can be somewhat more difficult and/or tedious to develop in, you can develop in the more expressive and probably simpler scripting language. When (if) you find that the scripted code is too slow, you can recode the underperforming parts in C or C++. With python and ctypes or CFFI this is a pretty straightforward task.

If your goal is just to learn C or C++, there is no reason why you actually need to use a scripting language at all. If you want to be able to plug in code at runtime you can use a dynamic link library. If you're writing a small game I suspect that the time invested in embedding a scripting language won't really get you much in the end anyway.

Many small games don't need any scripting languages (the reverse is also true: many small games can be written entirely in scripting languages). If you're just learning C, it'd simplify things by not trying learning two languages at once.

Though I question your choice of learning C in the first place. Seeing this thread, I think you might've gotten confused.

C absolutely has value, and C is still in use, and C is definitely worth learning.

Many languages have value, many languages are in use, and many languages are worth learning.

I think people's response to your query in the other thread about whether C is still in use, made you think that it was what people were recommending you learn next - rather than a side discussion about the merits of C and whether you should eventually learn it. (Maybe they were recommending you learn C next, I'm not sure, but it's not what I'd recommend. It's certainly an option though)

I believe your original question about "C# or C++?" was more on-target. Actually, you asked "Unity vs C++", and "Scripting vs Programming", which revealed some misconceptions, which Hodgeman properly addressed. I think you should return to the choice, "C# or C++", and either of those two choices would be really good. Learn one, and then the other. The order of those two don't truly matter (and people will have different advice of which of those two it'd be better to learn first). Whichever you choose to learn first, you should stick with for multiple years to really go deep in it.

In your original question, you asked which of those two (C# or C++) were "best" for your goals. Either choice is a valid route, and will take you (over the course of many years and multiple languages) to similar destinations. Since you already started learning C++, I'd say stick with it and make sure you learn modern practices (and also the modern features in C++11 & C++14); personally, I feel that'd be the slightly better of two great options. But I'm biased, as a C++ fan, and I'm also not an experienced videogame industry professional.

I'm not even going to touch the C versus C++ debate apparently going on in this thread. Going back on topic, Lua is fine. The Python API is pretty heavyweight and Python doesn't have that many advantages in the scripting department (it shines most as a tool development and middle-layer language in my experience) so I wouldn't recommend it for that task.

“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”

This topic is closed to new replies.

Advertisement