|
That Turkey Story posted:Speaking as someone who has worked on multiple professional games that have used lua for gameplay scripting, performance problems do get traced back to lua, through profiling, and it's really not specific to lua either. The problem for us was mainly due to creating lots of objects in lua, which all end up being dynamically allocated and garbage collected. If for every bullet or projectile you're spawning an object in lua, and all of your objects are dynamically typed and all of your function calls are on types in a dynamic language, it does cripple performance, and the worst part is, there's no simple way to parallelize the logic code that is typically implemented in a scripting language, so you end up really hurting without many options. My point is that these issues can be - and are in many games - solved by "not allocating shitloads of lua objects every frame" and "running independent scripts in separate threads" (which is actually quite easy to do) respectively. Yes, it will never be as fast as writing equivalent code in a language that compiles ahead of time to optimized machine code, but it can be "fast enough", and evidently a lot of development teams consider that a worthwhile tradeoff in exchange for faster development and increased moddability. That said, I'm certainly interested in suggestions for languages that have better performance characteristics than Lua/LuaJIT while still being threadsafe, suitable for embedding, and capable of on-the-fly script editing and loading.
|
# ? Sep 15, 2012 14:19 |
|
|
# ? Jun 5, 2024 08:05 |
|
ToxicFrog posted:My point is that these issues can be - and are in many games - solved by "not allocating shitloads of lua objects every frame" and "running independent scripts in separate threads" (which is actually quite easy to do) respectively. Also, you usually cannot simply "run independent scripts in separate threads" nor would that necessarily be a good idea or even fix anything to begin with. First, we're talking about general gameplay code that cannot easily be run concurrently with other scripts (and other code does run at the same time: C++ code runs in parallel occupying the cores that it can, but the lua is actually the bottleneck). Simply running certain scripts concurrently does not scale well, either, even if it were an actual option in our case, which it is not. ToxicFrog posted:Yes, it will never be as fast as writing equivalent code in a language that compiles ahead of time to optimized machine code, but it can be "fast enough", and evidently a lot of development teams consider that a worthwhile tradeoff in exchange for faster development and increased moddability. ToxicFrog posted:That said, I'm certainly interested in suggestions for languages that have better performance characteristics than Lua/LuaJIT while still being threadsafe, suitable for embedding, and capable of on-the-fly script editing and loading.
|
# ? Sep 15, 2012 17:47 |
|
Angelscript is basically what you're talking about. I don't know what the performance is like though. I do know that this is what most of the gameplay code of Star Ruler is written in.
|
# ? Sep 15, 2012 18:17 |
|
Zombywuf posted:This is the real horror. When enabled, Squirrel uses wchar_t for its strings. I haven't tried that feature since I rely on UTF8, but my experience with Squirrel has been good. Toady fucked around with this message at 20:44 on Sep 15, 2012 |
# ? Sep 15, 2012 20:42 |
|
Suspicious Dish posted:Their code contribution process is pasting code in wordpress comments. Just want to point that out. It's even better when you look at their github page. You have to build their website to work on anything.
|
# ? Sep 15, 2012 22:58 |
|
Huh, apparently the dude who made that phpjs abomination is the same guy who made CakePHP (or at least the repo for it is on his account). Whattya know.
|
# ? Sep 15, 2012 23:23 |
|
Optimus Prime Ribs posted:Huh, apparently the dude who made that phpjs abomination is the same guy who made CakePHP (or at least the repo for it is on his account). Whattya know. I think it's just a fork that he made to include some changes to the source.
|
# ? Sep 15, 2012 23:25 |
|
Ah, so it is. I missed the Forked from renansaddam/cakephp part. That would have been too perfect.
|
# ? Sep 15, 2012 23:27 |
|
That Turkey Story posted:If you have to bend over backwards to avoid allocating objects (which is not as trivial as it sounds), you're complicating things.
|
# ? Sep 16, 2012 00:02 |
|
Plorkyeran posted:WoW UI modders came up with a library that made this fairly easy -- by switching to manual memory management and clearing and reusing tables rather than allocating new ones. The whole thing was hilariously slow compared to the amortized cost of lua's garbage collector, but triggering the GC during combat could lock up the UI for multiple seconds. Yeah, when you have to manually manage memory in a dynamically typed language with GC, I really start to question the benefits of using that language as a scripting language.
|
# ? Sep 16, 2012 02:29 |
|
Plorkyeran posted:WoW UI modders came up with a library that made this fairly easy -- by switching to manual memory management and clearing and reusing tables rather than allocating new ones. The whole thing was hilariously slow compared to the amortized cost of lua's garbage collector, but triggering the GC during combat could lock up the UI for multiple seconds.
|
# ? Sep 16, 2012 10:58 |
|
In what world would someone even learn to write code this way?:C++ code:
I was paid to *fix* this application since the company running it changed some of the hardware it controlled (manufacturing) to a slower profile and the whole thing broke. And by fix, I mean "apply 2 regexp replaces and it's done".
|
# ? Sep 16, 2012 11:26 |
|
My first thought was some sort of COM MTA/STA threading issue, but still, why would you sleep the current thread instead of joining the created one?
|
# ? Sep 16, 2012 11:31 |
|
FrantzX posted:My first thought was some sort of COM MTA/STA threading issue, but still, why would you sleep the current thread instead of joining the created one? Apparently it had been "intermittently broken" for years, and they only decided to get it fixed now that it was completely broken. For reference, this was a single-run application that returned machinery to a default position on-demand (usually when unloading/loading materials). Single-threaded, one operation at a time. It's possible the original coder copy/pasted the code from another more complicated package and didn't understand the context, I guess. The Gripper fucked around with this message at 11:47 on Sep 16, 2012 |
# ? Sep 16, 2012 11:42 |
|
That's real time programming that is.
|
# ? Sep 16, 2012 12:23 |
|
PrBacterio posted:Wait, Lua doesn't have an incremental GC? I does, that sounds like it's more a problem with WoW than anything else. Edit: vv Welp SavageMessiah fucked around with this message at 15:41 on Sep 17, 2012 |
# ? Sep 16, 2012 15:11 |
|
PrBacterio posted:Wait, Lua doesn't have an incremental GC?
|
# ? Sep 16, 2012 16:04 |
|
DStecks posted:The typo had no tag. This typo had been undetected and part of a program that ran every day, and somehow never caused an abort, in 20 years. It's a funny business.
|
# ? Sep 16, 2012 22:16 |
|
It's time for another round of God gently caress C Forever, starring an associate who will remain nameless and a paraphrase of his code which contains some integers:code:
For bonus points, what's the reasoning for the right->left evaluation? http://codepad.org/HxSUpg3L
|
# ? Sep 17, 2012 02:37 |
|
So... the coding horror is the upcoming buffer overflow? Is it that he's using a singleton? ???
|
# ? Sep 17, 2012 02:47 |
|
quote:For bonus points, what's the reasoning for the right->left evaluation? Probably because the order of evaluation of parameters is undefined!
|
# ? Sep 17, 2012 02:51 |
|
It's that order of evaluation of the arguments isn't guaranteed by the spec? A guess at the right to left eval would be that's the order they get put on the stack for the call to printf?
|
# ? Sep 17, 2012 02:51 |
|
Yeah, I thought order of eval isn't specified in C, so you're dealing with undefined stuff there. E: Also I am a coding horror: I've done gone and liked node.js. Wozbo fucked around with this message at 03:03 on Sep 17, 2012 |
# ? Sep 17, 2012 03:00 |
|
I thought each of those commas was a sequence point?
|
# ? Sep 17, 2012 03:32 |
|
Suspicious Dish posted:I thought each of those commas was a sequence point?
|
# ? Sep 17, 2012 03:36 |
|
shrughes posted:So... the coding horror is the upcoming buffer overflow?
|
# ? Sep 17, 2012 03:37 |
|
The RNG from Doom was roughlyC++ code:
Blotto Skorzany fucked around with this message at 05:48 on Sep 17, 2012 |
# ? Sep 17, 2012 03:57 |
|
"Making assignment and declaration two different "things" is a huge mistake. It leads to the unexpected global problem in JavaScript, makes your code more verbose, is a huge source of confusion for beginners who don't understand well what the difference is, and is completely unnecessary in a language." See if you can guess what cool language this is in a thread about.
|
# ? Sep 17, 2012 05:00 |
|
Otto Skorzeny posted:The RNG from Doom was roughly A period of 256 is a bit short, but that seems fine for a non-crypto non-statistical source of psuedorandomness.
|
# ? Sep 17, 2012 05:32 |
|
Jabor posted:A period of 256 is a bit short, but that seems fine for a non-crypto non-statistical source of psuedorandomness. I was using it to demonstrate that the concept behind what bucketmouse posted isn't itself bonkers.
|
# ? Sep 17, 2012 05:47 |
|
Gigantic Slut Man posted:"Making assignment and declaration two different "things" is a huge mistake. It leads to the unexpected global problem in JavaScript, makes your code more verbose, is a huge source of confusion for beginners who don't understand well what the difference is, and is completely unnecessary in a language." "It's okay that variable shadowing silently breaks things because with TDD bugs don't happen"
|
# ? Sep 17, 2012 06:24 |
|
Plorkyeran posted:"It's okay that variable shadowing silently breaks things because with TDD bugs don't happen" How does variable shadowing silently break things?
|
# ? Sep 17, 2012 06:28 |
|
Suspicious Dish posted:How does variable shadowing silently break things? code:
edit: Oh, I think he may have meant "lack of variable shadowing silently breaks things," because that's how i read it before making this reply
|
# ? Sep 17, 2012 06:40 |
|
Gigantic Slut Man posted:
edit: I still agree that what you originally quoted is silly as hell. Xenogenesis fucked around with this message at 14:30 on Sep 17, 2012 |
# ? Sep 17, 2012 14:15 |
|
Xenogenesis posted:I assume CoffeeScript, like JavaScript, is lexically scoped, so that won't break anything? Or are you saying this is a problem because an external library might do something like window.foo = 42? (In which case, the problems are... bigger...) CoffeeScript is lexically scoped, but you don't have access to var, so you can't avoid changing the value of a variable from the outer scope other than by trying to make a unique variable name. If your function finds itself in a scope with foo, and you've named a variable foo, you're modifying the external foo. There's no declaration syntax available, only assignment with implicit declaration if the variable doesn't already exist.
|
# ? Sep 17, 2012 14:44 |
|
Isn't that completely mitigated by using proper namespacing and not reusing variable names in different scopes? I'm not a JavaScript or CoffeeScript developer so that could be entirely wrong, but I think the reason nobody noticed that glaring flaw until now is that it isn't actually one.
|
# ? Sep 17, 2012 17:22 |
|
Javascript doesn't have namespaces. It was a recommendation for the most recent ecmascript standard but MS fought to have it removed.
|
# ? Sep 17, 2012 17:25 |
|
Otto Skorzeny posted:Javascript doesn't have namespaces. It was a recommendation for the most recent ecmascript standard but MS fought to have it removed. I don't mean proper namespaces, just self-executing functions (in the browser), exports (on the server) and as few globals as possible. It doesn't matter if foo is defined by another library or your own code beforehand because it should be package.foo externally and you shouldn't reuse variable names internally.
|
# ? Sep 17, 2012 17:29 |
|
xtal posted:I don't mean proper namespaces, just self-executing functions (in the browser), exports (on the server) and as few globals as possible. It doesn't matter if foo is defined by another library or your own code beforehand because it should be package.foo externally and you shouldn't reuse variable names internally. There's no standard package system in JavaScript either.
|
# ? Sep 17, 2012 20:25 |
|
|
# ? Jun 5, 2024 08:05 |
|
xtal posted:I don't mean proper namespaces, just self-executing functions (in the browser), exports (on the server) and as few globals as possible. It doesn't matter if foo is defined by another library or your own code beforehand because it should be package.foo externally and you shouldn't reuse variable names internally. It seems like you're under the misapprehension that Javascript is related to Java somehow. Javascript doesn't have packages or namespaces. It's one giant namespace. You will be assigning to any variable in any scope that you are inside of if it has the same name (in CoffeeScript -- Javascript has shadowing with var)
|
# ? Sep 17, 2012 20:33 |