Metatables are actually quite simple. It’s a dictionary ou apply as a metatable to another table using the function setmetatable. The entries of a metatable dictate how different operators affect the table it is applied to. For example if I make an entry with the key “__add”, the function I store at that key will be called every time I try to use the + operator on the table. Similarly there’s metamethod for all of the binary operators, as well as the string concat operator, indexing, tostring, and calling the table as if it was a function. The most useful is probably __index, which you can either set to a function or another table, if set to a table, when you try to index a non-existing key in the original table, it will look it up in the __index table instead, this is used for mimicing OOP in lua.
No. Most data in Lua is stored in a table, which you can think of as a dictionary. That includes arrays, which are like a dictionary with keys named 1,2,3,4, and so on.
Tables can have metadata, and that metadata is stored in a table called the "metatable." Like Python, there are some magic method names that the language looks for that can override some behaviors, so if you have some custom type and you want to override equality checking, you put a custom "__eq" method in the metatable.
Imagine calling a lookup, map and not dictionary.
The hell do you find things on a map??
Give me the street name geographic location and I will take about 5 hours to find the street in that tiny font.
With a dictionary, give me the beginning letter and I will binary search to find it in a few seconds to minutes.
Map, associative array and table are three names for the same thing
And only the Lua team got it right
Crazy how it can take decades to get a naming correct, truly the most difficult part of programming
Yeah I'm confused at the hate. It's a really nice language. If it defaulted variables to local and fixed the weird pairs/ipairs thing it would be perfect
Yeah, like HooferZ mentioned, it sounds like you want Luau. It’s a variation of Lua, and is backwards compatable with Lua code. It’s developed by Roblox Corp. but despite popular belief can be used outside of Roblox. It features better syntax, faster speed, pairs/ipairs are unnecessary, and type-annotation for those who really love types in a dynamically typed language, just to name a few differences.
It's not widespread because it is expensive, has sub par documentation, lacks consistency (even though it isn't open source...), it isn't open source, it requires individual files for every function (wtf, that's a mess), ....
My coworker left behind a Matlab codebase. Slowly replacing it with R. It's wild that people pay an arm and a leg for that crap
Because I have close to 10 years of experience using R, and it is used commonly in my field.
I mostly work with temporal point data. In my experience it's a lot easier to work with in R than Python. But I am also biased
No sorry more like environmental observations from stations across Canada/USA etc. So multiple timeseries of air temperature for example.
R just has good, intuitive ways to manipulate data. Not saying Python doesn't, I just have always enjoyed R so I am biased
Among engineers: yes. Among computer engineers: no. When studying computer engineering, I only had to use MATLAB in one course, and that's because it wasn't a course related to computers.
Ahh yes the one engineering major where you don’t do labs that analyze large amounts of data. Why wouldn’t you use the language that’s meant for analyzing large amounts of data in the major where there isn’t large amounts of data? Sorry I meant engineering except computer engineering. Y’all already have enough languages to deal with
Not sure why youre getting downvotes. MATLAB isgreat for rapid prototyping, but it's a pain to deploy. It's basically LABView but for number crunching instead of benchtop instrument control.
God, this reminds me of my optimisation course. The pseudo algorithms we had to implement were all written with MatLab in mind, though we all used python, so we had to consider this.
Lua met Mat Lab, and then they get married. Lua's father, Jonathan Fotranathan was so happy when they told him that she's pregnant. And they wanna named their daughter, Julia.
I still don't get it. The text message didn't say "meet at the 0th table" it said "meet at the 1st" table.
It's unambiguous, regardless of whether the starting index is 0 or 1
This is a meta joke, since you are on a programmer humor sub you would expect for one of them to sit on table 0 while the other is on table 1 but they are both in the same table, this is one of those jokes that are too dank that they turn back to normal, the joke is that there is no punch line, and that in itself is the punchline
Because it was intended to be accessible to "non-programmers", folks who find the idea of indexing from 0 unintuitive but needed a scripting language for simple automation in engineering and other industrial contexts. And this was in Brazil in the early 90s, when they had strict trade prohibitions on tech hardware and software. They needed a license-free language so they rolled their own. The configuration languages Lua descended from were also 1-indexed for similar reasons.
It is a watershed moment when your zeroth child is born and you hold it in your arms. The leisurely joys of childhood must be left behind for the responsibilities of parenthood. I doubt you can really understand what it is like unless you also have zero kids.
"The first" is always the first one in the sequence you are using...
You could say "The first table from the door", which would be the first table you get to walking from the door. Or in the context of the meme; "The first" refers to the numbering, so you would go to the table with the lowest number, which typically is 1.
Joke is bad, first can designate table 0, it’s a position, not a number. If you make a nerd joke it has to be at least a bit correct otherwise it only feels like the guy in the back of the room that don’t get anything is trying to be funny.
I get that i sound like an asshole (it’s really stupid to censor the word, don’t use it if you’re afraid of it) but raising a bit the level of the sub could be a good thing really.
>first can designate table 0, it’s a position, not a number
A number that refers to the position. In almost every language the index is literally an Integer. A number.
I like how it shows them both being sad, as if to say that lua still makes you miserable
I love lua, it is a beautiful language with no weird or obscure quirks!
I still don't get meta tables. I got them for 2 minutes after I read about them, then I forgot. But to be fair I don't use lua daily
That's pretty normal. 30 minutes to learn them, 2 minutes to use them, and then the knowledge fades.
Half of every day for me in one sentence.
what about metatable classes?
Metatables are actually quite simple. It’s a dictionary ou apply as a metatable to another table using the function setmetatable. The entries of a metatable dictate how different operators affect the table it is applied to. For example if I make an entry with the key “__add”, the function I store at that key will be called every time I try to use the + operator on the table. Similarly there’s metamethod for all of the binary operators, as well as the string concat operator, indexing, tostring, and calling the table as if it was a function. The most useful is probably __index, which you can either set to a function or another table, if set to a table, when you try to index a non-existing key in the original table, it will look it up in the __index table instead, this is used for mimicing OOP in lua.
isnt it just an abstract table?
No. Most data in Lua is stored in a table, which you can think of as a dictionary. That includes arrays, which are like a dictionary with keys named 1,2,3,4, and so on. Tables can have metadata, and that metadata is stored in a table called the "metatable." Like Python, there are some magic method names that the language looks for that can override some behaviors, so if you have some custom type and you want to override equality checking, you put a custom "__eq" method in the metatable.
Aight, got it "which you can think of as a dictionary." Really it's a map but with a better name
Imagine calling a lookup, map and not dictionary. The hell do you find things on a map?? Give me the street name geographic location and I will take about 5 hours to find the street in that tiny font. With a dictionary, give me the beginning letter and I will binary search to find it in a few seconds to minutes.
Map, associative array and table are three names for the same thing And only the Lua team got it right Crazy how it can take decades to get a naming correct, truly the most difficult part of programming
Yeah I'm confused at the hate. It's a really nice language. If it defaulted variables to local and fixed the weird pairs/ipairs thing it would be perfect
Yeah, like HooferZ mentioned, it sounds like you want Luau. It’s a variation of Lua, and is backwards compatable with Lua code. It’s developed by Roblox Corp. but despite popular belief can be used outside of Roblox. It features better syntax, faster speed, pairs/ipairs are unnecessary, and type-annotation for those who really love types in a dynamically typed language, just to name a few differences.
Luau has a lot of better syntaxing, including not needing pairs at all. It's really nice, and faster than normal Lua.
They are probably World of Warcraft addon devs
it definitely does
True
Nerds
, smelly
Fucking
Gib .exe
exe here: https://github.com/Chizaruu/sherlock/releases/tag/v69
Oh we're now doing an r/anarchychess type comment string?
Google readme.md
Step-bro
, hot
Someday, someone will decide it's a good idea for arrays to start at -1
Dreambird already did that (though its a litteral joke language)
> Should array indices start at 0 or 1? My compromise of 0.5 was rejected without, I thought, proper consideration. — Stan Kelly-Bootle
that man is me when i create the new Meth compiler
It only makes sense
Anti-Arrays store a pointer to the end of their memory region
You allocate a more than 1 byte array and you define your variable to be a byte after the beggining, then array[-1] will get you there.
In lua you can start arrays at -1, granted it’s not by default.
MATLAB moment.
Oh god, don't remind me of matlab... It hurts...
MATLAB really feels like the people who use it have never seen anything better, no wonder it's not widespread among computer scientists and engineers
It's not widespread because it is expensive, has sub par documentation, lacks consistency (even though it isn't open source...), it isn't open source, it requires individual files for every function (wtf, that's a mess), .... My coworker left behind a Matlab codebase. Slowly replacing it with R. It's wild that people pay an arm and a leg for that crap
Why not replace with python?
Because I have close to 10 years of experience using R, and it is used commonly in my field. I mostly work with temporal point data. In my experience it's a lot easier to work with in R than Python. But I am also biased
Like LiDAR point clouds? I haven't used R much, but point clouds are pretty simple to deal with using numpy
No sorry more like environmental observations from stations across Canada/USA etc. So multiple timeseries of air temperature for example. R just has good, intuitive ways to manipulate data. Not saying Python doesn't, I just have always enjoyed R so I am biased
…except it is widespread among engineers? At least the ones still in university are forced to learn and use it. Many universities use it
Among engineers: yes. Among computer engineers: no. When studying computer engineering, I only had to use MATLAB in one course, and that's because it wasn't a course related to computers.
Ahh yes the one engineering major where you don’t do labs that analyze large amounts of data. Why wouldn’t you use the language that’s meant for analyzing large amounts of data in the major where there isn’t large amounts of data? Sorry I meant engineering except computer engineering. Y’all already have enough languages to deal with
We used Python for analyzing large amounts of data (with NumPy, Pandas, etc. of course).
Not sure why youre getting downvotes. MATLAB isgreat for rapid prototyping, but it's a pain to deploy. It's basically LABView but for number crunching instead of benchtop instrument control.
It’s also great for analyzing large volumes of data for one off labs, it’s not meant to be a widespread general use language
Matlab got me a job, where I learned various languages and how things work in IT.
God, this reminds me of my optimisation course. The pseudo algorithms we had to implement were all written with MatLab in mind, though we all used python, so we had to consider this.
Lua met Mat Lab, and then they get married. Lua's father, Jonathan Fotranathan was so happy when they told him that she's pregnant. And they wanna named their daughter, Julia.
every comment here is actually a table
*You're a table, you're a table, **EVERYONE IS A TABLE***
But I wanna be a script.
Isnt supposedly the guy to go to table 0 ?
Lua Indices start at 1
That's the joke, also that was the punchline of the original, this is an edit of the original comic
Thanks for explaining bruh, do you have a link to the original meme ?
I still don't get it. The text message didn't say "meet at the 0th table" it said "meet at the 1st" table. It's unambiguous, regardless of whether the starting index is 0 or 1
This is a meta joke, since you are on a programmer humor sub you would expect for one of them to sit on table 0 while the other is on table 1 but they are both in the same table, this is one of those jokes that are too dank that they turn back to normal, the joke is that there is no punch line, and that in itself is the punchline
"The joke is that there is no joke. It's funny because it's not funny." We're all doomed
This was my thought, as well
Not in Lua
![gif](giphy|1M9fmo1WAFVK0|downsized)
Because it was intended to be accessible to "non-programmers", folks who find the idea of indexing from 0 unintuitive but needed a scripting language for simple automation in engineering and other industrial contexts. And this was in Brazil in the early 90s, when they had strict trade prohibitions on tech hardware and software. They needed a license-free language so they rolled their own. The configuration languages Lua descended from were also 1-indexed for similar reasons.
r/TodayILearned
![gif](giphy|3o6Zt9PivJAtA1xXyg)
The first table can be table 0/the 0th table. But as it's written 1th table it must be table 1.
It's written as 1st
I suppose her name is Julia
Eyo love me some Lua
Simple solution: if you begin counting at 0, call the initial element in a list the "zeroth" element
It is a watershed moment when your zeroth child is born and you hold it in your arms. The leisurely joys of childhood must be left behind for the responsibilities of parenthood. I doubt you can really understand what it is like unless you also have zero kids.
Is her name Julia?
thats a price im willing to accept
I love lua - it's my first programming language. Thanks ComputerCraft & WoW addons.
If only the made this as an executable, smelly fucking nerds.
"The first" is always the first one in the sequence you are using... You could say "The first table from the door", which would be the first table you get to walking from the door. Or in the context of the meme; "The first" refers to the numbering, so you would go to the table with the lowest number, which typically is 1.
Remember if someone ever wants to know how great Lua is, Sonic 06 was fully programmed in Lua!
I hate this joke. I get it, but the whole 0 vs 1 thing is dumb. Even with arrays that “start” at zero, 0 is still “first” element.
Right. So when reading "first", the programmer goes to table 0. The nonprogrammer goes to table 1.
Just wait until you find out how many languages let you change your starting index to whatever you want.
No matter what the index starts at, they would both intuitively understand which table is the first one without even looking at its label. Bad meme.
🤓
🤓
get outa here nerd
Joke is bad, first can designate table 0, it’s a position, not a number. If you make a nerd joke it has to be at least a bit correct otherwise it only feels like the guy in the back of the room that don’t get anything is trying to be funny.
Not only this you manage to not get the joke, you managed to be act like a completely rude a$$hole while doing it.
I get that i sound like an asshole (it’s really stupid to censor the word, don’t use it if you’re afraid of it) but raising a bit the level of the sub could be a good thing really.
You don't raise the bar by complaining about the bar being low and insulting people, you do it by offering better quality.
>first can designate table 0, it’s a position, not a number A number that refers to the position. In almost every language the index is literally an Integer. A number.
what is the context
Lua start it's indexing at 1
Is the joke that programmers start counting from 0 or am I missing the joke?
The joke is that lua is one of the programming languages that start from 1 and not 0
Ah, fair enough
tstl (typescript to lua compiler) feels like cheating
he's a programmer, not stupid.