Someone ought to make a tier list
Someone ought to make a tier list
Let's say, that hypothetically, you decided to write a video game, and also decided to develop your own in-house game engine for it, rather than use an existing one. The engine itself - along with any and all CPU-intensive stuff, or anything you intend to hardcode - will be in C++ (or C if you prefer, but I prefer C++), while for everything else, you will be embedding a scripting language into your application. Basically, scripting languages are for when you want to be able to modify aspects of your application without having to compile the entire thing, or resort to hex-editing when you lack the source code to it - since scripting languages are interpreted, rather than compiled, they are orders of magnitude slower than compiled languages, but this is the price you have to pay for introducing programmability to your app. And in most cases, the benefit of programmability easily outweighs the - usually marginal - performance cost.
But which scripting language should you use? There are plenty of them, and if you liked none of them, you could even create your own. Well.... someone ought to make a tier list video. Sadly, it probably won't be me, because I'm not that good at making videos, and I don't know enough scripting languages to truly rate every single one of them. But I will showcase a few in this article, without putting them into any particular order.
Should TypeScript and CoffeeScript be on the list?
TypeScript is a great language, with a huge ecosystem of existing modules and code, a neat syntax, a nice way of handling modules, overall good ****. It is what JavaScript should have been from the very start. But I digress.
TypeScript is more than just a language: if anything, it is more like a linter. You cannot use TypeScript directly in anything, there is no TypeScript interpreter - it is a compiled language.... or more precisely, transpiled, because we don't compile TypeScript directly to any bytecode or machine code, we actually transpile it to JavaScript, which then gets executed by... well, your browser, NodeJS, or any application with V8 embedded in it. Of course, alternatively, you could "compile" (transpile) TypeScript to Lua too.
As such, I feel a bit torn on whether TypeScript really has a place in any scripting language tier list, because it's not so much a programming language - at least in the traditional sense - as it is rather a tool that makes it easier to write JavaScript (or Lua) code. As such, I am going to reluctantly say no. However, I will still mention TypeScript at places.
Similarly, CoffeeScript won't be on the list, because just like TypeScript, it compiles - or more precisely, transpiles - to Javascript.
How might I rate them?
As I said, I'm not going to make a tier list - someone else totally should, though - but I will still rate a few scripting languages - at least, ones I have at least some level of familiarity with - based on several parameters:
Embeddability: Arguably the most important aspect to any scripting language - especially one we intend to use in a video game - is how easy is it to embed within a C/C++ application, how easy is it to extend with additional functions written in C/C++, etc.
To an extent, this overlaps with Readbility & Aesthetics, at least when concerning the C/C++ API of the scripting engine.
Performance: Obviously, we don't expect an interpreted scripting language to have the speed of hyper-optimized hand-written assembly code, but neither do we expect the scripting language to single-handedly grind our game to a 1 frame-per-second PowerPoint slide either. Performance matters.... to a degree.
Learning curve: Does the language take an afternoon to learn, or does it take literal years? Obviously, a scripting language for a video game ought to be on the shorter side, being able to be learned by a large amount of modders.
Readability & Aesthetics: Unreadable code almost certainly equals unmaintainable code, which is especially problematic for a larger project like a video game. Now, you can produce unreadable and ugly code in any programming language - sometimes intentionally, in the case of obfuscated code - but some programming languages make it straight-up impossible to produce beautiful and easy-to-read code. Also, I am going to be a little biased here, and give bonus points to languages with a C-like syntax, curly braces and semicolons, while penalizing those that omit these aesthetics.
To an extent, this overlaps with Embeddability, at least when concerning the C/C++ API of the scripting engine.
Ecosystem: This is probably the least important aspect of an embedded scripting language, but it's still a nice bonus to have access to a pre-existing rich ecosystem of modules and optimized code written by others. Obviously, in this aspect, well-established languages like JavaScript, Lua, Python and C# are going to be winners, while relatively unknown scripting languages will be losers.
And with that out of the way, let's get ready to embed!
My brief review of some scripting languages
Lua
Lua holds a special place in my heart. It is the first scripting language I ever came into contact with, and the second programming language I ever learned (the first being C++). Now, is it a good language? Let's see.
Embeddability: 5/5. Lua is fairly easy to embed into C/C++ (albeit there is an initial difficulty for even experienced programmers in wrapping their heads around the stack system of the C API, or the 1-based indexes), and you can also easily extend Lua with your C++ classes using the C API. Hell, there is an even simpler way using LuaBridge or SWIG. When embedding Lua into C++, I constantly have this site open.
Performance: 5/5. Lua itself is a fairly performant language, even when used in its original pure interpreter mode - its memory footprint is smaller than that of Perl and Python, faster than UnrealScript and Ruby, and overall more performant than JavaScript. It can be even faster when one uses LuaJIT, which has performance comparable to native C! How crazy is that?
Learning curve: 4/5 - while Lua does have some unique quirks (which programming language doesn't?), like 1-based indexes (0-based indexes are the norm in programming, for any non-developers who are accidentally reading this article) and being able to return multiple variables from a function, it is a language with a short learning curve and a well-documented, easy-to-read API.
Readability & Aesthetics: 2/5. Besides my subjective opinion on Lua's aesthetics (syntax isn't C-like, there are no curly braces - except for arrays and objects/maps, - no semicolons, etc. overall looks like an overgrown ugly config file), arguably the biggest weak point of Lua is the readability of the code itself. It is not my subjective opinion, but an objective fact, that larger projects become utterly unmaintainable in Lua. Also, Lua is a dynamically typed language, which makes it easy to get lost at what type is a certain variable. All of these problems can be easily remedied with TypescriptToLua (which comes at the cost of giving up on some of Lua's unique features like multiple return values, but oh well), but when we're restricted to vanilla Lua, it's a 2/5.
Ecosystem: 3/5. LuaRocks is a thing, and there is plenty of Wikimedia Module code written in Lua for you to "borrow". That's about it. It's good, but still a 3/5 because it is absolutely dwarfed by JavaScript's and C#'s much bigger ecosystem.
Overall Score: 19/25.
JavaScript
JavaScript is arguably the most widely used scripting languange in the whole world. The Internet practically runs on JavaScript. It is embedded into almost every single webpage. Without JavaScript, we would be limited to completely static webpages with zero interactivity. But obviously, JS isn't used exclusively in the browser: it is also used stand-alone as a backend language, and is sometimes embedded into applications written in C or C++. How does it measure up in that department?
Embeddability: 4/5. When it comes to embedding JavaScript into C/C++, you have two choices: Google's V8 and Mozzila's SpiderMonkey. V8 is far easier to use and far faster than SpiderMonkey, so I reccomend using V8, but if you are feeling particularly experimental, you could try tiny-js, muJS, any of the other ECMAScript engines.
Performance: 5/5. This depends on which engine you are using, but assuming that we're dealing with V8, the score can't be anything other than 5/5. While Google's claims about their V8 JavaScript being merely 20% slower than C++ is highly debatable (as one person answered, it's more like 400%), it's still a fast language: it has to be, since it's embedded into every single browser.
Learning curve: 3/5. JavaScript is still one of the easier-to-learn languages, but definitely more difficult than Lua. Power comes at a cost, and JS's mutlithreading abilities (async), object-oriented features (objects, maps, arrays, and so forth) and other niceties come at the cost of a slightly longer learning curve. While you could practically master Lua in a single afternoon (or at least a single weekend), JavaScript requires more like an entire week.
Readability & Aesthetics: 4/5. It's a curly-brace language with a C-like syntax, which is a big plus for me (I know, I'm biased), and is overall very much readable for C(++) programmers. However, there is one minor flaw within JavaScript is that it's a dynamically typed language, where it's easy to get lost at what type is each variable. If you add TypeScript into the mix - which is what you should be programming in anyway, rather than directly in JavaScript - then it would be a 5/5, but for vanilla JavaScript, it's 4/5.
Ecosystem: 5/5. Can't be anything other than 5/5. Pretty much every website uses JavaScript. There are millions of modules on NPM. TypeScript - arguably the best thing ever - is literally part of the JavaScript ecosystem. Really, I cannot give this any other score than maximum.
Overall Score: 21/25.
C#
C# is a bit out of place on the list, because it is primarily not a scripting language, but a general-purpose programming language like C, C++, Rust, Go, etc. However, unlike those, C# can also be used as a scripting language.
Embeddability: 2/5. Arguably, embedding Mono into C/C++ comes with a confusing API, and one has to go around some hoops to invoke C/C++ functions from Mono. This can be remedied by using MonoBind or SWIG. However, vanilla Mono by default offers only roundabout ways to bind C++ functions and classes to C#. To make matters worse, C# isn't interpreted or JIT'ed directly by any engine, but is rather compiled to DLL files consisting of so-called "managed assembly", which obviously needs to be recompiled for every change, so I am giving it an arguably still overly generous 2/5.
Performance: 5/5. Cannot be anything below 5/5. The biggest strength of C# is its speed: it's a statically typed compiled language similar to C and C++, and while the code gets compiled to a type of bytecode (which is interpreted/JIT'ed into machine code at runtime rather than compile time) called "managed assembly" rather than actual machine code, it still retains just about all the compile-time optimizations that C and C++ offers, producing a robust scripting language with performance only slightly worse than C++! If we ignore the overhead of JITing the managed assembly into machine code at runtime, then the performance is comparable to that of compiled C and C++ code. If I was allowed to give it 6/5, I would.
Learning curve: 3/5. Admittedly, C# is not that hard to learn, but in this aspect, is kept down by its C-like heritage. Learning C# is practically a cakewalk if you already know C, C++ or Java, but if you don't, then it's one of the harder-to-learn scripting languages.
Readability & Aesthetics: 5/5. C-like syntax, curly braces, semicolons, mwah, I love it! But besides my personal biases, C# is an easily readable programming language that allows for good organization of classes, namespaces and functions. Once again, people who already know C, C++ or Java are at a big advantage, and C++ being my preferred programming language is the main root of my bias, but overall, C# is a language that by its design promotes keeping your code neatly organized.
Ecosystem: 5/5. Just like JavaScript, I cannot give it a score any lower than 5/5. The C# language's ecosystem is practically synonymous with .NET, which is huge. It is an absolutely huge framework with extensive documentation, and millions of extensions. I repeat, this is another case of a scripting language with a 100% score in Ecosystem.
Overall Score: 20/25.
Ruby
Ruby is scripting langauge that was developed in mid-1990s Japan by Yukihiro Matsumoto. I know for a fact, that Ruby is used in some webservers, and also in RPG Maker XP, RPG Maker VX and RPG Maker VX Ace.
Embeddability: 4/5. Historically a big issue, not anymore since 2012, when mruby became a thing.
Performance: 3/5. Supposedly half the speed of Lua. At least, as of 2014. Not sure how much did things change in the last 8 years, and what is the state of affairs as of 2022.
Learning curve: 5/5. It's a scripting language used in programs (RPG Maker) primarily intended for people who cannot into programming. Go figure.
Readability & Aesthetics: 3/5. Its syntax is similar to Python and Lua, which means it's not a curly-braced language, and that's a minus for me. It uses a lot of non-alphanumeric characters in its syntax, which is somewhat weird. I'll give it a generous 3/5.
Ecosystem: 2/5. Not a terribly big ecosystem, but definitely not a nonexistent one either. As I said, scripting the RPG Maker games post-XP are done in Ruby, so plenty of code to go around.
Overall Score: 17/25.
Python
Python is arguably one of the most popular programming languages out there. It can be used standalone, and also be embedded into C/C++ applications.
Embeddability: 5/5. Embedding Python into C/C++ is a pretty simple task.
Performance: 2/5. Slower than Lua and slower than Javascript. It's almost not even fair.
Learning curve: 4/5. Takes more time to master than Lua, but just like in the case of JavaScript and C#, power comes at a cost, and Python compensates for the steeper learning curve with more features.
Readability & Aesthetics: 3/5. A similar syntax to Lua and Ruby, it is, quite obviously, not a curly-brace language, but as a plus, it mandates the use of indentation for if-statements, which at least forces programmers to produce more readable code.
Ecosystem: 5/5. Python is a widely-used programming language with a bazillion repositories on Github. It's used everywhere. Lots of Python modules. Five out of five.
Overall Score: 17/25.
Perl
Perl is an interpreted programming language created for heavyweight text-processing, especially regex magic. It can also be embedded into C/C++ applications and used as a scripting language - but the question is, would you want to?
Embeddability: 3/5. It's doable, but you're not going to like it. Especially when compared to Lua.
Performance: 2/5. Pretty damn slow, unless you're using it for what it's intended for: text-processing.
Learning curve: 4/5. Relatively easy to learn.
Readability & Aesthetics: 2/5. Meh. It has curly braces and semicolons, but Perl also made the mad decision not to include any kind of argument listing at the declaration of functions, which is crazy. This leads to difficult-to-maintain code on the long run.
Ecosystem: 4/5. An extensive amount of Perl modules have been written. Not that you're going to use any of them in a video game, but they exist.
Overall Score: 15/25.
AngelScript
AngelScript is a scripting language intentionally created with the intent of seamless integration into C++ applications, specifically video games. It is so C++-like, that it follows the same syntax and doesn't even need proxy functions to glue the C++ engine and AngelScript scripts together.
Embeddability: 5/5. Embedding AngelScript into C++ is childplay. In fact, no proxy functions are even needed to register C/C++ functions into AngelScript. How cool is that?! If I was allowed to give it 6/5, I would.
Performance: 5/5. Comparable to Lua, therefore fast.
Learning curve: 5/5. Practically zero learning required, if you already know C++ - which I assume you do, if you want to program a video game.
Readability & Aesthetics: 5/5. The language has a syntax inspired by C++, intentionally to make it easier to learn for C++ programmers.
Ecosystem: 2/5. AngelScript doesn't have the huge ecosystem that Javascript or C# have. In fact, it barely even has an ecosystem at all. I've never even heard about AngelScript, until I read about it in a completely unrelated Reddit thread. I was surprised to learn that it's actually used in quite the number of video games. Nevertheless, a niche language like AngelScript - which it sadly is - simply doesn't have anywhere near the number of IDEs / linters available, nor the abundance of StackExchange answers and experts, nor countless books on shelves or blog articles or whatnot. So why am I still giving it 2/5 instead of 1/5 or 0/5? Because it is so easy to register C/C++ functions into AngelScript - and the overall syntax is so damn similar to that of C++ - that you practically don't need a dedicated AngelScript ecosystem at all.
Overall Score: 22/25.
Tcl
Tcl is a scripting language primarily made for graphical applications.
Embeddability: 2/5. Looks fairly confusing to me, and the overall API looks messed-up.
Performance: 2/5. Comparable to Perl.
Learning curve: 3/5. I'm going to be honest here: I never used Tcl, so I am utterly unqualified to comment on this.... but I still have to give it a score, so I am going to be generous and give it a 3/5. From the looks of it, this is a language that would probably take a fairly short amount of time to learn, despite the esoteric syntax.
Readability & Aesthetics: 1/5. Looks fairly ugly to me, but I could be biased. I don't know about you, but my first reaction to this was "What the hell am I looking at?!" . That's definitely a 1/5 for me, sorry.
Ecosystem: 1/5. Tcl is a niche language, and I only know one person - besides myself - who has ever heard about it.
Overall Score: 10/25.
Your own scripting language
Let's say that you like none of the languages I listed, and decide to write your own in-house scripting language. Epic Megagames did that for Unreal by creating Unreal Script. IdSoftware made QuakeC for Quake, Bethesda made Papyrus for Skyrim and Fallout, etc.
Embeddability: 5/5. Obviously, you are writing it specifically to be embedded into your C/C++ application. It's made for that purpose.
Performance: 0/5. Unless you are a REALLY good programmer - or use some Assembly magic to micro-optimize your interpreter / Just-in-Time compiler - you cannot hope to compete with established scripting languages that have years of multiple people working on it and optimizing it. I won't beat around the bush: generally, you can expect your own, homebrewed scripting language('s interpreter) to be orders of magnitude slower than the likes of V8 and Lua.
Just for reference, Papyrus is already being pushed to its limits even in vanilla Skyrim, let alone a heavily modded loadout.
Learning curve: ?/5. You made it yourself, so it should be 5/5 for yourself, but anywhere between 0 and 5 for others.
Readability & Aesthetics: ?/5. Can be anywhere between 0 and 5, but tending towards lower values.
Ecosystem: 0/5. For obvious reasons.
Overall Score: 5/25. Anywhere between 5/25 and 15/25. For the sake of simplicity, we'll just go with 5/25.
The Final Scores in order
In order, the languages I gave a brief review about are:
AngelScript, 22/25
JavaScript, 21/25
C#, 20/25
Lua, 19/25
Ruby & Python, both 17/25
Perl, 15/25
Tcl, 10/25
Your own homebrewed/in-house scripting language, 5/25
Now, I did say that I'm not going to make a tier list video.... but I still decided to make a picture of a tier list, based on this.
But I am just a flawed and biased man. I don't really have what it takes to make an objective, unbiased scripting language tier list. I'll leave that challenge up to other people.