Lua is weird...

min read

At 175 words per minute.

2024-09-16 Back to posts

Lua logo

Let me explain myself! 1-based indexing is not as bad as you think.

Lua is strange…

Lua has some quirks that can trip you up at first but once you get the hang of it, it can end up being intuitive.

Why is it strange?

Because of ‘1-Based Indexing’:

Unlike many other languages (C, Java, etc.) where arrays start at 0, Lua starts at 1.

It might seem odd at first, but it actually fits well with how we naturally count things.

In the code below, we have a list of fruits.

To any human, the FIRST item in the array would be number ONE.

Now, I don’t know how you we’re taught to count lists, but I start at 1 for the first item.

Lua’s way of handling arrays is different & strange compared to most programming languages but I got to admit, it has grown on me this weekend.

local fruits = {"apple", "bannana", "cherry"}
print("First Fruit:", fruits[1])

table.insert(fruits, 'blueberry')
print("Fourth Fruit:", fruits[4])


-- It can be intuitive...
for i = 1, #fruits do
  print("Fruit at position:",i,"is",fruits[i])
end

--output
--[[
First Fruit:    apple
Fourth Fruit:   blueberry
Fruit at position:      1       is      apple
Fruit at position:      2       is      bannana
Fruit at position:      3       is      cherry
Fruit at position:      4       is      blueberry
--]]

Conclusion

While Lua has some quirks, it is a fun language to learn and write.

Nick Stambaugh

Nick Stambaugh

Full Stack Engineer

Entrepreneur & Enterprise Software Engineer

Recent Posts

I Don't Follow, I Subscribe

For over 7 years, I have almost never engaged with social media. I'm sharing my story to help those who are addicted to social media or need direction in their careers.

2026-04-09

Read more →

#SelfHelp #SocialMedia

Why I Let GitHub Actions Maintain My GitHub Profile README

How manually updating your GitHub profile README quietly fails at scale, and how I use GitHub Actions to keep it accurate, current, and maintenance-free.

2026-01-06

Read more →

#Automation #DevOps #Engineering

Why Your Astro JavaScript Works in Chrome but Breaks in Firefox

How browser inconsistencies in JavaScript APIs can silently tank your Astro site, and why engineers often miss them.

2025-12-25

Read more →

#WebDev #Astro #Frontend #JavaScript

Software Can Stop Losing You Money

How engineers can apply software thinking to maximize sales, reduce errors, and improve business outcomes.

2025-12-25

Read more →

#Business #Tech #Opinion

LunivCore: BI As Code

A lightweight, expressive, efficient, extensible BI language with a Markdown-inspired syntax, powered by a compact C/Lua execution core.

2025-12-5

Read more →

#LunivCore #BIAsCode #C #Lua #BusinessIntelligence

Astro/JS Randomized Banner Icons

A guide to creating dynamic, randomized banner icons.

2025-11-18

Read more →

#Astro #TailwindCSS #WebDev