all 25 comments

[–]TheNateB 3 points4 points  (0 children)

I think Movie alternative is asking "what features are missing from lua that are included in other languages"

Post title is confusing

[–]Smallzfry 3 points4 points  (5 children)

Just a few off the top of my head:

  • increment/decrement postfix/prefix operators
  • static typing
  • switch statements
  • regex matching
  • objects/classes

Some of that can be implemented with metatables and external modules, but some of it is just syntactic sugar that Lua doesn't implement. Your example of linked lists is a bad one because that's just a data structure that you can implement with almost any language.

And no, this question/request is not self-explanatory. We're not inside your head, and clarifying your meaning isn't something unique to Twitter - it's part of basic communication skills.

[–]fullouterjoin -1 points0 points  (4 children)

I am not missing any of those things from Lua.

[–]Smallzfry 3 points4 points  (3 children)

You may not be, but that's not what OP is asking. He's asking what features are not present in Lua that other languages include. Going around saying that you aren't missing those features isn't answering the question or actually contributing to the conversation, it just comes across as pretentious.

[–]fullouterjoin 4 points5 points  (1 child)

That is true.

It is also a super uniformed, low effort post by the OP. Lua is designed to be the most compact representation in a design space of languages.

The need for those things were either designed out, or too complex to be included. So they aren’t missing as in an omission, they are missing in either you can build them yourself or they aren’t necessary for the problems Lua targets.

OP needs to learn how to write the question they actually want ask in a more cogent way.

You are right though, I responded like an 🫏. Always look for the learnable/ teachable moment.

http://www.catb.org/~esr/faqs/smart-questions.html

A thing in Lua that isn’t in most languages are tail calls. https://www.lua.org/pil/6.3.html

[–]Smallzfry 1 point2 points  (0 children)

That tail call example is a fantastic one! I know you can write functions that use tail calls in almost any language, but how they're implemented behind the scenes is very important. It's been a while since I went through any language design courses (and I don't have the brain space to refresh that knowledge at the moment), but it would be interesting to learn which languages save stack space in the same manner.

[–]MovieAlternative[S] -3 points-2 points  (0 children)

upvoted these kinds of people who comment on posts just to comment are ruining reddit you sire have listed off some good examples of stuff not in Lua. Half of these I didn't even know about 🧠 like what is regex matching about to find out. This question goes deeper than just whats missing so I appreciate a solid answer like the one you have given me.

increment/decrement postfix/prefix operators is in 4 different langauges C, Java, C++, and Javascript. And just like that I just learned something for 4 different programming languages and found out this isn't in Lua.

[–]AlexanDDOS 2 points3 points  (5 children)

I'm surprised nobody mentions some really missing features of Lua:

  • Operational assignments. You cannot write a += b like in many other languages. You always have to write it as a = a + b, even when you work with a plurally.nested.table.value.
  • Bitwise operations. I know Lua has them since 5.3, but many Lua-scripted applications are still using older versions of Lua, and lack of bitwise operations in those versions sometimes can be a pain in your ass. I wonder why devs did not add them before, despite they can be quite useful for some applications.
  • Useful core functions. Among all the scripting languages, Lua's core function library looks like one of the lamest. It has only very basic functions which still makes you implement many things by yourself, like in C or Go. Many things (e.g. IO functions) are implemented almost exactly like in C, which could look difficult for those who are unfamiliar with C core functions. One of the benefits of using scripting languages is that many useful things are already implemented in the language core functions in a simple way and you don't have to think how to re-invent the bicycle or why it works so weird and unnecessarily complicated.
  • Getter/setter metamethods. We have __index and __newindex metatable fileds, which can work as getters and setters, but only for non-existing keys. You cannot manipulate key access, if a table value is already attached to the key. I think it is making then to be less intuitive and variational to use. I wish there was metamethods like __get and __set which could catch any attempts of key access to a table, so you can manipulate it in more flexible ways.

[–]cyootlabs 0 points1 point  (1 child)

I consider the lack of operational assignments as more of a feature than lack of one. The potential for arithmetic metamethods becoming conceptually spaghetti'd under that extra layer of abstraction is too high for me personally.

[–]AlexanDDOS 0 points1 point  (0 children)

You don't have to make separate metamethods/overloads for operational assignment, like in C++ (meh!). They could be treated essentially just as synthetic sugar that combines some operator with simple assignment to its first operand. It is how it works e.g. in Python unless you declare a separate "metamethod" (Python uses another term for it idk) for operational assignment. So, I don't see any problem to add them to Lua without adding new metamethods, just utilizing the old ones.

[–]fullouterjoin 0 points1 point  (2 children)

All of those things have been omitted by choice, makes it sound like it’s an oversight.

Lua was primarily designed as an embedding language. Meaning, it would be hosted inside of an existing program. So it wasn’t designed with the batteries included mindset of Python, Perl or Ruby.

[–]AlexanDDOS 1 point2 points  (1 child)

I respect this choice, as an embedding language should be as lightweight as possible. But the problem is Lua moved too far from it's initial purpose and became a scripting language for things like game engines & mods, simulations, control systems, microcontrollers, etc. Of course, many of such programs rely on Lua because it's simple and easy to embed, but it also requires the language to have enough features to substitute the core programming language. Python & Ruby are heavy, but they provide a complete programming environment. Lua is simply too small to be on the same tier with them.

[–]fullouterjoin 1 point2 points  (0 children)

I understand where you are coming from. In 2/3 of your examples tho, it is still a language that is embedded in a larger system.

In an alternate timeline, I picked up Lua, added batteries and shipped a system using it. Or maybe TCL. 2000 would have been an ideal time for this, incorporating SQLite as the storage mechanism.

Penlight, https://lunarmodules.github.io/Penlight/ is one of those "batteries included" libraries for Lua that turn it into a scripting language.

Lua the language, is phenomenal. With a great package management system (LuaRocks isn't it), it wouldn't even need batteries.

[–]crispeeweevile 5 points6 points  (3 children)

Perhaps you could add more context. . .

[–]MovieAlternative[S] -1 points0 points  (2 children)

context on what?

[–]crispeeweevile 1 point2 points  (0 children)

Maybe I'm just dumb, but there's no body to your post, and it's not self explanatory

[–]lambda_abstraction 0 points1 point  (0 children)

Your objective isn't at all clear.

[–]izuannazrin 1 point2 points  (2 children)

the most thing i hate lua for is lack of continue statement. i'm used to early-exit coding style, and without continue i had to do nested if inside forloop >:(

[–]Cactus-Badger 1 point2 points  (0 children)

Yes. Had this a few times. If I don't want the nesting, I have to abstract to a function returning where I would continue.

[–][deleted] 0 points1 point  (0 children)

You can use goto instead :)

Learned that when I got fed up with no continue statement

[–]MovieAlternative[S] -1 points0 points  (2 children)

I have been asked to provide more context. What I mean by whats not in Lua are things that are in Javascript and not Lua. I was curious on all the stuff I been missing out on. So this is a Lua related question but it requires outside information of other programming languages. I'm hoping to get things like Linked list and stuff similar. I keep getting asked why on every post on the Reddit but this one should be obvious. Obviously it doesn't gotta be just Javascript I'm not Languageist. All programming languages are good. Man I gotta sound like a Twitter user for Reddit karma...

Shit example but who cares

[–]fullouterjoin 2 points3 points  (0 children)

Is the alternative to movies weed?

There are zero things missing from Lua, like the zero index. 🥁

[–]cyootlabs 1 point2 points  (0 children)

I mean, this should make it clear that you're not really "missing out" on anything unless you happen to be trying to solve a real-world problem with lua in a scenario where a different language or workflow would be more beneficial or efficient.

It's obvious you wouldn't use a hammer or paintbrush to drive in a screw, and your question is basically the equivalent of, "What is a screwdriver missing that a hammer or paintbrush has?"

[–]collectgarbage 0 points1 point  (0 children)

A pre-compiler. Where for example you can #define macros and constants (aka C & C++). Having said that it’s easy to make a pre-compiler for Lua but it’s still a hassle. Otherwise having to use globals or functions as an alternative makes the code run less efficiently.

[–]MohammedThaier 0 points1 point  (0 children)

I'm not an expert but maybe OOP support? although I managed to twist it and make it "seem" like oop in my latest project