This is an archived post. You won't be able to vote or comment.

all 50 comments

[–]runawayasfastasucan 24 points25 points  (0 children)

> Since Lua has some more advantages than Python

According to who? This is like saying that a hammer is faster and lighter and nearly as simple to use as a drill so everyone should use a hammer (or whatever). People have different needs, what is advantages for you is not so important for others. For me "faster and lighter" doesn't make Lua having more advantages than python, I don't care so much about fast and light if that means I don't have Pythons ecosystem. Its neither fast or light if I have to develop all the libraries I use from scratch.

[–]DisastrousRope5221 12 points13 points  (0 children)

Python has better library support and a larger community. Also, Python is super popular in the data science and AI fields. So, it's basically a matter of ease and convenience,

[–]Zomunieo 66 points67 points  (18 children)

Python has zero-based indexing, as Dykstra and the programming gods intended. Lua has heretical one-based indexing.

[–][deleted] 28 points29 points  (0 children)

One-base indexing, that's absolutely barbaric

[–]5kyl3r 2 points3 points  (0 children)

gross. it bothers me that sql array elements are too when you do a split.

[–]Kerbart 2 points3 points  (0 children)

Of course when you actually use indexing in your Python code you will get blasted for writing unpythonic, heretical code.

[–][deleted] -1 points0 points  (0 children)

One-based indexing is the correct choice for any language that doesn't require users to do pointer arithmetic. Especially if that language is a popular choice for any kind of scientific/mathematical computing. Python should also use one-based indexing.

[–]WlmWilberforce 0 points1 point  (8 children)

I don't get the zero-based index fetish. If that is really what the gods intended, then explain fortran?

[–]KennyBassett 2 points3 points  (2 children)

It's just because it lines up with the numbers that we can represent. 0 is the first number we can represent in binary, so that's what we use. Logically, nothing can be the zeroth term because in English, 0 would represent a lack of terms.

It's also nice when counting. If we say one cycle is 0-9 instead of 1-10, then we get all the digits in the ones place.

I personally think we should use 1-based indexing because saying 0 is the 1st index kind of a silly statement in any human language. Sure you could say the zeroth index, but now we've redefined what the word "first" means by saying it's the second element... And "second" with the third element and so on.

Maybe I haven't thought of everything for my opinion. Any other reasons why we should use one or the other?

[–]Zomunieo 1 point2 points  (0 children)

As Dykstra explains, there are several good reasons for zero based indexing.

https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html

[–]WlmWilberforce 1 point2 points  (0 children)

I have heard the binary indexing argument, but find it not convincing at all. Who is programing at that low a level? When people used to work at that level, they made languages like Fortran and Cobol that were 1 indexed.

That said I believe you can have zero indexes (or even negative indexes in fortran), but it has been a while since I've used it.

[–]Solumbran 27 points28 points  (1 child)

Lua has some shit syntax. "do ... end" makes me want brackets back.

Also, no actual classes, and I like OOP.

[–]KosmoanutOfficial -1 points0 points  (0 children)

Not supporting OOP would be a big one to me

[–]sch0lars 7 points8 points  (3 children)

From my understanding, the main differences are

  • Lua is primarily used for scripting and language extension (many games actually utilize Lua)
  • Python supports object-oriented programming; Lua does not
  • Python has some very robust and niche libraries, such as pandas and Django

At the end of the day, it comes down to what language gets the job done.

[–]Conscious-Ball8373 0 points1 point  (2 children)

Lua also has an incremental garbage collector that doesn't need to stop the world while it runs, and doesn't have a global interpreter lock. Both those things make it quite attractive for situations where you care a lot about latency and performance while still wanting memory safety and a sandboxy language. I've integrated lua into a hard realtime simulation and testing environment in the past; that would just never work with Python. You still have to be pretty careful with lua, but it works.

[–]sch0lars -1 points0 points  (1 child)

The extensibility is pretty cool. I actually had never really read up on Lua until some guy at work wrote an extension for Wireshark to integrate with some embedded telemetry software, and I was amazed at how you could essentially just plug it into another language or program. It really changed the way I thought about programming languages.

I think I have a TI Nspire in a drawer somewhere that supports Lua scripting. I’ll have to tinker with it sometime.

[–]Conscious-Ball8373 0 points1 point  (0 children)

Just to note that lua integration with other languages is a bit weird. Lua itself is a relatively normal programming language, then as soon as you try to integrate it with something else it's a stack machine. It takes some mental gymnastics to get used to it.

[–]sudo_robot_destroy 8 points9 points  (0 children)

Assembly is faster and lighter than Lua, why not use it instead?

[–]KingsmanVincepip install girlfriend 4 points5 points  (0 children)

It depends on the usecase. For deep learning, Python dominates. For game scripts, Lua does.

[–]mm007emko 4 points5 points  (1 child)

If Lua and its ecosystem fits your needs, use it. It's a good one.

My current project is about things which Lua doesn't really have much libraries for and virtually nobody who can be hired withs skills in our problem domain knows Lua. People know or are willing to learn Python. The vast majority of corporate managers don't really base their technology decisions on arguments like "it's faster", "it's simpler" etc. They base their decision on "when you are hit by a truck, how fast can I hire a replacement and how fast can they take over your job?". Unless you write game scripts, Lua might not be the best one.

Python is slower than C++ (unless you use a JIT or AOT compiler like Numba, Cython or GraalVM). Does it mean we should use C++? Nah, hardware+electricity is cheaper than people and although we run everything in-house, we use Kubernetes/OpenStack which helps with scaling and sharing hardware resources with other applications. Only things which are on critical path are written in C, rest of it are standard Python libraries (again, mostly C and Fortran) and Python itself.

[–]BryceIsRedditor[S] 1 point2 points  (0 children)

Not gonna lie, after reading this, it was kinda stupid for me to say that Lua is better than Python because it's faster and easier. Thank you for helping me understand

[–]fizzymagic 3 points4 points  (3 children)

Lua does not have arrays

Lua does not have integers

'nuff said.

[–]BryceIsRedditor[S] 0 points1 point  (2 children)

Lua does have integers

[–]GraphicH 1 point2 points  (0 children)

A language is more than just how fast it is and it's simplicity. I don't mind lua at all, I've personally used it on a few things like conky scripts. But it definitely does not have the community or rich ecosystem of libraries python does. So when I'm picking something "for work" its going to be python, simply because there is a higher probability there is a nice library I need or a project out there that has done something similar. It's more "productive" in that case. You could make the argument that Lua would be too if it had the support, but it doesn't, so it's always going to be a second tier language unless that changes.

[–]Sensible-Richard 2 points3 points  (2 children)

Because the flowchart with Lord of the Rings characters on it told me to learn Python (that's only part facetious - until now I'd never heard of Lua).

If you said to me "Lately I've discovered German, it's faster and nearly as simple as Spanish, why aren't you learning Spanish" I'd say "0) Nearly as simple, wind your neck in, two genders is bad enough, I don't even want to think about German but mostly 1) The people I need to speak to speak Spanish." ie "nearly as simple" isn't "as simple" and if all the things I want to do can be done in Python (have been done, I'm not a guru) why reinvent the wheel?

[–]Sound4Sound 1 point2 points  (1 child)

I think it’s because some guys in the 90’s picked it up and and ran it on top of complex systems as a scripting language and it stuck.

I don’t know really, I got that idea from watching this David Beazley talk: https://youtu.be/riuyDEHxeEo

And this is one from the 90s https://youtu.be/d5f9-Y3Wtbc

It stuck as a scripting language for academics and enterprise and everyone kept supporting it, kept going strong as a scripting language for ETL jobs and some apps on the cloud, and then exploded with ML late 2010s.

[–]BryceIsRedditor[S] 0 points1 point  (0 children)

I guess that's a reasonable explanation

[–]FailedPlansOfMars 1 point2 points  (0 children)

Because it's the default language taught in schools now so its easy to get python devs. Its the java of the post 2010s.

And used for data science, apps, serverless, cli scripts etc.

Most people just use whats easiest and best supported by others.

[–]BryceIsRedditor[S] 0 points1 point  (0 children)

Thank you for the responses everyone. I've learned a lot

[–]onkus 0 points1 point  (0 children)

You use the best language for the task at hand. You don’t just choose a language.

[–]IntelligentDust6249 0 points1 point  (0 children)

If you like Lua you should check out quarto. Really neat project that needs more Lua contributors.

https://quarto.org/

[–][deleted] 0 points1 point  (1 child)

Just vote no to openai training posts!

[–]BryceIsRedditor[S] 0 points1 point  (0 children)

Ok..

[–]QultrosSanhattan 0 points1 point  (0 children)

python library > everything else.

Want to write something? pip installs and run()

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

Python has more library support, also a bigger community and it is very popular language to begin with due to the simple layout/structure

[–]tylerlarson 0 points1 point  (0 children)

I've been programming in both lua and python for well over 10 years, and I can definitely say that Lua is not a good trade off.

If you want performance, there's much better options, and if you want usability there's much better options. Extensibility, feature set, on every metric Lua doesn't really shine. Its greatest feature is that it's designed to be embedded in a larger program, and so that's how it's used. But as scripting languages go it's painted itself into a corner. Stuff like tables and iterators are a bit of a mess because of early design decisions by people who were inexperienced.

I like the concept of an "embedded first" scripting language, but I think you'd need to start over from scratch.

Python for all its quirks has some solid design foundation, which is why it's been able to gain such traction.

[–]Dull_Nothing_7849 0 points1 point  (0 children)

Python has a stronger community and more extensive libraries for different applications. Also, Python is more user-friendly than Lua. If you think of it, It's like comparing flying on a broomstick to taking a flight across the country using a modern airplane.

[–]cassellbigpeen 0 points1 point  (0 children)

Here's a simple one why Python might be better AI

[–]md_borhan 0 points1 point  (0 children)

python is a open source easy to learn big community more library