Lua - First Impression [Programming Languages Episode 22]

preview_player
Показать описание

►Lesson Description: In this lesson we take a look at an extremely popular scripting language -- Lua! Lua is a dynamically typed language that is meant typically for embedding into other applications (though can be standalone). It has influences from languages like Modula, though features of functional languages like anonymous functions and higher-order functions. Lua is interesting in that it has one data structure -- the table. Lua also has lots of utilities in its standard library. Finally, we'll briefly check out coroutines at the end. Let me know if you're using lua (or in which project it's embedded) or otherwise one of its varients (e.g. luajit). As always, let me know what resources/tools I missed that others should know about in the comments below!

►Please like and subscribe to help the channel!
Рекомендации по теме
Комментарии
Автор

what I like about lua is that its white/green paper is only one page. but the C-API is powerful enough that you can asign C[++] functions for the state to use as built ins (that call out to your compiled binary)... that is super powerful because you could say write a sdl binding and lua treats the functions that you bind to it as first class items. (rather than using a translation layer)
that list is missing one huge title : "computer craft (Minecraft mod)" which is where I learned LUA
Javascript (namely P5.js) is the best way to learn to program because it is instant and P5 makes it like art...
C implicitly casts and it wouldn't be too difficult to write a set of functions that cast to the right types 'correctly' in C++ too.
everything that isn't C[++] is not much more than a wrapper around C[++] libraries... and why would it not be? there's not many problems that weren't solved in a C library over the past 50 years

skeleton_craftGaming
Автор

Lua is my absolute favorite scripting language. I'm not a huge fan of 1-indexed arrays, but you very quickly get used to them.

nyanlauncher
Автор

It's interesting that some languages (older and newer) that deal with high-performance computing and heavy mathematics are 1-index based languages such as Julia, Fortran, Matlab. And there are a few languages that let you choose your starting index such as Object Pascal which is n-index based.

GaryChike
Автор

Many times, I find that the use of 'continue' is redundant and can be left as an 'empty statement'. In the Lua code below, if the user enters nothing, the logic loops back to the start of the while loop. This works similarly in most languages like C/C++, C#, Java, Python, etc.. Some languages are more strict and do not allow 'empty statements' like Ada which requires 'Null' and Seed7 which requires 'noop' (no operation). Neither Ada nor Seed7 happen to have 'continue' either:

local user_input = ""
local q<const> = "q"

print("Press <q> to exit..")
while string.lower(user_input) ~= q do
io.write("> ")
user_input = io.read()
if user_input == "" then -- 'continue' not needed
else print ("> You wrote '".. user_input .."'")
end
end
print("> Goodbye!")

Ada: if Input = "" then null;
Seed7: if input = "" then noop;

GaryChike
Автор

I'm a simple man, see Mike - give thumb up!

sgretsch
Автор

Have you tried Erlang before? This autumn I'll start my firt semester in uni and I'll have the oppurtunity to take Erlang, and I'm kinda interested in it.

lajtaib
Автор

Some language developers feel that break, continue, exit, return are essentially a 'masked' goto statement.

I'm quoting one of them:
"Why are break and continue not supported?
Just like goto statements, break and continue violate the concept of structured programming. A programmer should imagine loops as:

while primaryCondition and
loopCount <= 1000 and
seconds <= 3600 do
if data <> "undefined" and
not doSkip then
do_something_useful;
end if;
end while;

instead of:

while primaryCondition do
if loopCount > 1000 then break;
if seconds > 3600 then break;
if someData = "undefined" then continue;
if doSkip then continue;
do_something_useful;
end while;

A goto or anything like it compromises readability. Non-structured statements are frequently used as shortcuts to avoid restructuring the program's flow. Programmers should overcome the temptation to introduce break or continue. Usually, this is a sign that the code is too complex and should be refactored. Seed7 provides many loops that help in this regard."

GaryChike
Автор

In the olden days, Tcl was used for exactly the same reason (as an embedded language for a C app/framework); still a great language (hint hint) ;)

bsdooby
Автор

This was fun! I’d love to see you take a tour of Gleam.

thepatzer
Автор

i have just used it in project zomboid to give myself a bottomless bag.

androth
Автор

Love me some Lua! 🙂 PS: Lua is register-based, not stack-based. 😛

pikuma
Автор

Lua is SO weird when using for the first time, and-or operator, no continue in loop, 1 indexed array etc

ataimusiclab
Автор

i've have just used it in project zomboid to give myself a bottomless bag.

androth
Автор

oh it's new video, i thought it was an old video 😂

iogilarb