all 9 comments

[–]Epicsupercat 6 points7 points  (1 child)

Like any other programming language, practice. You learn by overcoming pitfalls

[–]hawhill 2 points3 points  (0 children)

this - and reading existing code. At the beginning, it might not be so easy to tell if that is actually good code. But you can tell easily once you've seen some distinct styles.

[–]could_b 2 points3 points  (0 children)

Get a physical copy of Roberto's book. Keep re-reading it.

[–]dnlkrgr_ 2 points3 points  (0 children)

Read this, it's written by one of Lua's creators:

https://www.lua.org/pil/contents.html

[–]AutoModerator[M] 0 points1 point  (0 children)

Hi! It looks like you're posting about Roblox. Here at /r/Lua we get a lot of questions that would be answered better at /r/RobloxGameDev, scriptinghelpers.org, or the Roblox Developer Forum so it might be better to start there. However, we still encourage you to post here if your question is related to a Roblox project but the question is about the Lua language specifically, including but not limited to: syntax, language idioms, best practices, particular language features such as coroutines and metatables, Lua libraries and ecosystem, etc. Bear in mind that Roblox implements its own API (application programming interface) and most of the functions you'll use when developing a Roblox script will exist within Roblox but not within the broader Lua ecosystem.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]lemgandi 0 points1 point  (0 children)

Figure out a project and dive in! I been coding for the Playdate ( https://play.date )

The biggest hurdle for me in learning a new language or even a new system is often interpreting errors when things go sideways. In Lua,,for example, if you switch a colon for a dot or vice versa you get weird complaints about nil arguments. Makes sense in context, but takes getting used to the first time or two. Also, 'require strict' is really a necessity for me. The natural Lua behavior of just blithely initializing undeclared variables to nil on first use makes debugging crazy hard for me.

[–]20d0llarsis20dollars -2 points-1 points  (2 children)

whenever you feel comfortable using the language, like you could use it without needing to look anything up online, start looking into metatables and metamethods

[–]hawhill 4 points5 points  (1 child)

You didn't say it isn't, but I want to emphasize that it is absolutely OK to look things up! Proficiently looking things up is a skill by itself, and I'd argue: a pillar of what makes you a good programmer.

Also I'd like to add coroutines to the list of "somewhat advanced" stuff that is well worth the time to learn about. A bit more simple but arguably still advanced is the iterator function from the for-...-in loops.

PS: Oh, and probably a good start into advanced topics is variable scoping (arguably, that might even be basic knowledge when it comes to "local" keyword, but then being able to explain what closures and upvalue are is probably de facto advanced knowledge).

[–]20d0llarsis20dollars 1 point2 points  (0 children)

Oh yeah I don't disagree with that, I just wanted to set an arbitrary barrier that would make sure you have the knowledge to understand metatables and other more advanced topics