this post was submitted on 14 May 2025
418 points (99.5% liked)

PC Gaming

10995 readers
628 users here now

For PC gaming news and discussion. PCGamingWiki

Rules:

  1. Be Respectful.
  2. No Spam or Porn.
  3. No Advertising.
  4. No Memes.
  5. No Tech Support.
  6. No questions about buying/building computers.
  7. No game suggestions, friend requests, surveys, or begging.
  8. No Let's Plays, streams, highlight reels/montages, random videos or shorts.
  9. No off-topic posts/comments, within reason.
  10. Use the original source, no clickbait titles, no duplicates. (Submissions should be from the original source if possible, unless from paywalled or non-english sources. If the title is clickbait or lacks context you may lightly edit the title.)

founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 2 points 5 hours ago

Correct, but said implementation will be orders of magnitude slower than implementing at a lower level…

"order of magnitude" typically means 10x. A reasonable Lua implementation of rigidbody physics isn't going to be 10+ times slower than an equivalent C++ version. C++ provides a lot more tools for optimization than Lua, so you're unlikely to find a truly apples-to-apples comparison showing the difference between a Lua and C++ that isn't a benchmark of the particular algorithms in the implementations.

To be clear, I'm not saying Lua is faster or as fast as C++, just that you're making it sound as if Lua is too slow for something like this. I know this isn't a programming community, but we're talking about programming languages, so I feel compelled to point stuff like this out.

meaning you cannot handle lots of objects, you can only handle a few, and only with a few players if this is all networked… otherwise you get massive physics calculation innacuracy, terrible performance spikes, crashes, and if networked, server hangs/stalls, huge desync, etc.

None of this is true.

... than just actually having direct access to them… but that would be the case with any language ...

It is specifically a problem with embeddable languages like Lua because they're limited by what is exposed to its VM and how. In the context of modding physics into Morrowind, it's possible that not everything you'd need is cleanly exposed through Lua (which afaik is implemented with a third party plugin and not natively supported).

Not saying its impossible, just saying it… I’ve never seen anyone pull off an efficient and accurate 3D physics engine in Lua, untill now with this LuaJIT implementation.

At the risk of sounding like a dick, I think you're bullshitting. I doubt you've ever seen any physics engine implemented in Lua before, much less benchmarked them or evaluated them for their "efficient" and "accurate" qualities (which are meaningless terms). Lua physics engines certainly exist, but they're mostly gimmicks interesting to developers to study/learn as there aren't many real world use cases for something like that. There are few reasons to choose that over a C++ physics library, not because Lua is slow, but simply because C++ is faster, and the libraries are typically much more mature and feature-rich.