# Lua high performance examples

**URL:** <https://forum.defold.com/t/lua-high-performance-examples/79039>\
**Category:** Questions\
**Created:** [December 3, 2024, 7:10am UTC](https://forum.defold.com/t/lua-high-performance-examples/79039 "2024-12-03T07:10:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![errorstrike](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/errorstrike/32/35094_2.png) [@errorstrike](https://forum.defold.com/u/errorstrike)\
**Post date:** [December 3, 2024, 7:10am UTC](https://forum.defold.com/t/lua-high-performance-examples/79039/1 "2024-12-03T07:10:09Z")

</div>

Hello. I am not a professional programmer. I am just an enthusiast. So, sometimes my Lua code works not smoothly especially in HTML5.  
So, which is faster (more smooth) Lua or Teal?  
Google and Youtube give about Lua significantly less information than about other programming languages.  
If you know any web-resource about correct high-performance style of coding in Lua, give me links, please!

---

<div class="post-metadata">

**Author:** ![ackle](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/a/13edae/32.png) [@ackle](https://forum.defold.com/u/ackle)\
**Post date:** [December 3, 2024, 7:25am UTC](https://forum.defold.com/t/lua-high-performance-examples/79039/2 "2024-12-03T07:25:35Z")

</div>

My understanding is that Teal compiles into Lua, so there should be no performance difference. As for improving the performance of Lua code, this article / book chapter from the Lua developers is a good place to start: [https://www.lua.org/gems/sample.pdf](https://www.lua.org/gems/sample.pdf)

---

<div class="post-metadata">

**Author:** ![Alex\_8BitSkull](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/alex_8bitskull/32/5424_2.png) [@Alex\_8BitSkull](https://forum.defold.com/u/Alex_8BitSkull)\
**Post date:** [December 3, 2024, 8:48am UTC](https://forum.defold.com/t/lua-high-performance-examples/79039/3 "2024-12-03T08:48:52Z")

</div>

I also agree that it’s unlikely that you’ll derive performance benefits by switching language, it’s almost certainly down to your coding practices.

Here is a good thread with some neat tricks:

> [@Lua and Luajit Best Practices?](https://forum.defold.com/t/lua-and-luajit-best-practices/68405/2):
>
> Luajit projects useful for learning interop: UFO Excellent examples of luajit ffi Lua for Windows: A huge array of interop libraries for windows. You can make almost any application using these. These projects provide a huge array of samples and libraries for people to learn Lua and Luajit with. Highly recommended to new Lua users.

Generally speaking though I think a lot of benefit will come from practice. Start using the profiler if you aren’t already!

---

<div class="post-metadata">

**Author:** ![aglitchman](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/aglitchman/32/19432_2.png) [@aglitchman](https://forum.defold.com/u/aglitchman)\
**Post date:** [December 3, 2024, 9:31am UTC](https://forum.defold.com/t/lua-high-performance-examples/79039/4 "2024-12-03T09:31:08Z")

</div>

> [@errorstrike](#):
>
> So, sometimes my Lua code works not smoothly especially in HTML5

HTML5 uses Lua 5.1 interpreter, not LuaJIT. That’s the reason.

> **[Lua versions - Lua programming in Defold](https://defold.com/manuals/lua/#lua-versions)**
>
> The Defold engine has the Lua language embedded for scripting. Lua is a lightweight dynamic language that is powerful, fast, and easy to embed. It is widely used as a videogame scripting language. Lua programs are written in a simple procedural...
