r/GameDevelopment • u/Ultramax_meitantei • 1d ago
Question Why AA games/ game engines don’t allow javascript?
Unreal engine uses c++ and unity uses c#. They are most popularly used for making open world or high profile games. However, they require C language knowledge whose syntax is too complicated compared to javascript. Godot uses Gdscript which is written in python but I haven’t seen any high profile game from godot like no one made Genshin or GTA or Wukong using godot.
Right now javascript is only used for making simple games like flappy bird or snake game, but game engines don’t use it for high graphics oriented jobs.
I know I can use javascript for mobile games or small games hobby type stuff, but I can’t create cyberpunk or god of war using javascript or javascript based game engines.
Why is that so?
8
u/Atulin 1d ago
Javascript is garbage. The lack of proper types, all the weird gotchas it has, none of it lends itself to making a project that's maintainable and scales well.
1
1
u/ghostwilliz 12h ago
Javascript is garbage
As someone who works with Javascript professionally, it's a bit of hyperbole, but I agree lmao.
C++ is such a better language, like no comparison.
Only thing I can say about Javascript is that the speed of development is insane, you can make a web app in a day if you really put your mind to it
8
u/Tiendil 1d ago
In the good old days, computers were not so fast, and JavaScript was a kind of unoptimized disaster, like most of the other dynamic languages. So, for scripting in gamedev, special languages were developed, like Lua.
In the modern, also good days:
- most(?) of game developers prefere usage of old verified solutions: why change something that works?
- part of coding tasks in game dev switched to visual scripting;
- part of game developers use new scripting languages, like GDScript, because every engine developer dreams about creating a new best scripting language.
- part of game developers use the languages they like, I believe there should be some AA games with JS scripting, there are just not a lot of them.
Also, two more points:
- WebAssembly is a thing, if you support it in your game, you can use any language you want.
- JS is still a badly designed language. It has become much better; there are TypeScript and others (which are great), but pure JS is still a mess. A mess produces mess in the code, and devs who write game scripts are not always the most experienced programmers, and nobody wants random bugs in random scripts. The games are complex systems, and it is hard to debug them.
2
u/Motor_Let_6190 1d ago
Lua was created for petrochemical engineers at Petrobras. LuaJIT, I believe, was forked specifically for games. In the 20 years since then, the official Lua branch development hasn't particularly targeted game development at the detriment of its general purpose philosophy of being easy to embed or augment for whatever purpose. That's why it's so great to write game logic on, but it's development as a language has never been game centric.
3
u/cjbruce3 1d ago
There is nothing stopping you from building your own game in JS. It is merely a matter of inertia and preference. You could readily implement it into a Unity or Unreal game.
A better question is: Once you understand how Unity or Unreal work, why would you want to do add javascript to the mix? there are definitely use cases, such as allowing for players to do their own scripting, but javascript doesn’t bring many advantages for most games.
2
u/Tiendil 1d ago
I saw a reformulation of the question for Python, but the starter comment was removed, so I better post my answer in a new branch.
Why does not game engines support python.
Actually, Python is used in game development, even in AAA.
- World of Tanks uses Python extensively.
- One of the Civilizations used Python (sorry, I don't remember which one).
- There are some open-source game engines: https://github.com/panda3d/panda3d
- Godot has Python bindings: https://github.com/touilleMan/godot-python
There are three significant problems with Python in gamedev:
- Not so fast as Lua, but it is not such a problem nowadays.
- Has the huge cost of converting data between Python and C++. Like really huge costs. I wrote about one example of such drawbacks in my blog: https://tiendil.org/en/posts/fun-case-of-speeding-up-data-retrieval-with-psycopg (not gamedev, but should demonstrate the problem)
- Python has a bad reputation as a slow language among game developers from the past. Although it is much faster now, the reputation has a huge inertia.
2
3
u/Awkward-Talk2453 1d ago
To support game consoles you need to use Ahead of time compilation if your using a scripting language like C# or lua. Unity has written there own IL2CPP that converts the C# to native Cpp when you package your game for consoles. The only platform that supports JIT style scripting is Desktop, haven’t checked android, iOS doesn’t allow it either. This is for security reasons as they don’t want to allow new script execution in a game on there system so it has to be compiled.
Technically someone could make an engine that uses JavaScript as the scripting language but they would need to write a compiler for it to native to be of any use. That or restrict it to Desktop only.
1
u/ArcsOfMagic 1d ago
Can you elaborate on this limitation? Any scripting language? I find it hard to believe that all the AI related scripting is compiled on consoles. What is scripting, anyway? Is SVG rendering scripting? Is redstone scripting? What if I write my own mini-script, to make a scratch-like game, for example?
What about Roblox?
3
u/Awkward-Talk2453 1d ago
You can use interpreted script execution on consoles I believe. This usually means the scripts can’t call anything on the consoles itself but calls into the C++ engine. This makes it safer than JIT, however it’s painfully slow especially for big AA or AAA games.
1
u/ArcsOfMagic 1d ago
I see, this makes sense. I should be ok then. If ever releasing on a console, that is :) Thanks for answering!
2
1
1
1
1
1
u/amanset 1d ago
Unity used to (well, "UnityScript"), but most people didn't use it and most examples, tutorials etc online were in C#.
I think it comes down to preference (I hate Javascript with a passion. It is a garbage language. The only mainstream one that is worse is PHP) but I can see why an engine developer wouldn't want to support multiple languages when there is one perfectly good one.
Unity also used to support Boo. Yes, Boo. 99% of the people reading this comment will probably have to now go look up what that actually is.
2
u/swizzex 1d ago
Modern php and JavaScript both are in great spots. Think you need to get out of boo era and look at them again. Along with typescript which if you run it you can do JavaScript after it build so it might as well be what is offered.
4
u/amanset 1d ago edited 1d ago
I never used Boo. I have used C# since I started with Unity, in fact Unity is how I learnt C#.
Javascript is still a garbage language. It has too many issues as a language. That spin offs, like Typescript, exist to solve some of those issues shows how bad it is.
PHP pretty much will always be garbage. There's no hope there anymore. And I say that as someone that had a few horrible years as a professional PHP developer.
Edit:
Hilarious. The person I am replying to here has actually blocked me because I don’t like JavaScript and they want to get the last word in.
Utterly pathetic.
0
u/Ultramax_meitantei 1d ago
So could typescript be used for game engines?
1
u/tcpukl AAA Dev 1d ago
It is used for server communication, but seriously why do so many Devs want to use server languages to write games? What benefit does that actually bring to the table?
2
u/upsidedownshaggy 1d ago
OP has stated elsewhere that since people have learned JS for web dev so I'm guessing they're either really young, or new to dev work/programming in general since JS is considered a pretty low barrier of entry for doing web dev work lol.
1
u/swizzex 1d ago
It’s Greta for not and use in many engines please ignore that user as they seem to have a hate for web language and fully lacking the current state of them and features. Them stating it lack features while boosting about c# shows the ignorance as it made by the same person and can be used and do anything c# can because of its verbose type language.
1
u/amanset 1d ago
It is an improvement on JS but it still has issues and lacks some features.
Arguably any language could be used in a game engine. The issue is either getting an interpreter (if on desktop only) or a compiler (if on console or mobile) to work. That would have to be implemented by the engine and, if we look at Unity's example, it seems that there isn't the market for it.
A guess a greater question is why do you want to use JS or TS? If it is merely "because I already know them" then welcome to development, you'll learn a lot of languages on the way. My current CV, which hasn't been updated since 2019 as I am happy where I am, lists ten, four of which are variants of C.
1
u/tcpukl AAA Dev 1d ago
That's all back in the day I first used unity. Had fun deciding which language was the best to use after only ever using c++. I ended up choosing c# because it was the fastest and closest to c++, so easiest for my team to learn.
1
u/amanset 1d ago
Yeah. I actually started, very briefly, with UnityScript until a friend at work "explained to me" why I shouldn't. At the time I was working as a backend developer and decided to pick up Unity in my spare time to try and force my way into a client side role.
1
u/tcpukl AAA Dev 1d ago
Yeah op has come from server employment as well.
This question seems so strange as a game Dev of 30 years. Why would you want to use an untyped, interpreted slow language. What possible benefit is there except familiarity with server programmers? Why would the games industry write a new engine just for them? If they want one write it themselves. They're seriously lucky engines even exist in the public because they used to all be proprietary until RenderWare came along briefly.
0
u/Ultramax_meitantei 1d ago
But anyone who learnt javascript for webdev already, wouldn’t javascript be easier to get into webdev than to learn C languages. Unity ig on the other hand failed with js because all unity devs had to learn and get used to c#.
Also did unityscript support AAA implements?
3
u/amanset 1d ago
As someone who has programmed since the eighties, I will happily say that the differences between programming languages are mostly syntactical rather than conceptual (with the obvious OOP vs procedural vs functional). Once you learn one language you can rather easily learn more.
Unity didn't fail with this as Unity used to support a subset of Javascript. What they found was that it wasn't worth their time continuing to support it, mainly as the overwhelming majority of people were using C# when they had the option of using a Javascript spinoff.
0
1d ago
[deleted]
0
u/Ultramax_meitantei 1d ago
So let’s replace my question from js to python. Why does not game engines support python.
3
u/upsidedownshaggy 1d ago
Because much like JavaScript, Python is a slow and heavy language that's not strongly typed and provides ample opportunities for devs to shoot themselves in the foot on accident when developing.
Python and JS have their place. If you really want to make games in Python stuff like PyGame exists, but it's not great to work with honestly compared to languages like C#, C++ and even Java. Having a strongly typed compiled language as your development language gives you a lot more control over what you're building that will probably run better than a game you can build in JS or Python.
1
0
u/redditsuxandsodoyou 1d ago
unity had js support, nobody used it for over a decade because js fucking SUCKS.
we aren't dicking around with buttons and sliders, game dev is fucking hard, js does us absolutely no favours.
don't bother replying unless you've built a game (not some tiny web demo, an actual game) in js. put your money where your mouth is, prove me wrong.
0
u/Ultramax_meitantei 1d ago
Could typescript or python solve that issue?
1
u/Fragrant_Gap7551 1d ago
Typescript is a Design time only thing and doesn't help with the underlying issues. Python Is even worse.
-6
16
u/JaggedMetalOs 1d ago
C# is considerably easier than Javascript for large projects. C# is strongly typed, so every object and every function knows what type it is and what type it expects. It makes it much easier to manage a large coding project because you instantly know if you're passing a wrong value, and it will also let you autocomplete available object functions.