Full Lua Crash Course 💥 2.5 Hours 🖥️⌨️ Beginner's Programming Fundamentals Guide for Developers

preview_player
Показать описание
Lua is a high level, cross-platform programming language that can be embedded in various software products. For example, Lua is used as a scripting language inside of popular networking software tools including Wireshark and nmap. Lua has also been used to script actions inside of games such as Roblox.

Similar to other high level languages, Lua uses a "virtual machine" layer to interpret instructions, and handle memory management (garbage collection).

In this video, we will be taking a look at how to write Lua code completely from scratch. After watching this video, and practicing some of the code samples, you should be equipped to write Lua code yourself. You should install the development tools that we present in this video, including Microsoft Visual Studio Code, and the Lua and Code Runner extensions for VSCode.

Lua probably isn't the best choice for general purpose programming, although it could be used for that purpose if you chose to. Even though Lua doesn't support the notion of structs and classes, you can still construct custom types of objects by using the "table" data type.

🚨📦 Help support this channel — shop through my Amazon storefront!
⬇️⬇️⬇️
⬆️⬆️⬆️

Please follow me on these other social channels!

All trademarks, logos and brand names are the property of their respective owners. All company, product and service names used in this website are for identification purposes only. Use of these names,trademarks and brands does not imply endorsement.

#opensource #software #linux #devops #programming #coding #codinglife #code #coder #ubuntu #ubuntulinux #appdev #developer #lua #luascript
Рекомендации по теме
Комментарии
Автор

🚨📦 Help support this channel — shop through my Amazon storefront!
⬇⬇⬇
⬆⬆⬆

TrevorSullivan
Автор

=== Timestamps ===
0:00:00 Intro
0:00:34 What is Lua
0:01:02 Where is Lua used
0:02:12 How Lua works
0:04:35 What's included in this course
0:04:55 Other places to learn Lua
0:07:08 How to install and run Lua
0:08:11 Lua shell (REPL) vs interpreter
0:10:04 Installing Lua on Ubuntu (apt)
0:10:45 Installing Lua on Windows (scoop)
0:12:06 Installing Lua on MacOS (homebrew)
0:13:16 Installing and setting up VSCode
0:15:16 Extensions
0:16:25 Creating a new Lua script
0:17:15 Using the Lua shell (REPL)
0:18:03 Variables
0:20:47 Multiple statements on the same line
0:21:46 Block definitions (do...end)
0:23:13 Back to VSCode
0:24:21 Code Runner extension
0:26:04 nil type
0:26:46 Booleans
0:27:36 Variable naming conventions
0:29:58 Strings
0:30:12 Numbers
0:33:25 String concatenation
0:36:41 Multi-line strings
0:40:19 Comments
0:42:07 Tables 1
0:44:02 type() function
0:45:15 Tables 2 (indexing, types)
0:47:13 Length operator
0:48:58 Tables 3 (key-value pairs)
0:51:06 Variable naming limitations
0:52:40 Math operations
0:54:00 Math module
0:55:59 abs()
0:57:09 ceil()
0:57:55 floor()
0:58:32 random()
0:59:17 randomseed()
1:01:07 min(), max()
1:02:52 More Strings
1:03:47 String module
1:04:07 sub()
1:07:22 find()
1:09:01 Functions
1:35:08 For loop
1:40:55 If statements
1:47:31 While loop
1:49:46 Repeat loop
1:51:43 User input
1:52:14 io.read()
1:57:05 Table module
1:58:50 sort()
2:02:21 concat()
2:04:07 remove()
2:06:33 OS module 1
2:08:11 remove()
2:09:18 execute()
2:10:07 getenv()
2:12:10 IO module (writing to file)
2:12:39 output()
2:14:00 write()
2:15:31 open()
2:18:05 OS module 2
2:18:15 time()
2:21:27 Modules

Im_Ninooo
Автор

I watched the whole video. Great and Smooth! Keep up the good work :))

alijavidi
Автор

There's a lot of issues with this tutorial.

-- nil is never a value in a table. it's always the value that indicates that something doesn't exist. This isn't a distinction without a difference. That hole will cause inconsistent results from the length operator and any function that relies on it. This is because the length operator is defined as returning the first numeric index that is found that is not empty but an empty space after it. Furthermore, Lua will try to avoid allowing any underlying memory to be taken up if possible. The reason the length operator didn't fail when you tested it is because the current official implementation tends to search backwards by last modification (with table creation going left to right).

-- print("Hello", ...) wasn't adding something like a tab. It was adding a tab. That's how print() works when given multiple values.

-- The ... symbol is considered a sequence. That's important, because it's why you need an indirect way to access it. Syntactically, it's multiple values rather than being a single value.

-- Using "_" for unused return values is just a convention for signaling intent. It doesn't discard anything.

-- You never explained what the generic for loop actually does, nor did you even mention the numeric for loop.

-- You explained how to initially create a table, but you didn't explain to adjust it later, nor that the string indices are actually strings. This makes your explanation of the pairs() function incomplete in a way that's just asking for confusing errors when a viewer tries to use it.

-- Your use of pairs() right after table.sort() is not guaranteed by the definitions to work. It just happens to work because of how the official implementation currently handles next() (which is what pairs() is actually returning). The proper way to iterate when order matters is with a numeric for loop. This is a really important pitfall, because it makes it seem like pairs() obeys a specific order, whereas in reality it tends to go in the order of first modifications.

--It's a really glaring omission to not mention that setting a variable to nil signals to the garbage collector that the value should freed. You spent over 2 hours on this and didn't tell your viewers how to free up memory.

-- math.randomseed() and math.randomseed(os.time()) do exactly the same thing. The reason the manual discourages this is that for the time in seconds doesn't change fast enough for programs that need to care about security (micro or even better nanoseconds is preferred).

-- Functions are always stored as variables. The first syntax you showed is syntactic sugar.

-- I don't think you mentioned a few important differences in multiline strings that could trip
people up: 1. they don't interpret escape sequences and 2. they ignore the first newline if beginning with a newline, so that they can be placed on their own set of lines more easily.



Seriously, please read the actual manual fully before you do even a beginner's tutorial. You've opened your viewers up to a lot of very nasty pitfalls by making some of these mistakes.

biggerdoofus
Автор

This is great!

I use Lua in an audio/visual/control system called QSYS by the audio company QSC. Lua is used to control automation, build plugins to connect to other devices or extend stock functionality of the system.

This video is helpful for me to fill in some gaps, where I sometimes find it difficult to read the manual, having someone explain it in a different way is awesome. Much appreciated!

thescottallen
Автор

The quality of your video is amazing, and you are such a good teacher.
i'm still at half of the course but i hope there will be more of lua !
thanks alot !

LouisWeiserUVI
Автор

Lua is also used by DCS (DIGITAL COMBAT SIMMULATOR) mission editor...

mikekohler
Автор

I feel there's not many informative, in-depth videos on YT about Lua; specially for OOP.
(I know that's not Lua's strongest suit but, in the environment I'm currently working in, it's either Lua or C)

if you ever have the time to tackle more advanced concepts like how to use Lua modules to do composition or how to make use of mixins with Lua, that would be wonderful.

either way, you've got a new subscriber!

nederui
Автор

Great introduction; however, I was a bit surprised by your statement about Lua not being fast enough for REST APIs. Lua is an extension language, and when the lower levels are implemented in C code, a REST API can be incredibly fast with Lua. For instance, REST APIs designed with the Mako Server (a performant Lua web engine) are blazing fast. They really scream in terms of performance!

socaldude
Автор

Hi Trevor ! It's a very awesome topic, because I'm going to learn Lua to configure NeoVim😆

B-geqy
Автор

12:29 you are able to install Lua through Homebrew with `brew install lua`

jakubtomas
Автор

this video was such a great finding!
I've been learning lua myself by trial and error, and I got stuck not knowing how to structure my code properly.
(ah, so that's how Lua modules work!)
thanks a lot for your time and valuable info. you are an amazing teacher.

nederui
Автор

The best video I could find for lua. Thanks!!!

tlgtby
Автор

I like this video, i want more videos about lua, thank you very much

juandavidcastroarias
Автор

Thank you for this, it would be nice if you could do Luau also, its like a Typescript version of Lua that is being use by Roblox

BlackistedGod
Автор

Learned very well. precise and clear . Thank you

chalikir
Автор

Interesting, I couldn't make the print work on the function being returned on multiple compilers, why is that?

enkiimuto
Автор

Using VScode to write and run lua. preposterous ;)))

tomaszgora
Автор

I loved the tutorial for getting started also which theme is this I liked this one

puneetshakya
Автор

Hi Trevor, which theme are you using in the video? I like your purple theme.

XYZ-griu