Rust + Lua - Why & Full Code Examples

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 ธ.ค. 2024

ความคิดเห็น • 34

  • @camwoo1233
    @camwoo1233 3 วันที่ผ่านมา +11

    Nice video! Luau is a more modern version of Lua (has typings, faster, etc) that's also supported by mlua. Definitely a great thing to consider for those looking at this space!

    • @JeremyChone
      @JeremyChone  3 วันที่ผ่านมา +2

      Yes, Luau can be a good choice. It's great that mlua allows us to choose the engine so easily.
      By the way, for devai.run, I am using Lua 5.4, but I might switch to Luau. They seem to have drifted a little, so I wanted to play it "conservative."

    • @binary132
      @binary132 2 วันที่ผ่านมา +1

      That’s not how I would characterize Luau. Luau is a fork, not a “more modern” Lua - it has support for certain things like timing our calls that regular Lua doesn’t have, that are useful for Roblox. But it’s not standard Lua, there are differences. And I don’t think Luau scripts will be guaranteed to run on LuaJIT.

    • @binary132
      @binary132 2 วันที่ผ่านมา

      timing out*

    • @JeremyChone
      @JeremyChone  2 วันที่ผ่านมา +2

      Yes, this was my impression as well-a fork that has drifted by now. This is why the standard Lua 5.4 is a good starting point, and then, depending on the need, adjustments can be made.
      Big kudos to the mlua developers for providing such a simple way to choose what we want to run with.

  • @fabricehategekimana5350
    @fabricehategekimana5350 2 วันที่ผ่านมา +4

    Wow thank you, I was asking myself how I could embedd lua scripts with Rust ! This is all I needed to know ! I want to integrate teal script (that will compile to lua) so people could have a typed scripting language. Thanks again !

  • @letronix6243
    @letronix6243 2 วันที่ผ่านมา +1

    Thank you very useful. I always wanted to someday add lua to my game engine and I now understand the workflow.

  • @GouthamGunasekaran
    @GouthamGunasekaran 3 วันที่ผ่านมา +6

    Hello sir I completed your rust book programming playlist.... I'm from embedded c background, how can I use Rust programming in Embedded devices like ESP32 microcontrollers...does rust programming support popular microcontrollers...please make videos on how to use in microcontrollers...thanks for knowledge your sharing....your videos are really valuable information ❤.

    • @drweshnaw3365
      @drweshnaw3365 3 วันที่ผ่านมา +3

      It's been a second since I've touched this space; but rust has a ecosystem around a crate called:
      'embassy-rs' which when I tried it had OK documentation; and I'm sure it has gotten better, it supports most common micro controllers (and it was designed to be a framework first, so porting to a new micro-controller isn't impossible for a dedicated single person); though the more obscure you go the more documentation starts to be just reading function definitions and crate source code

  • @emvdl
    @emvdl 3 วันที่ผ่านมา +3

    Thanks @jeremy 👍

  • @irlshrek
    @irlshrek 3 วันที่ผ่านมา +5

    this is so cool!!!

  • @cno9984
    @cno9984 วันที่ผ่านมา

    I think that embedding WASM would be a great choice as well. It's sandboxed, fast, lightweight and it can be compiled from many languages (e.g. C++ or Rust).

    • @JeremyChone
      @JeremyChone  23 ชั่วโมงที่ผ่านมา +1

      @cno9984 WASM would not serve the same purpose, as the user would have to compile to it, usually from a strongly typed/compiled language.
      With scripting, the user just writes and provides the script, and the application can take it from there.
      Both are good at what they do, and it’s true that they both allow external code to run inside the app.

  • @kamertonaudiophileplayer847
    @kamertonaudiophileplayer847 2 วันที่ผ่านมา +1

    Awesome! Thanks.

  • @jeffg4686
    @jeffg4686 3 วันที่ผ่านมา

    Nice!
    We need to get full python interface eventually.
    I know we can do it via this type of way, but make it able to be python only by embedding this functionality into the engine.
    We need to draw that crowd - python is massive now.

    • @JeremyChone
      @JeremyChone  2 วันที่ผ่านมา

      Yes, Python would be nice, but integrating it is complex and heavy.
      Two main options are:
      1) [PyO3](pyo3.rs/) - popular but heavy.
      2) RustPython - a pure Rust interpreter, still experimental.
      Embedding Python is challenging due to its reliance on native libraries like NumPy, which introduces significant complexity.
      Using a lighter scripting language like Lua simplifies runtime and app complexity. While developers need to learn Lua, it offers high net value and allows calling other languages like Python or Node.js when needed.
      For apps like Deno, embedding V8 makes sense, as JS was the end goal, but Lua suits simpler use cases better.

    • @jeffg4686
      @jeffg4686 วันที่ผ่านมา

      @@JeremyChone -thanks, makes sense. I was just thinking in terms of aligning Bevy with a highly popular scripting language. Would make people more interested in Bevy and likely get more development going on here from big companies donating in plugins. It's practically hidden at this point. I guess that's why godot likely did their whole gdscript thing instead of python.

  •  วันที่ผ่านมา

    whats your thought on rai ?

    • @JeremyChone
      @JeremyChone  วันที่ผ่านมา +1

      Rhai is a good technology, and it is pure Rust, which has some benefits. However, I think the net value of Lua is greater.
      Here is a quick pros/cons list:
      *Rhai*:
      - pros:
      Pure Rust, no unsafe code
      Relatively simple to use
      - cons:
      Relatively unknown, medium size of 3 MB
      AST Walker (not a full scripting engine) does not support async.
      *Lua*:
      - cons:
      C integration, many unsafe aspects
      (but mitigated by engine maturity and library reliability)
      - pros:
      Relatively well-known, super small at 300 KB,
      Full scripting engine with async support and many features.
      Super simple to use and embed (can handle bidirectional calls)
      Supports sending (with a cost, but very convenient)
      Overall, I think that Lua is a better choice for its size, simplicity, popularity, and full, mature scripting capability.

    •  19 ชั่วโมงที่ผ่านมา

      🙏

  • @mahabat23
    @mahabat23 3 วันที่ผ่านมา

    what is the code editor, xcode?

    • @JeremyChone
      @JeremyChone  3 วันที่ผ่านมา

      vscode, with Google Materials + Custom Icons & Colors.

  • @danser_theplayer01
    @danser_theplayer01 2 วันที่ผ่านมา

    I wonder if javascript can be embedded like that or if it's just too "big and all powerful".

    • @JeremyChone
      @JeremyChone  2 วันที่ผ่านมา +1

      (copied reply for convenience)
      JavaScript is an option, but it is heavy and intrusive for applications. While Deno has made great strides in simplifying this, it is still orders of magnitude more complex and heavier than Lua.
      Lua has the advantage of clear expectations-developers don't expect to "npm install" or "pip install," keeping scripting simple and self-contained.
      In devai.run, I let developers use `utils.cmd.exec(...)` to call Python, Node, Bun, etc., and retrieve results. By controlling the `utils.cmd.exec` calls, I ensure they remain constrained within the application runtime.

  • @eyz-4
    @eyz-4 2 วันที่ผ่านมา

    interesting. unrelated, have you ever used nifs with elixir and rust? a crate called rustler that's very interesting

    • @JeremyChone
      @JeremyChone  2 วันที่ผ่านมา

      It does look interesting, but I have not tried it.
      There are many other alternatives, such as full JS, Python, or Rust-based languages like Rhai or Rune, but Lua has a high net value when simple scripting is needed.

  • @أميرالمؤمنينبنمحمدأكرم
    @أميرالمؤمنينبنمحمدأكرم 3 วันที่ผ่านมา +1

    Use case please

    • @fabiand
      @fabiand 3 วันที่ผ่านมา +4

      I mean he explained the usecase pretty well in the beginning of the video

    • @JeremyChone
      @JeremyChone  3 วันที่ผ่านมา +1

      devai.run is a great usecase for this.

  • @broom7294
    @broom7294 3 วันที่ผ่านมา

    now do javascript 😁

    • @kallebysantos5167
      @kallebysantos5167 3 วันที่ผ่านมา

      You can use Deno by deno_core and other extension crates

    • @JeremyChone
      @JeremyChone  2 วันที่ผ่านมา +3

      JavaScript is an option, but it is heavy and intrusive for applications. While Deno has made great strides in simplifying this, it is still orders of magnitude more complex and heavier than Lua.
      Lua has the advantage of clear expectations-developers don't expect to "npm install" or "pip install," keeping scripting simple and self-contained.
      In devai.run, I let developers use `utils.cmd.exec(...)` to call Python, Node, Bun, etc., and retrieve results. By controlling the `utils.cmd.exec` calls, I ensure they remain constrained within the application runtime.

  • @surplusking2425
    @surplusking2425 2 วันที่ผ่านมา

    C++ + Go is much better than Rust + Lua

    • @JeremyChone
      @JeremyChone  2 วันที่ผ่านมา +1

      Not sure if those pairs compare.