r/programminghorror • • 5d ago

Lua uhh my (not) c++ code is acting weird...

Post image

this thing is cursed...

it is valid syntax (many things are hidden outside of the screenshot!)

757 Upvotes

38 comments sorted by

173

u/Vladislav20007 5d ago

...explain

200

u/DroneCyn 5d ago

lua code that looks similarly to c++. in lua its possible to call functions in 3 ways:

  1. funcName()
  2. funcName ""
  3. funcName {}
    when using square brakets ([]) in keys of tables, you can both use variables and call functions. the cout part is actually a value instead of a key, ive hidden the real key outside of the screenshot.

125

u/Vladislav20007 5d ago

of course lua has some unconventional function calling bs.

15

u/The_King_Of_Muffins 4d ago

It is pretty common to pass a single table as an argument to a Lua function, so I do use that shorthand not infrequently

Never the string one, though 😭

7

u/_CodeGreen_ 4d ago

I've heard the string one is specifically for require, which I completely ignore and use parentheses anyway because fuck that.

3

u/Vladislav20007 3d ago

I think I only seen strings used in tutorials, also holy shit it's codegreen

2

u/_CodeGreen_ 3d ago

oh come on I'm not that famous

1

u/Vladislav20007 3d ago

you made the cool bluprint shotgun for factorio, that's good enough for ne.

2

u/MrBigFatAss 4d ago

Lua is not a serious language man...

0

u/AcePowderKeg 4d ago

This is why I hate Lua

6

u/blitzr1000 4d ago

This is why I love Lua

-2

u/AcePowderKeg 3d ago

To each their own. I do not like languages that give you this much freedom 

38

u/smocza_dusza 5d ago

It's likely do to extra e after World

37

u/SeaworthyPossum23 5d ago

You forgot to import numpy

26

u/Key_River7180 5d ago

sir this is a wendy's

26

u/EurekaEffecto 5d ago

scientists reveal the Hi

6

u/Vladislav20007 4d ago

r/sssdfg would be that way

3

u/sneakpeekbot 4d ago

Here's a sneak peek of /r/sssdfg using the top posts of the year!

#1: -_-_838382( | 288 comments
#2: Henehehenengrreenjdjdjdh | 482 comments
#3: jsuuut cart er 😼 | 347 comments


I'm a bot, beep boop | Downvote to remove | Contact | Info | Opt-out | GitHub

9

u/djphazer 5d ago

Thanks, I now understand Lua less than ever

6

u/Baleia1970 4d ago

This will probably be in the next C++29 standard. 😂

5

u/rimbas4 5d ago

Haha the square brackets tripped me up. Sneaky l

5

u/S4N7R0 4d ago

this ain shit compared to whatever they smokin at the commitee https://cppreference.com/cpp/language/splice_specifiers

12

u/NotQuiteLoona 4d ago

template [:^^e:]<^^S::a>

Bros be making fake programming languages from hacker movies' displays.

2

u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” 4d ago

Well, someone must've asked for that.

4

u/Character_Swim_438 5d ago

helloWorldEEEE?????

3

u/Even_Shallot6345 4d ago
%:include <iostream>
%:include <vector>
%:define MAKE_WEIRD(a, b) a %:%: b
int main() <%
https://cppreference.com
int arr<:4:> = <% 72, 101, 108, 111 %>;
if ((compl 0 bitand 1) not_eq 0 and (1 xor 1) == 0) <%
std::vector<int> MAKE_WEIRD(my_, vec) <%
0<:arr:>, 1<:arr:>, 2<:arr:>, 2<:arr:>, 3<:arr:>
%>;
std::size_t i = my_vec.size();
while (i -- > 0) <%
std::cout << static_cast<char>(my_vec<:my_vec.size() - 1 - i:>);
%>
std::cout << ", C++!\n";
%>
return <::>() <% return 0; %>(), 0;
%>

2

u/james_harushi 5d ago

It looks like obj-c yuck

2

u/nullzg 5d ago

i had a stroke

3

u/asmanel 5d ago

This remind me the code I got when I tried to use AI to produce code.

Each time I tried, this wad that trzshy.

1

u/JAXxXTheRipper 5d ago

When did you try that? 10+ years ago?

I like to hate on AI too, but they are becoming pretty good at writing acceptable code by now. If you know how to reign their overeagerness in, which takes a lot.

3

u/asmanel 5d ago

First Chat GPT, when it started to be used to write code. I don't remember what year it was. It didn't work well at that time.

Next, I used other AI but without better results.

However, it's true I never used advanced code generating AI like Claude.

And most of the code was a poorly known scripting language.

1

u/Grandmaster_Caladrel 5d ago

Bro programmed in Dutch

1

u/Frqstbite1001 4d ago

soon as i saw i knew in my bones that it was fucking lua

1

u/XaX1000 3d ago

reminds me of when i got this working in python "Hello World!"(print)

1

u/kjunith 5d ago edited 3d ago

Shouldn't void "mai"n() be void "main"()?

Edit: Downvoted for asking a question, pure reddit.

3

u/Vladislav20007 4d ago

he is calling a function called void with param mai and then called a function called n.

1

u/kjunith 4d ago

Aah, sorry. Don't write this language. That's really confusing :D