this post was submitted on 08 Aug 2023
6 points (100.0% liked)

Lua

331 readers
1 users here now

Lemmy community dedicated to the Lua programming language.

About Lua

Lua is a powerful and lightweight dynamically typed programming language, often embedded into applications to extend their API.

Resources

lua.org - official website
lua.org/pil - book
lua.org/manual - documentation
luarocks.org - package manager

Rules

You may read full set of rules here.
Too long; didn't read:

  1. Posts must relate to Lua
  2. Use descriptive titles
  3. Provide reproduction code
  4. Information about environment

founded 1 year ago
MODERATORS
 

Hey all,

I'm learning Lua and come from a Java background, and have been diving deep into Lua "classes".

Realizing that a Lua "class" is just some clever syntactic sugar, and lacks encapsulation, I've found that closures can act like a Java class and protect it's state. An added bonus is my muscle memory won't struggle with : vs . for function calls, a pitfall I've already wasted time debugging.

I'm new to all this though, is there anything I'm missing? Is a Lua "class" with self and : a better choice than using a closure like a class?

you are viewing a single comment's thread
view the rest of the comments
[–] samus7070@programming.dev 3 points 1 year ago

With any language or platform, don’t try to fight it’s conventions. You’ll just end up frustrated.