r/lua • u/ilPlayerdiGD • 13d ago
Lua it's the best high-level programming language
I need to talk about lua. I started with Python then I passed to C and C++ (my favourite languages). Now, I tried re-learning Python to have a 3nd programming language but I did found that in reality Python it's boring and bs! I tried Zig and it was a bad experience, I tried Rust but idk why but I think it's overrated. Then, at the end, I tried lua and at first I though that lua was stupid, no i++ or i+=, arrays start at 1… but then I tried do C/C++ + Lua and I changed my perspective.
I used, recently, lua for configs in my projects but then I discovered that Lua it's SO underrated. Like they didn't lie when they said C and lua are the best programming language.
Lua it's minimal and so powerful. I accepted the syntax and now it's my 3nd programming language.
The reason that I love lua it's because… it's FAST, it's DAMN SIMPLE and so easy to learn, it has A LOT of potential.
The more the language is big, the less likely it gonna be easy to learn.
Guys I don't think I have cons on lua, I think it's perfect and I still don't have learned all of the lua out there.
Really, I have to say… lua it's the best.
Anyway did I say something wrong? What's your opinion on lua?
Anyway, thanks for reading ;)
8
7
u/bluemanZX 13d ago
Similar, first python then rust, next c/cpp because of wide device support and legacy, then advanced bash, recently lua. What I can’t do with bash I’ll try to do with lua. Lua is great.
3
u/ilPlayerdiGD 13d ago
I need to learn real bash. I use the linux terminal everyday but I don't know real bash. I don't automate stuff because I don't need to. Thanks for the reminder!
3
7
u/GardenerAether 13d ago
i cant say i fully agree. i definitely like lua conceptually, and i appreciate its simple syntax. but the lack of static typing and forced garbage collection kinda irk me off of it a bit. it definitely interests me, and i think i would like to use it for some project sometime, but i think ill probably end up making my own language to address some of the problems i have with it im happy to hear you enjoy it and that it addresses your needs in any case :3
1
u/ilPlayerdiGD 12d ago
isn't Python like this? I think every, very high, programming language should be like this and for static types low level. Well I maybe said some bs, let me know 😭
3
u/GardenerAether 12d ago
Actually, python and lua have essentially the same class or type system; python just allows for explicit typing annotations, whereas all of lua's types are implied :3
In my personal experience, static typing is nigh-universally preferable to dynamic (and especially weak) typing. Even ignoring performance (which I think is always important) two benefits of note to me are that they catch a lot of problems early, and make your code essentially self-documenting. Doubly so if the language is functional.
3
u/loonite 13d ago
You can try to adapt Lua itself, the source code is kinda small and very well documented.
I'm not at this point yet, but I would love to see a statically typed Lua with more on-hands memory management. Having the option to use RC/ARC, arenas or maybe something akin to a borrow checker would be really interesting.
4
u/didntplaymysummercar 13d ago
Part of me thinks this is either a shitpost or an overly enthusiastic beginner. Lua (as much as I like it, and I knew it before Python and bash) has some decent sized gaps, like using tables for arrays, missing some table operations, GC being so-so, minor versions being breaking changes, etc.
2
u/ilPlayerdiGD 12d ago
Idk I kinda like lua. It's my third language but it can't be better than C and C++, but the good of lua is that it is Embedded with C and C++! So it's 10/10 for me. It's good for the configs btw
1
u/DoNotMakeEmpty 10d ago
Lua's second version number is not minor version. The general expectation of that goes to semver, which was created later than Lua 5.1
0
u/didntplaymysummercar 10d ago
That number in lua.h is called "minor version" since 5.2 and everyone knows what is meant by "minor" version in x.y.z.
1
u/DoNotMakeEmpty 10d ago
No, minor version meaning backward compatibility is semver, which is as I said younger than Lua 5.1. Between any version you don't need to provide compatibility depending on your version scheme. If you use semver yes minor versions must be compatible. In Lua's own versioning scheme they explicitly enable breaking changes in minor version. It is just your usual dev who knows only one way of doing a thing seeing a different way.
And Lua's release schedule is so sparse that minor Lua versions are released rarer than major versions of many other software, so timeline-wise it is less breaking than most libraries or software.
They probably named second version number as minor due to popularity of the naming, which is misleading but consistent within Lua.
0
u/didntplaymysummercar 10d ago
A moment ago you claimed that there are no minor versions in Lua.
Now you claim I'm wrong to state the fact they break compatibility in minor versions (lua.h itself calls them that) because it's not semver.
Nowhere did I mention semver. Incompatibility between versions is a real problem we face. If they used semver and we were at Lua 9.0 by now it'd be a problem too.
Lua as a language breaks compatibility more often than Python, C and C++. It's a real problem for some or makes people stick to old no longer maintained version.
You're going "well akshually 🤓" like a redditor over nitpicks that aren't even right.
Go away.
1
u/DoNotMakeEmpty 10d ago
The releases of Lua are numbered x.y.z, where x is the series, x.y is the version, and z is the release. This scheme superficially resembles the popular semantic versioning scheme but is not the same, especially regarding compatibility. Here are the details.
Directly from Lua's version history page. They don't call the second number as minor. In the header, they might have needed to discriminate first and second number (which is arguably not needed since x.y is version as a whole). This discrimination did not even exist in 5.1.
Incompatibility is a problem when you must support different versions. Lua is not supposed to be host, so the design choice is that you can break things because you directly use a certain version in your host app. If you don't use a system wide Lua, your scripts cannot be broken. The language developers treat each version as self-contained, you are not supposed to have the latest and greatest.
I have seen more Lua scripts that can run equally well on Lua 5.1 to Lua 5.4 (spanning 15 years) than Python scripts that can run well between consecutive minor versions. Many open source Python libraries can run only in a couple of versions spanning like two years. Venv was not created for nothing. Almost all open source Lua libraries OTOH explicitly say they support 5.1 to 5.4 or nowadays 5.5. It is usually trivial to create 10 loc preludes that provide roughly same functionality in all versions. Incompatibility lists are very short and blast radii are pretty contained.
People stick to older versions because of either luajit, or hosts being stuck (latter being intended).
Oh and if Lua actually used semver, we would have been at Lua 5.0 corresponding to Lua 5.5. Lua before 5.0 can be considered as 0.x (development was fast, too).
And I would not want backward compatibility exactly. Lua is perfect in this regard. Slow and incompatible changes. I am sure that my script has at least 5 years of shelf life even if I use latest only, against intention of developers. And unlike C++ and even Rust nowadays, Lua does not get dirty at each version. Say unpack. If backward compatibility was focused on, we would have both table.unpack and unpack doing literally same thing. If you want, Lua has mechanisms strong enough, that you can write one line and have old unpack. If you don't need it, language is not dirty with two ways of doing same thing.
0
u/didntplaymysummercar 10d ago
LUA_VERSION_MINOR- directly from lua.h 🙄Compatibility between versions is a real problem that even Hisham wrote about.
Your anecdotes about Python (my code uses fenvs and will break in 5.2, meanwhile Python 3.x updates never broke my scripts), venv (Lua and others have similar tools to run different versions, and for Python the main purpose is to isolate installs, not get another interpreter version) or praising breaking as "clean design" or getting hung up on me calling what's after dot "minor version" don't change that.
I'm done wasting time on you.
2
u/DoNotMakeEmpty 9d ago edited 9d ago
Yeah, not existent on Lua 5.1's lua.h. They created versioning system before naming it.
I wrote many arbitrary code evaluators. 10 loc shim has pretty much same feature set on 5.1 and 5.5.
Go and try to install some ml library for Python. They usually say things like "this runs only on 3.9", and indeed runs only like 3.9 and maybe 3.10 if you are lucky. So many things break after I update my Python version. OTOH almost all Lua libraries on github work in 5.1 to 5.4 or 5.5. Love2d works on luajit, lua 5.1 through 5.4, probably also 5.5.
Backward compatibility is really why C++ or Win32 or POSIX are hell. Without breaking changes, opengl would have been abandoned 10 years earlier.
3
3
u/Corruptlake 13d ago
If only there was a low level language with Lua like minimalist syntax, nelua is the closest we got to it but it is incomplete abondonware and frankly I dont like some of its decisions.
3
u/ilPlayerdiGD 13d ago
Yes. Honestly that is a good idea. I will love too a programming language like that!
2
3
u/oluies 13d ago
It is one of several good languages
1
u/ilPlayerdiGD 12d ago
Obviously, there is no BEST PROGRAMMING LANGUAGE. But I think lua it's a VERY good choice
2
u/DannyDeKnito 13d ago
How do you define what a powerful language is?
As for Rust, it was all the hype for a hot second, but now that the hype has died down it seems to have carved out its own niche - but if you try and treat it like a general programming language, it breaks down.
1
u/ilPlayerdiGD 12d ago
Oh good question. Well I think lua it's powerful because it's simple, really legible. I can't explain myself I'm sorry 😭. Anyway I didn't tried all of Rust but I think the syntax of Rust and Zig are both very annoying to me.
3
u/DannyDeKnito 12d ago
Ehhh, I'd rather call that approachable than powerful - poweful to me implies one of two things: great performance, or baked-in low-level abstractions such as memory management, multithreading, etc. Lua straight up does not give you a way to do that - which to me reads as opposite of powerful.
1
2
u/HaiMeoYoutube 12d ago
I hate lua indexing at 1 instead of 0
1
u/ilPlayerdiGD 12d ago
Honestly me too, but for a beginner it's "normal"? Maybe? Well you could do table[i + 1] where if i is 0 then the index is 1. Still annoying but if you really don't like it I think it's better to do it like this. I don't really have problems with lua index, I think. It's not the end of the world.
1
7
3
u/No_Personality_1456 13d ago
Yo soy desarrollador de juegos en Roblox y si es muy simple de aprender llevo ya mas 5 años usandolo para todos mis juegos, pero el lua que se usa en Roblox no es el lua de uso general es Luau, (si solo añade una u al final) y simplemente es lua con esteroides
Su mayor fuerte es su Tipado tan sofisticado de tipos, estabilidad y rendimiento, a comparacion con de lua original la sintaxis es exactamente la misma solo que la variables tambien pueden ser declaradas constantes (const) y es bastante mas escalable para proyectos grandes con las propias herramientas del lenguaje
El unico inconveniente es que usar todas sus funciones que lo hacen distintivo y sofisticado, es tardado y le quita en gran medida la simplesa que tiene lua y su capacidad de ser incrustable a cualquier software
Si no usas su Tipados ni sus funciones avanzadas como --!strict lints o su integracion avanzada para OOP y otras cosas, es simplemente un lua optimizado y ya
(Como dato luau fue escrito casi desde 0 desde la version 5.1 de lua y versiones posteriores a esta ya tienen grandes optimizaciones y luau simplemente añade retrocompatibilidad desde su propio codigo)
3
u/DDDX_cro 13d ago
Supreme commander is made with it. Been able to do wonders, while having zero pr8gramming knowledge. This is pre-AI, mind you
3
u/glisteringbasalt 13d ago
I really like Lua, although I haven't done much with it. It was designed to be a language that's easy to embed into applications and I think the developers have done an excellent job with the design
1
1
u/Background-Path-246 10d ago
Lua es increible, tal vez no sea un Dios por así decirlo, pero yo lo utilizo para videojuegos con Defold, solar2d y tambien lo probé con LOVE2D, siento que este lenguaje elimina la complejidad y cosas inncesarias dejando el campo para que tu lo hagas y lo construyas.
1
1
1
u/thecratedigger_25 3d ago
Lua is the perfect scripting language. It makes bash much easier to work on as well as working alongside C/C++ and even outpacing python. Lua compiler source code isn't very big compared to python source code.
1
u/slade51 13d ago
I never used python & despise C++. My favorite languages are C & Perl, and I don’t mind PHP. I do agree with you that Lua is so quick & easy to use - I’ve been hobby-programming with it for a year or two. I haven’t tried game coding, but it’s great for interfacing with Conky on Linux. For those who say bash is good for programming, I say yes as long as you combine it with awk.
0
u/kutac56 13d ago
I mean bash is also really good
6
u/y53rw 13d ago
No it is not.
1
u/kutac56 13d ago
Whether it is better than Lua is up to personal opinion but bash is definetly really good. Watch some yousuckatprogramming to see it in action
5
u/y53rw 13d ago
That just seems like a guy trying very hard to do things in bash that are very easy to do in any other general purpose language, with no help from the non-existent type system.
2
u/kutac56 13d ago
He has made a lot of useful tools for himself with bash that he uses very often. Also thats just not true. Bash is perfect for commandline interfaces as it parses arguments very easily and is made to build on top of tools and combine them. Bash is an amazing scripting language. Whether it is better than lua is up to personal preference but it def is good
1
23
u/TheV1ruSS 13d ago
yes it's simple but has enough complexity to not be bs. you build the complexity however you want. best language