Lua in 100 Seconds

Поделиться
HTML-код
  • Опубликовано: 1 окт 2024
  • Lua is a lightweight dynamic scripting language often embedded into other programs like World of Warcraft and Roblox. It's minimal syntax makes it easier to learn than Python, while being much more performant than other interpreted languages.
    #programming #compsci #100SecondsOfCode
    🔗 Resources
    Lua Manual www.lua.org/ma...
    Lua History www.researchga...
    Lua C API riptutorial.co...
    🔥 Get More Content - Upgrade to PRO
    Upgrade to Fireship PRO at fireship.io/pro
    Use code lORhwXd2 for 25% off your first payment.
    🎨 My Editor Settings
    - Atom One Dark
    - vscode-icons
    - Fira Code Font
    🔖 Topics Covered
    What is Lua?
    What is Lua used for?
    Is Lua faster than Python?
    Lua vs Python
    Lua Basics Tutorial
    How do tables work in Lua?
    How to use C or C++ with Lua

Комментарии • 2,8 тыс.

  • @alexandermichaud957
    @alexandermichaud957 2 года назад +6862

    Being subscribed to this channel is a problem, because every day I learn about a new piece of technology I want to go play around with

    • @drishalballaney6590
      @drishalballaney6590 2 года назад +69

      ngl you had us in the first half xD

    • @joseph0x45
      @joseph0x45 2 года назад +128

      i litteraly have a txt file where i keep a list of technologies i want to play around with later, 90% come from this channel lmao

    • @Thespokenone
      @Thespokenone 2 года назад +19

      @@joseph0x45 That's a pretty handy idea, I'll remember to do that!

    • @DogeMultiverse
      @DogeMultiverse 2 года назад +69

      Just print hello world and add that programming language into your resume

    • @Thespokenone
      @Thespokenone 2 года назад +10

      @@DogeMultiverse I can see why that's your profile name 😂

  • @vicradon
    @vicradon 2 года назад +12037

    I love how Jeff always uses “hi mom” instead of “hello world”.
    Edit: Jeff made a Twitter post about how his Mom always watched his videos and was proud of him even though she wasn't a programmer. Sadly she passed away.
    My heartfelt condolences Jeff. I'm sure she in a better place seeing the great work you do for the tech community making these amazing videos. ❤

    • @bigoulie931
      @bigoulie931 2 года назад +969

      Same thing, because she is his world

    • @salmanbehen4384
      @salmanbehen4384 2 года назад +53

      @@bigoulie931 Maybe because of hava.

    • @padamupreti
      @padamupreti 2 года назад +306

      I wonder if he does this because his mom watches every video he puts out, so he is saying hi knowing this

    • @alpers.2123
      @alpers.2123 2 года назад +45

      So cute

    • @masmullin
      @masmullin 2 года назад +87

      Is name is Jeff? Well today I just learned TWO things!

  • @tati6213
    @tati6213 2 года назад +4406

    Pretty cool seeing people talk about lua, it was invented in my university and I had a class lectured by one of the creators you showed in this video!

    • @Psychopatz
      @Psychopatz 2 года назад +280

      You're one lucky guy!

    • @gloverelaxis
      @gloverelaxis 2 года назад +120

      wow, that's amazing! please tell that lecturer that one more person out there absolutely loves the language they designed

    • @sbrunner69
      @sbrunner69 2 года назад +22

      Awesome! I’ve been using lua in mach4 on my homemade cnc router. It’s cool.

    • @hodayfa000h
      @hodayfa000h 2 года назад +8

      wait what

    • @cheeseboiyes._.
      @cheeseboiyes._. 2 года назад +140

      so that means if your university didn't exist roblox would not even be a thing lol

  • @Ren-bo7bj
    @Ren-bo7bj Год назад +294

    Lua is one of the greatest scripting language for video game mods that I have encountered. If you're creating a game and have mods in mind as a possible feature, include Lua scripts in that mod loader, the community will make amazing things with it.

    • @sethjets4687
      @sethjets4687 4 месяца назад +7

      hades 2 for example

    • @olivers.7821
      @olivers.7821 3 месяца назад +2

      The Minetest Engine also uses Lua to code mods for it.
      I am currently trying to learn Lua to make some mods for it :)

    • @stephen303
      @stephen303 2 месяца назад +1

      Factorio mods are done in large part through Lua, I believe!

    • @thadashley2911
      @thadashley2911 Месяц назад +1

      GTA V modding has a lot of Lua scripts as well. Personally trying to use it to tinker with awesomeWM.

    • @Will_-it3mh
      @Will_-it3mh 10 дней назад

      add celeste to that, i believe it uses lua for mods too

  • @whythosenames
    @whythosenames 2 года назад +106

    computercraft anyone?

    • @cibulis5347
      @cibulis5347 4 месяца назад +3

      Good old times

    • @edukkkkkj
      @edukkkkkj 4 месяца назад

      I miss this time

    • @andrewyork3869
      @andrewyork3869 4 месяца назад

      Times where everything made sense.

    • @Sirbozo
      @Sirbozo 4 месяца назад

      Wat

    • @Noah-gp5sj
      @Noah-gp5sj 3 месяца назад

      wait guys google CC:Tweaked….. do it..

  • @KalleJillheden
    @KalleJillheden 2 года назад +4212

    Lua doesn't have Regex because the Regex C library is bigger than the entire Lua compiler and runtime, including Lua's own "Lua patterns" that works like a simpler Regex.

    • @Rice7th
      @Rice7th 2 года назад +86

      I love lua patterns soo much!

    • @TheJobCompany
      @TheJobCompany 2 года назад +196

      or you can write your own parser, which, let's face it, is probably gonna be smaller than the regex matcher

    • @halflifefan
      @halflifefan 2 года назад +42

      Some CS:GO cheats' Lua API's have an ability to run JavaScript code, so we just use that if Lua patterns limit us lol

    • @inserteunnombreapropiado9079
      @inserteunnombreapropiado9079 2 года назад +7

      Has simpler Regex, but still enough to make many things.

    • @holthuizenoemoet591
      @holthuizenoemoet591 2 года назад +33

      I love lua's simple and elegant syntax, like # to get the length, its simple for loop, etc
      However it lakes a lot of useful stuff, like math constants PI and Euler etc.
      A short spread operator, instead you have to use table.unpack
      To print a table you need to unpack it first, print(table.unpack(my_table))
      I wish lua or luau had these functions so that i could use it form my data science projects

  • @phire0
    @phire0 2 года назад +2579

    Lua is what most likely got me into programming. I started messing around with it in Roblox back in 2010 when I was only nine and that got me into computers, now I'm a software engineer :)

    • @samast253
      @samast253 2 года назад +32

      same!

    • @znimator
      @znimator 2 года назад +52

      same! but for a gamedev ❤

    • @isaiahballah2787
      @isaiahballah2787 2 года назад +73

      I also started with learning lua when I was around 11 and now i've interned at google twice as a swe

    • @isaiahballah2787
      @isaiahballah2787 2 года назад +32

      also on Roblox of course

    • @-data
      @-data 2 года назад +6

      @@isaiahballah2787 nice! hope that all goes well

  • @jakubsebek
    @jakubsebek 2 года назад +1876

    Fun fact: The PyTorch machine learning library that everyone loves is actually based on the original Torch library, built for Lua.

    • @DaveParr
      @DaveParr 2 года назад +82

      That's amazing. I literally had no idea and that's my new favourite fact.

    • @testtest-qm7cj
      @testtest-qm7cj 2 года назад +183

      @@DaveParr And sadly, Torch library is now abandoned in favor of PyTorch.

    • @manojkothwal3586
      @manojkothwal3586 2 года назад +1

      😳

    • @heyoudodobird
      @heyoudodobird 2 года назад +4

      how to script: ruclips.net/video/7fn-qMlC864/видео.html

    • @nishanth6403
      @nishanth6403 2 года назад

      damn

  • @ScotsmanRS
    @ScotsmanRS 2 года назад +28

    Fun fact: in Scottish Gaelic, “luath” (pronounced much the same as “Lua”) means “fast”.

    • @Cradien
      @Cradien Год назад +3

      glé luath! (very fast)

    • @ScotsmanRS
      @ScotsmanRS Год назад +2

      @@Cradien Gu mì-fhortanach, chan eil sìon a dh’fhios agamsa dè cho luath ’s a tha Lua. 🤷🏻‍♂️😂

  • @xyz2112zyx
    @xyz2112zyx 2 года назад +66

    I knew nothing about Lua 2 months ago, but now I realize that Lua is a good complement for C language, and viceversa. Both languages work beautifully between them and when I need to code something quickly, I use Lua, but when I need more performance, I use C or C++. I wonder why I didn't learn before about Lua...

    • @xyz2112zyx
      @xyz2112zyx 2 года назад +18

      And sorry about Python fans, but I learnt more Lua in 1 week that what I learnt about Python in 1 year... I feel Python is becoming complex and clumsy about its syntax and program complexity...

    • @hjrgf
      @hjrgf Год назад +11

      ​@@xyz2112zyx I realised python is really bad for anything but data science and machine learning

    • @NotePortal
      @NotePortal Год назад +4

      @@hjrgf Yeah, lua imo is best for beginners. its extremely easy to learn.

  • @felixo.8818
    @felixo.8818 2 года назад +904

    While there are no traditional classes in lua, you should note that there is a concept called metatables that allows for object oriented programming.

    • @nathanhedglin931
      @nathanhedglin931 2 года назад +197

      @@gamemoves2415 someone's mom didn't hug them enough as a kid

    • @Youkakun
      @Youkakun 2 года назад +8

      Closures are good enough but metatables allow overloading of operators - that's the point but not a strong one.

    • @sournois90
      @sournois90 2 года назад +56

      @@gamemoves2415 "omg guys im so random look mom, im a shitposter!!!!! 😏😏🤩🤩😎😎🤣🤣🤣🤣"
      "omg why do i have no friends and social life??? 🤔🤔🤨🙄😥😲🤡😭😭😭😭"

    • @v0xl
      @v0xl 2 года назад +1

      yeah you can even do complex "prototype" chains with them!

    • @RoyRope
      @RoyRope 2 года назад +9

      @@gamemoves2415 I do, shut up.

  • @mikolmisol6258
    @mikolmisol6258 2 года назад +1201

    Lua is interesting because it's what I'd a call a "low level" scripting langauge. It's not close to the metal or anything, but it is quite flexible. It doesn't have classes, but you can implement them with function tables, metatables, or closures, each having its advantages and disadvantages. You can also implement multiple inheritance using metatable pooling. You can reuse tables to conserve memory with the table.clear() function. Iterators are simply functions that return a function for retrieving the next element of your (custom) collection.

    • @gamemoves2415
      @gamemoves2415 2 года назад +14

      No one cares.

    • @PokeRuto898
      @PokeRuto898 2 года назад +274

      @@gamemoves2415 35.346 People care

    • @wishub
      @wishub 2 года назад +106

      @@gamemoves2415 rip bozo

    • @philippjungkamp3760
      @philippjungkamp3760 2 года назад +137

      @@gamemoves2415 This is actually a nicely written collection of things that make lua great.
      I care and I like this quality comment.
      Back to Lua:
      Integrating it as a dynamic configuration is also super easy and really flexible. And with LuaJIT the Lua code/configuration can also yield really fast machine code.

    • @gamemoves2415
      @gamemoves2415 2 года назад +4

      @@philippjungkamp3760 so what? Not like anyone is going to use every you've written. If they need lua information they are certainly not coming to an obscure comment. Everyone is going to Google.

  • @f-person
    @f-person 2 года назад +266

    Also worth mentioning that Lua is a first-class citizen for Neovim

  • @Little-bird-told-me
    @Little-bird-told-me 2 года назад +597

    Lists of keywords in each launguage
    ANSI COBOL 85: 357
    SystemVerilog: 250 + 73 reserved system functions = 323
    VHDL 2008: 115 reserved words
    C#: 79 + 23 contextual = 102
    F#: 64 + 8 from ocaml + 26 future = 98
    C++: 82
    Dart: 54
    Java: 50 (48 without unused keywords const and goto)
    PHP: 49
    Ruby 42
    JavaScript: 38 reserved words + 8 words reserved in strict mode only
    Python 3.7: 35
    C: 32
    Python 2.7: 31
    Go: 25
    Elm : 25
    Lua: 22
    CoffeeScript: 19, not necessarily "reserved", plus ~50 to avoid from JS
    Smalltalk: 6 pseudo-variables
    iota: 2

  • @waffos8055
    @waffos8055 2 года назад +7

    The only reason I knew of Lua before this is because I got bad coder achievement in Garry's Mod

    • @endgamerplays
      @endgamerplays 2 года назад +2

      Wait, it’s used in GMod?

    • @waffos8055
      @waffos8055 2 года назад +1

      @@endgamerplays i think so

    • @doodle1244
      @doodle1244 Месяц назад

      @@waffos8055its used to code addons

  • @dyXurChannel
    @dyXurChannel 2 года назад +373

    Lua has become one of my favorite programming languages. It's sheer simplicity makes writing it an absolute joy.

    • @xn--719h
      @xn--719h Год назад +22

      make roblox game

    • @duxofducks
      @duxofducks 7 месяцев назад +2

      @@xn--719h too hard

    • @boblol1465
      @boblol1465 4 месяца назад +1

      yeah, some people hate it for its simplicity and some people love it precisely for it

    • @deesh6378
      @deesh6378 3 месяца назад +2

      @@boblol1465 not to mention that Roblox uses their own fork of Lua nowadays called Luau that supports variable types, true multithreading, etc.

    • @NotGarbageLoops
      @NotGarbageLoops 3 месяца назад

      I really want to use it but the counting from 1 messes me up :(. Looks like such a cool language otherwise.

  • @itzmeB2
    @itzmeB2 2 года назад +904

    My god i never knew there was a language easier to learn than python, Lua truly is an underrated language

    • @skyhappy
      @skyhappy 2 года назад +168

      It's....beautiful, even more than python. And not just that, but even faster, if this vid is correct.

    • @bobuccman1424
      @bobuccman1424 2 года назад +92

      @Linux user i can confirm its usually 3.2x times faster than python (lua 5.2.1 vs python 3.9.8)

    • @internetsfinest8839
      @internetsfinest8839 2 года назад +223

      @@skyhappy ugliest part about the language is the starting index of 1

    • @nosmirck
      @nosmirck 2 года назад +62

      @@internetsfinest8839 and the lack of typing... I can see one easy falling into the same javascript nonsense.

    • @skyhappy
      @skyhappy 2 года назад +130

      @@internetsfinest8839 I disagree, humans start counting at 1, not 0

  • @e1nste1in
    @e1nste1in 2 года назад +1116

    I met lua first time in the *Computercraft* extension for Minecraft - never had so much fun coding before that.
    I think this should be the first project in classes to motivate pupils für CS.

    • @christopherk4166
      @christopherk4166 2 года назад +71

      Yes! That's how I really got into programming :)

    • @dauerplay4544
      @dauerplay4544 2 года назад +67

      Fucking loved that mod great memories

    • @Taaz2
      @Taaz2 2 года назад +38

      I met this mod on my first steps into programming too!
      I remember it was possible to use turtles to craft banned stuff like chunk anchors or run thru residences to siphon chests.
      Oh man I would love to go back and explore that mod for the first time again (I am sorry to whoever I griefed that one day)

    • @jwalty
      @jwalty 2 года назад +37

      @@Taaz2 Came to talk about my ComputerCraft experience and found somebody who did exactly what I did. I would steal from chests with wireless turtles and it's probably the peak of my minecraft career

    • @korhzik77750
      @korhzik77750 2 года назад +13

      @@dauerplay4544 2 words: Open computers (:

  • @ariankar98k
    @ariankar98k 2 года назад +258

    BRASIL! VOCÊ FINALMENTE CRIOU ALGO ÚTIL! OBRIGADO MEU QUERIDO PAÍS!

    • @maushax
      @maushax Год назад +51

      neovim was created by a brazilian (Thiago de Arruda), so is the second (maybe there are more) useful thing created in Brazil, and curiously, neovim uses Lua for plug-in creation and configuration.
      Edit: Elixir is also created by a brazilian, so Lua is definitely not the only useful thing created by them.

    • @Mrguaxinim
      @Mrguaxinim Год назад +7

      @@maushax Vou aprender lua, acho ela ótima pra scripting

    • @0kr4m
      @0kr4m Год назад +40

      @@maushax Brazil invented planes....

    • @viniciusneiva5796
      @viniciusneiva5796 Год назад +18

      Cara acredite ou n'ao, com o pouco investimento que a gente tem, a gente realmente é pioneiro em muita coisa na TI.

    • @lookatel3658
      @lookatel3658 Год назад +2

      Por isso que ficou mais claro de noite

  • @captmcneil
    @captmcneil Год назад +33

    To me, Lua always felt like someone heard the "JavaScript the Good Parts" talk by Doug Crockford, and decided to make a language from it. Sometimes I wish, we had Lua in the browser.

  • @witherin-_-3712
    @witherin-_-3712 2 года назад +30

    "famous for being underrated" this is some infinite iq humour

  • @fgsaldanha
    @fgsaldanha 2 года назад +316

    I had no idea that such a relevant programming language was created in my country.

    • @gsvf
      @gsvf 2 года назад +22

      somos brabos :)

    • @quequeque57
      @quequeque57 2 года назад +3

      Nem eu.

    • @GuilherHast
      @GuilherHast 2 года назад +8

      Brs mandando a ver.

    • @baraodesantos9993
      @baraodesantos9993 2 года назад +18

      Elixir tambem é br

    • @clehpton
      @clehpton 2 года назад +11

      @@GuilherHast Mano, não posso ver nenhum canal gringo que tem mais outros brs por lá kkkkkkkkk

  • @cookiecan10
    @cookiecan10 2 года назад +170

    Computercraft is a populair Minecraft mod that adds programmable blocks and drones (turtles) into the game, it uses Lua as their scripting language and it's how I got in contact with programming for the first time.

    • @dfoxg
      @dfoxg 2 года назад +13

      Same here. It was the beginning of my programming career 🙋 I think my very first programm was a password-locked door. Great old times

    • @rrune
      @rrune 2 года назад +10

      Computercraft is wild. Played a modpack a year ago and needed something to dig. Didn't have the patience to learn Lua for it, but going through the scripts of others and fixing bugs was really fun

    • @nollix
      @nollix 2 года назад +2

      Computercraft is shit. Use OpenComputers.

    • @MrFunny01
      @MrFunny01 2 года назад +4

      @@nollix computercraft is just old, for older versions. OpebComputers - remake of ComputerCraft with more flexible API, devices etc.

    • @airgeadlamh
      @airgeadlamh 2 года назад +11

      @@MrFunny01 opencomputers stoppped on 1.12.2, so, no thank you, i'm gonna stick with ComputerCraft as it can even be played at 1.18+ already

  • @SpiteAnims
    @SpiteAnims 2 года назад +9

    Lua is simple and easy to learn. Perfect scripting language to implement if anyone is interested

    • @nikolaievans2432
      @nikolaievans2432 2 года назад +1

      Its also a unsafe and exploitable scripting langauge since exploits can use a dll to hack into the c++ code

    • @MiguelGoncalves-yk3sc
      @MiguelGoncalves-yk3sc Месяц назад

      @@nikolaievans2432 any language can be exploited. it's not unsafe if you do good practices

  • @Ceelbc
    @Ceelbc Год назад +2

    I tried it. I would not recommend it. It is useful to create an API that non-programmers can use to create for instance mods for your game. However, I would not recommend it for creating your entire app out of it. Furthermore it is not powerful enough to create a backend for a server. I would rate it between a 3/10 and a 4/10.

  • @pinkink9281
    @pinkink9281 2 года назад +94

    First time I heard about lua when I thought about switching vscode by nvim and found out plenty of nvim plugins are written in lua. That was a barrier for me 'cause I really didn't want to spend a lot of time learing new language just to use nvim properly. But just this one small video makes me feel it's not that scary to go into lua. Thank you Jeff for your videos they're really inspiring

    • @heyoudodobird
      @heyoudodobird 2 года назад +1

      how to script: ruclips.net/video/7fn-qMlC864/видео.html

    • @elnico5623
      @elnico5623 Год назад +5

      Lua is most probably the easiest language to get into

    • @ForeverZer0
      @ForeverZer0 Год назад +3

      I know this comment it a year old, but for others: You will literally learn Lua naturally without even trying just by taking the time to configure neovim how you like it. Assuming you have some very minimal programming experience in any language, you can just dive in, you will figure it out as you go without once ever reading the Lua docs.

  • @hashtags_YT
    @hashtags_YT 2 года назад +400

    Lua does have classes (though it doesn't do them the same way python for example does), they can be created via a metatable and they support inheritance, object values, the self keyword and just about anything else you can think of.
    Thanks to the colon operator closely followed by the self keyword, it's obviously an intended feature rather than something that can be simulated.

    • @mikumikudice
      @mikumikudice 2 года назад +28

      Actually self is not a keyword but a default defined argument of functions that use the colon notation instead of dot

    • @divingradish
      @divingradish 2 года назад +48

      Lua doesn't have classes, but you can make classes using table.

    • @elpersonpl576
      @elpersonpl576 2 года назад +3

      if lua had classes then there would be a class keyword of something of that sort

    • @divingradish
      @divingradish 2 года назад +21

      @@elpersonpl576 they can have class keyword and still doesn't have classes, if the class keyword is just syntactic sugar.

    • @hashtags_YT
      @hashtags_YT 2 года назад

      @@mikumikudice It's pretty much what I meant since I added it right after that point, not to mention that self in Lua cannot be used outside of a function with colon notation, but regardless thank you for the correction.

  • @nickchapsas
    @nickchapsas 2 года назад +13

    So we'll all just gonna ignore that this guy convinced 1M+ people that 100 seconds = 2:30 minutes?

  • @appropriate_name1
    @appropriate_name1 2 года назад +13

    0:28 why everyone who talks about lua always forgors garrys mod

  • @lmnts556
    @lmnts556 Год назад +36

    Why did they have to ruin lua with indexing from 1. SO ANNOYING!!!!!!

    • @eldrago19
      @eldrago19 5 месяцев назад +5

      I don't know, maybe because they are normal people as opposed to people with C Stockholm Syndrome.

    • @lmnts556
      @lmnts556 5 месяцев назад +10

      @@eldrago19 Nah, indexing from 0 makes sense and basically every language has adapted it. Not doing it is silly and them trying to be edgy.

    • @HansBezemer
      @HansBezemer 4 месяца назад +2

      @@lmnts556 It's the same with some BASICs. Some BASICs allocate for that reason one element *MORE* than requested and treat index 0 as if it doesn't exist. Very cute, but wasteful.

    • @DucNotADuck
      @DucNotADuck 4 месяца назад +2

      I quite like it but I get what you mean

    • @lmnts556
      @lmnts556 4 месяца назад

      @@DucNotADuck its gay.

  • @SkyyySi
    @SkyyySi 2 года назад +95

    You can define dictionary tables without the `["index"]` syntax. That is only required for using non-standard names (like ones containing special characters) or when the key you want to assign something to is dynamic (for example, you want to assign specific keys from a loop, but you don't know the key name at that point). This syntax works as well (and from what I understand, seems to be the convention): `local t = { x = 4, y = 2 }`. You can also access table fields both using `varname["key"]` and a more "object"-asque syntax with `varname.key`.

    • @WackoMcGoose
      @WackoMcGoose 2 года назад +5

      Exactly. Roblox even _encourages_ using object-style syntax with tables (if the key is a valid variable name, just alphanumerics and no spaces, you're golden for nesting keys as far as you want, and in fact that's literally how accessing game objects in the DataModel natively works, they're functionally just tables inside tables). I got quite good at scripting back when I was still interested in the game, and even made a few ModuleScripts (libraries) for referencing Terrain voxels (which natively have to be accessed using stud coordinates for some reason???) using more reasonable "one voxel, one index over" coordinates, aka how Minecraft and literally all other voxel engines read and write their data structures...

    • @edupazz
      @edupazz 2 года назад +1

      Just like Javascript

    • @cheesebusiness
      @cheesebusiness Год назад

      JavaScript flashbacks

  • @surajrawat4204
    @surajrawat4204 2 года назад +99

    Wow I learnt Lua literally in 100s.

    • @1hsl
      @1hsl 2 года назад +18

      learnt in 50s on 2x 😎

    • @lakshman587
      @lakshman587 2 года назад +2

      @@1hsl Converted the video into 2x speed and watched in 2x speed
      And learnt in 25sec 😎😎
      Lol! 😂

    • @SolathPrime
      @SolathPrime 2 года назад +4

      @@lakshman587 convert the 2x2x to 2x2x2x to learn it in 12.5 secs

    • @brentambrielcabigas1086
      @brentambrielcabigas1086 2 года назад +9

      Skip to the end, learn *instantly* 😎

    • @samn4730
      @samn4730 2 года назад +1

      @@SolathPrime converted the 2x2x2x into 2x2x2x100x and learned it in 0.125 seconds

  • @skaruts
    @skaruts 2 года назад +154

    I agree it's greatly underrated. Its flexibility is amazing. I've hopped around through many languages over the past 15 years, never really feeling comfortable about any. I tried Lua some 4 years ago, and at first I struggled a bit with the 1-indexing, but it didn't take long for me to really settle for it. Coding in Lua is a breeze. I only stopped for about a year because I thought it wasn't fast enough for my gaming projects, but eventually I went back and I found out it was just my bad implementation being bad.
    Lua, at least with LOVE/LuaJIT, is actually really fast.
    Lua being a simple language is also a plus. When I got back to it after that long pause, I still remembered almost everything about it. And it's also the one language I can go for days or even weeks without needing to check something in its documentation.

    • @cyberlawit8891
      @cyberlawit8891 2 года назад +3

      Wow bro thanks for information

    • @jameswashington4704
      @jameswashington4704 2 года назад +16

      man lua is so fucking fast. learning to work around the JIT's nuance + storing data in c types will give you ungodly performance you would not believe. People really dont understand how fast this language can get. Those benchmarks showing near C and sometimes faster than C speeds are real.

    • @pixelstriko1642
      @pixelstriko1642 2 года назад +8

      I agree on lua's flexibility and simplicity, in lua everything just feels really straight forward, i feel like my only limit is the speed of my hands and the language is fast, where as in other languages i feel like i have to do roundabout techniques to get what i want, also lua's first class functions are a huge plus, its painful for me to use a language without first class functions at this point.
      Edit: also tables and metatables really deserve more credit, they can do the job of what in other languages you'd have like 4+ things to do it, for example tables can function as: arrays, dictionaries, structs, enums, etc.. and if you learn metatables (easier than they seem) you can emulate classes if you really wanted to, but because of how unbelievably flexible lua ls you wont even feel like you need to, its honestly really sad how it stagnated

    • @Forcoy
      @Forcoy 2 года назад +1

      I also love lua for how common it is in sandbox games
      Be it Roblox (how I discovered it), Gmod, ComputerCraft, you name it. Its quite common in that niche.

  • @douggale5962
    @douggale5962 2 года назад +22

    The way you depict the arrays starting at one is perfection.

  • @RodolphoArrudanogoogle
    @RodolphoArrudanogoogle Год назад +8

    That array index starting at '1' reaction was hilarious. 🤣 1:32

  • @codex8797
    @codex8797 2 года назад +357

    As a Brazilian it's cool to know that there is a Brazilian programming language (that is actually good)

    • @victorhsluiz
      @victorhsluiz 2 года назад +55

      There's Elixir as well (and it's becoming very popular)

    • @mr.boloso8296
      @mr.boloso8296 2 года назад +6

      Indeed

    • @SrIgort
      @SrIgort 2 года назад +5

      Indeed

    • @codex8797
      @codex8797 2 года назад +5

      @@SrIgort indeed

    • @SrIgort
      @SrIgort 2 года назад +3

      @@nollix You're trying too hard to be a jerk, this is cringe

  • @Stevesteacher
    @Stevesteacher 2 года назад +92

    Lua is close to being my favourite programming language, especially when it comes to game dev, it is what encouraged me to continue making those types tutorials, since doing it in Lua is quite fun

    • @AkshayKumarX
      @AkshayKumarX 2 года назад +2

      You are giving me some encouragement to finally sit down and try learning a new language and get back to programming. Question, does LUA only work with C, or it can work with other languages too?
      Is there a downside to doing that?

    • @fbiagentmiyakohoshino8223
      @fbiagentmiyakohoshino8223 2 года назад +13

      i have learned lua for 5+ years, and all those 5 years were on roblox by this point i have basically mastered lua and wanted to go to other languages like c# and c++, then my lua brain broke when i saw their syntax.

    • @Stevesteacher
      @Stevesteacher 2 года назад +4

      @@AkshayKumarX You can use Lua on its own as well! I'm not really sure if Lua works with other languages, but most languages will have some sort of library that will allow you to execute it in some way ;)

    • @_lod
      @_lod 2 года назад +6

      @@AkshayKumarX there are a few Lua bindings for other languages like C#, java, rust and other ones

    • @heyoudodobird
      @heyoudodobird 2 года назад

      how to script: ruclips.net/video/7fn-qMlC864/видео.html

  • @langamerdev
    @langamerdev 2 года назад +31

    It was my first language to deal with, I modded so much things on old Gmod servers in Lua, most of the CS:S and OrangeBox games (based on Source 1 before the BIG source 1 update that killed 120 tick servers...) used Lua to give the community the ability to create plugins ! Loved this one Jeff, thanks for the memories :)

  • @michaelborges5204
    @michaelborges5204 2 года назад +13

    Eu programo em Lua já alguns anos e sempre enjeto código C no meio. Fica super legal para os propósitos que eu preciso, aínda mais para sistemas de embarcação!

    • @nerd2544
      @nerd2544 2 года назад +2

      what do you use lua for? embedded system?

  • @Saikocide
    @Saikocide 2 года назад +3

    lua was one of the first languages that i tippied my toes on when i was 12, i got inspired by roblox games and i wanted to make one myself, and it didn't work out

    • @thrill3272
      @thrill3272 2 года назад +1

      Roblox lua was one of my first languages as well lol

  • @pesterenan
    @pesterenan 2 года назад +4

    Of course we from Brazil would start counting from 1, instead of 0, you know, like *_everyone does..._*

    • @softwarelivre2389
      @softwarelivre2389 2 года назад +2

      That's actually not that good, because it messes up with offsets. *ptr + index * offset won't work properly, you'll need to do *ptr + (index - 1) * offset, which is not great.

    • @softwarelivre2389
      @softwarelivre2389 2 года назад +1

      @@ribethings even so, if you have a 2**n array, you'd need 2**(n+1) bits to store it. That's generally not good.

  • @KuruGDI
    @KuruGDI 2 года назад +34

    Some time ago I wanted to contribute to an open source program. For this I had to learn LUA. I really started to love it for it being so simple yet so powerful.

  • @drk3249
    @drk3249 2 года назад +22

    Sometimes I just wish there was more than 1 channel like fireship, or more jeffs/people running fireship to produce more high quality videos and tutorials on every technology

  • @megasst4747
    @megasst4747 2 года назад +8

    0:11 É... Finalmente nós Brasileiros...

    • @Tealen
      @Tealen 2 года назад +2

      yessir

    • @megasst4747
      @megasst4747 2 года назад +1

      @@Tealen 👍?

    • @um_idkw
      @um_idkw Год назад

      ​@@megasst4747 ✅️

  • @ant_onion
    @ant_onion 2 года назад +3

    Wow, i didn't know lua was created by brazilians (even though i'm brazilian)
    Cool, very very cool

  • @savejeff15
    @savejeff15 2 года назад +9

    1:37 ... i'm head out.

  • @B1GTM4N
    @B1GTM4N 2 года назад +179

    I've heard of Lua once when I was in college, didn't think too much of it.
    Watching this video has piqued my interest again -- insanely awesome!
    I think it's incredibly powerful, that Lua has a C API that allows developers to run Lua code in a C program, and vice versa.
    Great -- how am I suppose to get my work for the day done now? 😂

    • @nonominox
      @nonominox 2 года назад +5

      This happpens to me every single time I discover something new 🤣

    • @CyberPunk38
      @CyberPunk38 2 года назад

      I also thought Lua was just a meme. But a lightweight interpreted language sounds very interesting...

    • @SrIgort
      @SrIgort 2 года назад +6

      But be aware that although the "run Lua code in a C Program" part is very easy to do, the "run C program in lua code" will require a lot of binding work.

    • @victor95pc
      @victor95pc 2 года назад

      about running C inside an interpreted language is nothing new really, most language has support to it, Ruby for example has a lot of libs(gems) that uses C to speed up the code

    • @Youkakun
      @Youkakun 2 года назад

      @@victor95pc It's called FFI (foreign function interface). This technology is present in all jit (just in time) compilers of various languages (see JNA for Java or cffi in python/pypy). It binds at runtime instead of compile-time so calling bound functions is a bit slower.

  • @ilyasb4792
    @ilyasb4792 2 года назад +137

    Lua is a really cool programming language, some would even say that beginners should start with Lua and not Python for an introduction to programming.

    • @seadrown6252
      @seadrown6252 2 года назад +19

      I started with lua, making games on ROBLOX. I now do lua and python, (lua due to Roblox and python due to GCSE computer science), and I have to say I do enjoy lua more. It's syntax is very easy to pick up

    • @ZephrymWOW
      @ZephrymWOW 2 года назад +15

      Lua is a bad first language if you are not doing it for fun or planning on doing video game development. It teaches you bad habits and is very different from the majority of "real world" applications.

    • @light_creations
      @light_creations 2 года назад +8

      @@ZephrymWOW Bad habits?

    • @nwa8169
      @nwa8169 2 года назад +5

      @@light_creations Using globals by default for starters

    • @XKMetralhaDO
      @XKMetralhaDO 2 года назад +2

      @@nwa8169 I started with lua in college

  • @djxoxta
    @djxoxta 2 года назад +3

    I was thinking during the video and lua was my first contact with lua progamming bots for Tibia, amazing and very easy language 🇧🇷

  • @ThiagoSilva-vh9fy
    @ThiagoSilva-vh9fy 2 года назад +2

    For the first time in many years I feel proud for being Brazilian.

  • @mfaizsyahmi
    @mfaizsyahmi 2 года назад +15

    Funnily enough I learned Lua when I was an admin on a Wikia (now Fandom) site. Did some cool stuff with it, like parsing a bespoke record format I created to draw tables, which is nigh impossible with wiki markup. Things went sideways and I left but the things I learned on the Mediawiki environment I'd always cherish.
    Lua being the scripting language of choice of many programs like VLC and Garry's Mod makes it easy for me to dip my toes into them too, as I approach them as a returning Lua coder instead.

    • @thewitheredstriker
      @thewitheredstriker 2 года назад +1

      holy shit I'm pretty sure I recognize you -- aren't you the guy who made Notiplus?

    • @heyoudodobird
      @heyoudodobird 2 года назад

      how to script: ruclips.net/video/7fn-qMlC864/видео.html

  • @_mickmccarthy
    @_mickmccarthy 2 года назад +20

    Ugh, now I'm getting docked hipster points for my preferred language being covered on this channel! ;)
    Understandable omitting the use of metamethods & metatables given the 100 second overview, but they are a very powerful concept that allow you to (amongst other things) write in an object-oriented manner also. Definitely worthwhile exploring for any folks interested in picking up Lua

  • @gaeel330
    @gaeel330 2 года назад +12

    Fitting that, on St Valentine's day, you post a video about my first and only programming language crush

    • @_mickmccarthy
      @_mickmccarthy 2 года назад +2

      Sounds like a perfect reason to check out the LÖVE videogame engine/framework! It makes use of Lua for all of its scripting

    • @gaeel330
      @gaeel330 2 года назад +1

      @@_mickmccarthy That's actually how I got started with Lua, yeah

  • @pinko_blox
    @pinko_blox 4 месяца назад +17

    Roblox studio anyone?

  • @Maksym_S_real
    @Maksym_S_real 2 года назад +7

    2:24 minutes are not 100 seconds

  • @HarmonyIsDead
    @HarmonyIsDead 2 года назад +14

    Lua has to be one of my favorite programming languages.

    • @skyhappy
      @skyhappy 2 года назад +2

      Why so

    • @HarmonyIsDead
      @HarmonyIsDead 2 года назад

      @@skyhappy It was one of the first languages i could properly code in. also it was pretty easy to learn.

    • @周杨-r1c
      @周杨-r1c 2 года назад +1

      Can you tell me what interesting things you do with Lua?

    • @HarmonyIsDead
      @HarmonyIsDead 2 года назад

      @@周杨-r1c i made a really bad discord bot this one time

    • @creamcheese5328
      @creamcheese5328 5 месяцев назад

      ​@@周杨-r1cyou can make anything you can imagine

  • @fidelguajardo5990
    @fidelguajardo5990 2 года назад +44

    I really like functional programming. At the moment I am really loving Elixir. I hope you can cover it in the near future. Thank you for all your GREAT content!!!

    • @matj12
      @matj12 2 года назад

      @@ChristophBackhaus I think that functional programming goes well with object-oriented programmming. Scala is an example of that.
      Such style is possible even in Java with streams, records and some elements of pattern matching, but it's annoying there because streams are single-use and there needs to be a lot of boilerplate.

    • @brnuovncs
      @brnuovncs 2 года назад +2

      Coincidentally it's a Brazilian language too!

    • @heyoudodobird
      @heyoudodobird 2 года назад

      how to script: ruclips.net/video/7fn-qMlC864/видео.html

  • @gamerobotjimmy
    @gamerobotjimmy 2 года назад +12

    Lua was my first real language, but for doing certain things I learned some other languages, because I assumed that since those languages are more popular, they must be better; now you have blown my mind.

  • @Linuxdirk
    @Linuxdirk 2 года назад +2

    1:12 … I totally dislike the syntactic sugar! Functions are just variables!
    local foobar = function()
    -- function code here
    end

  • @Toprak135
    @Toprak135 2 года назад +3

    More like 144 seconds.

  • @pinkdiscomosh2766
    @pinkdiscomosh2766 2 года назад +13

    Every time I watch one of these 100s videos, I makes me want to diver right into what ever it's about. Most of the time lol. Lua seems very interesting. Great video

  • @sinom
    @sinom 2 года назад +4

    'dynamic language' and 'no type annotations are required' are two different things. You can write a C++ program always using auto etc. but it still isn't dynamically typed.

  • @stokbrood
    @stokbrood 2 года назад +5

    I only know this language because of ComputerCraft

  • @incbionic9804
    @incbionic9804 2 года назад +2

    I ❤️ Lua!

  • @sunofabeach9424
    @sunofabeach9424 Год назад +2

    1:42 no you do NOT put Unicode in Lua strings. I mean you can do that but it wll most likely lead to bugs. Lua uses C library to handle strings that are basically byte arrays and it is unprepared for Unicode so it will screw up string related tasks in delightful ways

  • @ARandomSub
    @ARandomSub 2 года назад +6

    LUA was really fun to learn when I was making WoW mods. It became a meme at my company where I would suggest we rewrite the front end of our entire application library in LUA at almost every standup meeting ha

  • @EmmanuelNgwandu
    @EmmanuelNgwandu 2 года назад +6

    Some parts of VLC player are written in lua. There is where I saw it in action. Thanks

  • @Gruak7
    @Gruak7 2 года назад +9

    I'd love to see a video about fp-ts library for functional programming in typescript. It (un)suprisingly gains a lot of traction right now, at least in terms of npm downloads per week.

  • @firetecstudios1146
    @firetecstudios1146 Год назад +2

    Also, you can use Lua in Minecraft, with the Computer Craft or Open Computers mod!

  • @Joeyfield0
    @Joeyfield0 2 года назад +13

    "starts at 1" SOLD

  • @hdtlab
    @hdtlab 2 года назад +48

    This language looks cool actually. Lua can be found in most industrial embedded devices like sensors, PLC, and HMI development toolkit. I still don’t get why it is so underrated.

    • @Pyrohawk
      @Pyrohawk 2 года назад +29

      Its underrated because Google chose Python, and a lot of really important libraries followed suit.
      I believe in Lua supremacy.

    • @iamunamed5800
      @iamunamed5800 Год назад +14

      @@Pyrohawk I mean its just true. The only thing Lua is really missing is more popular libraries. If it had that it'd be a solid competitor to Python.

    • @dmitrykargin4060
      @dmitrykargin4060 11 месяцев назад

      ​@@iamunamed5800 LUA is intended to be a simplest-but-functional scripting language to be added to your C program. It is not self-sufficient by design. LUA must drop this simplicity principle to be able to become self-sufficient and be able to compete with python. It will effectively prevent LUA being LUA.

  • @bishwajitkar2165
    @bishwajitkar2165 2 года назад +8

    I use Awesome window manager as daily driver in my debian machine, which is fully written in Lua. So I had to learn a little bit of it in order to customize my desktop to my linking. I found it super easy to get my head around quickly and had a lot of fun configuring (after coming from Qtile which is written in Python).

  • @akashdoppalapudi3548
    @akashdoppalapudi3548 2 года назад +10

    Man! I've never known that a language existed with these many features and syntax easier than python.

    • @_quixote
      @_quixote 2 года назад

      It's still hard

  • @rsho3472
    @rsho3472 2 года назад +1

    I don't understand a single s**t about what you just told me, I hope I can come back one day to this video and understand everything that you are saying

  • @ScipiPurr
    @ScipiPurr 2 года назад +7

    Back when I was still first learning programming I got super burnt out on C/C++ over the years. Lua was the language that reignited my love for programming and games development. It can be such a joy to use!

    • @inserteunnombreapropiado9079
      @inserteunnombreapropiado9079 11 месяцев назад +1

      Same history: I started to learn programming with C++ and it was hard. I mean, got many of the concepts of programming, but it wasn't funny. Then, I wanted to learn how to make games in Roblox and win money and I got to learn Lua. Now I don't make Roblox games, but I use Lua for pretty much any programming task I want.

  • @Imevul
    @Imevul 2 года назад +7

    First introduction to Lua for me was World of Warcraft modding, but nowadays I use it only for programming stuff in modded Minecraft (CCTweaked, OpenComputers). Oh how I despise meta tables though. I've been doing OOP for so long that my brain is wired to think in classes. It's a neat language though, as long as you're open to think a bit differently.

  • @ch1caum
    @ch1caum 2 года назад +6

    I'd also add that lua has proper tail call recursion, so you can use functional paradigms without bloating your stack (yes I'm looking at you python) - and this was before funcional programming was hip.

  • @Apollo1_
    @Apollo1_ 2 года назад +11

    would love to see some scala stuff too! great content as always

  • @quut6594
    @quut6594 2 года назад +3

    0:34 also for roblox executors; hacking

  • @JoaoPaulo-ox6pr
    @JoaoPaulo-ox6pr Год назад +1

    Lua was my first contact with a programming language, i had about 12 years and just knew back then "Lua is used on Roblox, then if I learn Lua, i can make a roblox game", but i stopped learning it as soon as i started due to loss of interest.
    After about 3 or 4 years later i started to learning python, i ve had a very good experience, as expected, but then, when i was learning Django, i've discovered that was better to learn HTML+CSS+JS first, because, even with decent abilities in python, i couldn't build anything interesting without this knowledge, then, i stopped with python for a while and started to learn Javascript in the pandemic. Recently i learned React, and here i am now, preparing to study node.js(and maybe another framework such Electron or Next), then i must return to python to finish something i couldn't finish before.

  • @RobertWildling
    @RobertWildling 2 года назад +4

    Those fancy fluid logos - who makes them? And how? Any chance you could make a short tutorial about those? Really, really beautiful!

    • @talkysassis
      @talkysassis 2 года назад +1

      In Davinci Resolve (Or Fusion) you can just make a Fusion template with nodes and change the source image. Then you can reuse this template.

  • @lauej
    @lauej 2 года назад +4

    I spent much of my childhood playing with lua in first Roblox, then Garry's mod and World of Warcraft. It might even be the main reason I study cs today.

  • @notletiuldawg
    @notletiuldawg 2 года назад +6

    Also lua has something like classes yes, but you need to have metatables and etc
    Example:
    local clss = {}
    clss.__index = clss
    function clss.new()
    return setmetatable({}, clss)
    end
    function clss:hi()
    return "hi mom"
    end
    local a = clss.new()
    a:hi()

    • @gamemoves2415
      @gamemoves2415 2 года назад

      No one cares.

    • @Zartymil
      @Zartymil 2 года назад

      why are you writing "clss" instead of "class"?

    • @vitor.torino
      @vitor.torino 2 года назад +4

      @@Zartymil so you don't confuse it for the keyword 'class'

    • @enivo2363
      @enivo2363 2 года назад

      @@gamemoves2415 I do

  • @Topher7lol
    @Topher7lol 9 месяцев назад +4

    This video helped me understand Tables a bit beter, thanks Fireship!

  • @teststuff2962
    @teststuff2962 Год назад +2

    as someone who has been learning game dev on roblox for a while n is taking a cs class where python is being taught i can guarantee that lua is so much easier to learn

  • @lakshyasaharan5348
    @lakshyasaharan5348 2 года назад +7

    All singles on Valentines Day, coding pls give your attendance

  • @DookyButter
    @DookyButter 2 года назад +4

    @Fireship, do Django in 100 seconds!
    Lua is completely underrated. I played around with it to show my kids how to build their own Roblox games, and it was a joy to work with.

  • @daiangan
    @daiangan 2 года назад +6

    It is also used in Adobe to create plugins for products like Lightroom and Photoshop.

  • @eternitydev
    @eternitydev 20 дней назад +1

    not totally right, roblox use it own language called "luau", luau is a customized lua version 5.1 since 2021.

  • @GabrielLima-gz8zg
    @GabrielLima-gz8zg Год назад +1

    Popular programs that uses Lua in some way:
    - AwesomeWM (Window Manager)
    - Neovim (text editor)
    - Wezterm (terminal emulator)

  • @MrSamkots
    @MrSamkots 2 года назад +4

    A lot of game engines use Lua as the scripting companion of C++.
    That's because it's fastest among the dynamic languages.
    Take CryEngine, for example, the engine behind Crysis!

    • @gimcrack555
      @gimcrack555 2 года назад

      I started out using a 2D gaming engine call Love. That's how I started how to program with Lua. Did a very cool Breakout Clone game using the Love gaming engine.

  • @lenikk137
    @lenikk137 2 года назад +3

    sorry but that was 144 seconds.

  • @vicradon
    @vicradon 2 года назад +17

    Perfect timing. I'm writing a Lua related article on O3DE(formerly Lumberyard). Thank you Jeff.

  • @YharonTheReal
    @YharonTheReal Год назад +2

    C++ still better

  • @lucasthech
    @lucasthech 2 года назад +2

    I'm brazilian, use lua and never knew it was created here!
    (obviously I noticed the name, but never questioned it's origin because of this)

  • @FireSiku
    @FireSiku 2 года назад +20

    Lua starting arrays at 1 is a very interesting thing because it was a logical design choice based on INDEX, so if your array has one item, it should be 1.
    I feel like the reason why C arrays started at 0 has been lost to time. It did that because it was an OFFSET.
    C arrays were a pointer at a memory address of the first item. So address+0 is the first item, address+1 is the second item, etc.
    Most languages dont even operate like that anymore so it doesnt make sense anymore.

    • @bit2shift
      @bit2shift 2 года назад +4

      "Most languages dont even operate like that anymore so it doesnt make sense anymore."
      That's where you're wrong. Any language that compiles down to native machine code still has to deal with arrays being 0-indexed.
      A language with 1-indexed arrays like Lua naturally incurs a small performance penalty on each array access since it needs to subtract 1 from the array index before accessing the underlying memory location, unless, of course, said language chooses to reserve the 0th array element to store array metadata.

  • @ProfreshionalLifeBeyond
    @ProfreshionalLifeBeyond Год назад +4

    A brilliant and thorough introduction to Lua. Thank you for your 100 second session. Much appreciated from beautiful Melbourne Australia from an ex-software engineer.

  • @PauloCesar-td9xo
    @PauloCesar-td9xo 2 года назад +19

    As a brazilian developer I'm astonished to not being aware of this, as always great content!

    • @Polaroid1995
      @Polaroid1995 2 года назад +4

      Elixir was also created in Brazil !

    • @snk-js
      @snk-js 2 года назад +1

      me too, that's mind-boggling

  • @megadumgreeny7885
    @megadumgreeny7885 Год назад +2

    ‘Famous’ for being ‘underrated’
    Ok I get it

  • @rodev819
    @rodev819 2 года назад +2

    u mean 144 seconds of lua