[HN Gopher] What I think about Lua after shipping a project with...
___________________________________________________________________
What I think about Lua after shipping a project with 60k lines of
code
Author : gamescodedogs
Score : 130 points
Date : 2024-05-31 18:15 UTC (1 days ago)
(HTM) web link (blog.luden.io)
(TXT) w3m dump (blog.luden.io)
| annaglotova wrote:
| 60k lines sounds crazy for Lua...
| fwsgonzo wrote:
| Congrats on shipping a game! It's truly an insane amount of work
| these days, with all the competition out there.
| gamescodedogs wrote:
| Thank you for the kindness :) Doing our best!
| xandrius wrote:
| To be fair, shipping itself has nothing to do with competition.
|
| Still a tough feat nonetheless!
| bru3s wrote:
| Congrats on your game!
|
| Which would you say were the major hurdles you'd found with C++
| that convinced you against using it again?
| lyu07282 wrote:
| what do you think about this take by Jonathan Blow about
| scripting languages in gamedev:
| https://www.youtube.com/watch?v=y2Wmz15aXk0
| ralfd wrote:
| Summary of the video please?
| lyu07282 wrote:
| Jonathan Blow criticizes the use of scripting languages in
| modern game development as outdated and inefficient, pointing
| out that they slow down performance, are error-prone, and
| complicate the development process with extensive engine
| integration needs. He notes that while initially appealing
| for allowing quick iterations and non-programmer
| accessibility, scripting languages often result in poor
| quality, bug-ridden code that requires significant oversight
| from professional programmers. Advocating for robust,
| compiled languages like C++, Blow dismisses scripting
| languages as a failed experiment and praises the shift
| towards more constrained and user-friendly visual scripting
| systems in platforms like Unreal and Unity.
|
| (i don't mean to suggest that i agree with him, I just was
| curious)
| IshKebab wrote:
| Interesting. I feel like his opinion makes sense for first
| party code, but what if you want to support mods? I don't
| really have time to develop them anymore but I did a couple
| in QuakeC back in the day (I'm old) and really enjoyed it.
| IIRC it had lots of domain specific niceties like native
| vector types. One slightly hilarious thing is any loop that
| looped more than 100k times was killed with an infinite
| loop error. Actually saved me a couple of times.
|
| I feel like if there was a nice modern statically typed
| language that was easy to embed I would go with that.
| Something like Dart maybe. But I don't think that's easy to
| integrate.
| wudangmonk wrote:
| Was a lot of the functionality of Quake done in QuakeC or
| was that scripting language added for the sole purpose of
| allowing for mods to the game?.
|
| I think scripting languages are a very bad idea for the
| core functionality of a game and I see no benefit to
| them. If its done after you have nailed down all your
| core mechanics and just want to add mod support for
| things such as player created maps then I think that's
| fine.
|
| That means that a scripting language should only be added
| towards the very end of a project. Adding it towards the
| beginning when you don't even know your core mechanics
| yet seems crazy to me since I see no benefit to it.
| IshKebab wrote:
| The engine was all C. QuakeC was used to script the game
| logic - how weapons behave, doors open, items move
| around, etc. It was reasonably powerful. You could make
| grappling hooks, proximity mines, etc.
|
| I guess the core mechanics of Quake were very obvious. It
| wasn't a very innovative game in that sense; basically
| identical to Doom but with way fancier graphics, controls
| and so on.
| hoten wrote:
| Play any Bethesda game and you understand his points about
| designing your games to be largely scripted by less
| experienced programmers is error proned.
|
| At the same time, the success of Bethesda games despite
| these bugs is an argument against it mattering all that
| much. Not to mention mods, which doesn't really require a
| scripting engine but 100% lowers the barrier to entry for
| community creations.
| vunuxodo wrote:
| > success of Bethesda games despite these bugs
|
| Bethesda bugs are almost an endearing feature at this
| point. Weird stuff happening in the game for no
| discernible reason is part of the charm.
| bawolff wrote:
| I feel like that is the same language design flamewar that
| has been going on for the last 40 years.
|
| The arguments are all the same, neither side is any closer
| to winning.
| slowhadoken wrote:
| Blow is pompous. Lately he pretends to be a mentor but he's
| still immature and insufferable.
| bsder wrote:
| Until Blow open sources Jai, his opinions are mostly
| irrelevant.
| AnotherGoodName wrote:
| Every config file becomes something close to a scripting
| language at some point. Build files, video game maps, etc.
|
| Eg. You have a game with enemies spawning in some circumstance.
| The file that defines the level of the game now needs a bit of
| logic to specify that the enemy spawns given conditions. If you
| don't use a scripting language you'll have a field in that file
| that takes parameters for the conditions. Now do this 1000
| times over for all the other little things you may want in the
| level. Pretty soon your file that defines the level is slowly
| becoming a shitty adhoc scripting language.
| AlphaWeaver wrote:
| > After that, I went back to Dmitry and asked him if my
| understanding of "everything is a table" was correct and, if so,
| why Lua was designed this way. Dmitry told me that Lua was
| created at the Pontifical Catholic University of Rio de Janeiro
| and that it was acceptable for Pontifical Catholic Universities
| to design programming languages this way.
| oh_nice_marmot wrote:
| It's unclear to me what you are trying to say here.
| nmz wrote:
| There's no explanation.
| jmspring wrote:
| https://en.m.wikipedia.org/wiki/Lua_(programming_language)#:.
| ...
| gary_0 wrote:
| It's a joke wryly comparing its uncommon origins with its
| uncommon design.
| adolph wrote:
| Yep, sounded like papal bull
| koeng wrote:
| I've used teal before, the statically typed Lua that is mentioned
| at the end. It's actually really good! There are some limitations
| (especially around generics) that can be annoying, however.
| Overall, I really enjoyed using it and would use it again.
| ardit33 wrote:
| I haven't used the static version, but almost eveyrone that I
| know have used Lua loves it. There is beauty to its
| simplicity/bare bones approach to programing.
| QuaternionsBhop wrote:
| After 10 years and many projects, the greatest with 40k lines of
| code including a time-of-intersection-solving single body physics
| system, I have come to know how to use Lua for my purposes. Even
| so, from the moment I started watching Rust hype videos on
| YouTube, I knew I would eventually be converted into a Rust
| fanatic. At the end of a 2 year project to rewrite my Lua game
| with a new physics system, I felt it was a good time to learn
| Rust (and rewrite the game again in Rust). So far I have spent 6
| months in Rust and my old tool looks like a toy. How did I ever
| live without iterators, algebraic data types, the safety of a
| strong type system, and especially separate types for arrays and
| hashmaps for god sakes?
|
| Lua makes the scope of learning programming smaller compared to
| other languages, so it is probably fair to say that it is a good
| language to learn programming with. However, knowing the details
| of heap vs stack, array vs hashmap, and explaining that to
| someone learning programming for the first time within a language
| that attempts to hide those details is frustrating. I can't see
| the smaller picture and view a table simply as a thing that you
| get and set values from, I can't see the weak types as anything
| more than an annoying source of bugs at runtime, and I crave the
| borrow checker which saves me from myself.
|
| My 10 years of Lua set me up to appreciate Rust's fantastic
| design choices, and I'm having a great time in Rust land. I wish
| to remain in Rust land but my finances demand me to use my Lua
| skills at least a little while longer. End of ramble
| chx wrote:
| The fanaticism of Rust programmers are well known and off
| putting. Why, one of them just posted about it into a Lua
| thread. It couldn't be less relevant. Much as I don't have a
| hard choice between picking assembly and PHP for a task, Rust
| and Lua are just not in the same problem space.
| umvi wrote:
| I read his post less as Rust fanaticism and more someone who
| has learned their first programming language isn't perfect -
| strong types? iterators? These are all things that are
| present in many languages, it just sounds like Lua is lacking
| them and he is discovering some of the cool features of other
| languages.
| nmz wrote:
| But lua isn't lacking them, <for in do> is for generators,
| and if you want iterators you can make those as well.
| pfg_ wrote:
| I think they are. Rust is a general purpose programming
| language, and Lua is a language specifically designed to be
| embeddable. But that means if you're making a project that
| embeds Lua, like Factorio for example, you have the choice of
| what language you write the code in. The choice is whether to
| write a function as native or to write it in Lua, and that
| choice might not be super clear unless someone else already
| made that choice for you.
|
| This is completely different than assembly vs PHP. Assembly
| is a 'don't use it unless you have to' programming language,
| while PHP is a programming language designed for website
| building. You wouldn't use assembly to make a website because
| there are no frameworks for it and you'll scream and cry. You
| wouldn't use PHP to write the entrypoint to your operating
| system because PHP can't do that.
|
| Rust and Lua are a lot closer together than PHP and assembly
| and it often would be reasonable to compare these languages
| for the same problems. It's not relevant at all to the blog
| post though because the engine they're using is built for
| Lua, and it's not really up to them unless they want to work
| against the engine and try to use a different language.
| hu3 wrote:
| > Rust and Lua are a lot closer together than PHP and
| assembly.
|
| Perhaps for some definition of closer, but they are very
| far away still.
|
| Like opposite-ends-of-many-spectra far away.
| saagarjha wrote:
| Amusingly I've gotten more job offers for web software
| written in assembly than PHP
| IshKebab wrote:
| I think he was just offering the perspective of someone else
| that has also written a lot of Lua.
|
| > The fanaticism of Rust programmers...
|
| Honestly the endless criticism of Rust "fanatics" is far more
| tedious than anything Rust developers say. Rust is a
| fantastic language. Do you expect people _not_ to talk about
| it?
| chx wrote:
| > Honestly the endless criticism of Rust "fanatics" is far
| more tedious than anything Rust developers say.
|
| We can agree to disagree. I am sick and tired of Rust
| people screaming at the top of the lungs in every possible
| place about how their language is great and want to rewrite
| everything in it.
|
| So yes I expect people not to praise Rust in a Lua thread,
| it's completely off topic.
| interroboink wrote:
| I haven't used Rust, but lots of C++ -- do you ever find the
| strongly-typed and compiler-driven approach constraining,
| compared to Lua?
|
| Like, in C++ if I want to change the API for something, I need
| to update a few different places (header, implementation, maybe
| some downstream typedefs, etc.), maybe recompile a library or
| two, then re-run the application, whereas in a more loosly-
| typed and "interpreted" language like Lua, I can rely on duck
| typing and such, make my edits and save, and the code is
| immediately live.
|
| The iteration cycle can be very short, if the system is built
| that way.
|
| Anyway, maybe I just come from the opposite end of the
| spectrum, so Lua feels like a breath of fresh air sometimes vs.
| writing everything in a stricter language. My project is also
| very amenable to that, though.
| umvi wrote:
| Iteration cycle of strongly typed languages can be very short
| too, if you pick the right technologies. Rust (and c++),
| unfortunately, has pretty long compile times compared to,
| say, Go.
|
| The problem with loosely typed languages is that you don't
| find out until runtime that you have a problem. And if the
| problem is inside an if statement that users only hit 1% of
| the time, you might not find it at all except in the form of
| users very occasionally complaining that it sometimes crashes
| unexpectedly.
| secondcoming wrote:
| There are techniques in C++ that can prevent this situation
| somewhat but it comes at the expense of indirection (see
| pimpl).
| xedrac wrote:
| As a long time C++ developer with only a few years in Rust,
| C++ is downright painful in comparison. However, I still
| cannot iterate in Rust as quickly as I can in Lua, unless the
| project is large and complex, then I'd argue that I can work
| faster in Rust. Languages like Python, Lua, Lisp really
| struggle in large projects because it becomes way too easy to
| break things unknowingly.
| marcosdumay wrote:
| "Second System Effect from Within - A Documentary"
| akira2501 wrote:
| > knowing the details of heap vs stack, array vs hashmap, and
| explaining that to someone learning programming for the first
| time within a language that attempts to hide those details is
| frustrating
|
| These are implementation artifacts. Knowing how to program does
| not require any knowledge of them.
|
| > and my old tool looks like a toy.
|
| The great thing about toys is they are very easy to put down
| for a while and then pick back up again later with very little
| effort.
| idoubtit wrote:
| > The great thing about toys is they are very easy to put
| down for a while and then pick back up again later with very
| little effort.
|
| That matches my experience.
|
| I've written programs in Haskell, and it was very satisfying.
| But going back to the project after 6 months of work in other
| languages was very hard. I took some time to remember the
| concepts, the abstractions and what the cryptic operators
| meant in their contexts. I've kept away of Rust for this
| reason: maintenance would be hard if I only dabble episodicly
| in Rust.
|
| On the other side, my own experience with Lua was not very
| nice. I contributed (and patched for my needs) Koreader, an
| ebook reader with 180k lines of Lua. The lack of explicit
| types and data structures was a strong impediment. And the
| language has subtle traps... Everything is a table, but not
| all tables are equals: some tables are sequences (indexed by
| 1..n) with special operators (like # whose result is
| undetermined for other tables (which hurts like the famous
| Undefined Behavior of C++). With Lua, simple questions like
| "Is this table empty?" or "What is the size of a table?" are
| too hard for beginners.
|
| So, complex artefacts are hard to go back after a long break,
| but many toys break easily when you come back after a pause,
| having forgotten how fragile they were.
| nequo wrote:
| I find Rust much better on this front than Haskell. Haskell
| has a much stronger culture of using library-specific
| operators and abbreviations for function, variable, and
| type names, than Rust does. In Rust, you can't even define
| a custom operator.
|
| If you understand borrowing and some of the basic traits,
| you're a long way there. There aren't new DSLs to learn or
| relearn, and the documentation is good at closing any gaps
| that open up while you're away from Rust.
| chx wrote:
| It's interesting to see Haskell vibes mentioned.
|
| Where's the "well yes but actually no" meme when one needs it.
|
| It's not Haskell, it's Scheme.
|
| https://www.lua.org/doc/hopl.pdf
|
| > Semantically, Lua has many similarities with Scheme, even
| though these similarities are not immediately clear be- cause the
| two languages are syntactically very different. The influence of
| Scheme on Lua has gradually increased during Lua's evolution:
| initially, Scheme was just a language in the background, but
| later it became increasingly important as a source of
| inspiration, especially with the introduction of anonymous
| functions and full lexical scoping
|
| Of course, Haskell was also Scheme influenced although it's an ML
| descendant.
|
| Speaking of this, I wonder what would've happened if they
| embedded Lua into Netscape instead of writing JavaScript...
| nmz wrote:
| well, lua existed back then, but that lua is not lua5, even
| lua4 looks incredibly different especially when it comes to
| tables.
| chx wrote:
| Yeah that would've been lua2.1 described here:
| https://www.lua.org/spe.html
| jmclnx wrote:
| Lua is one language I have been wanting to use, especially since
| it has hooks into the NetBSD kernel.
|
| And
|
| >And what about the lack of classes in Lua?
|
| to me is a big plus :)
| ardit33 wrote:
| I have used it production (embeded/mobile), and I liked a lot.
| Their associated tables are just awesome.
|
| The problem with Lua is that object oriented programing is not
| necessary a first class citizen (you have to create it from
| scratch with object prototypes) and that Python occupies the
| same space and has sucked the oxygen out of it.
|
| Think of Lua as a much leaner/simpler Python, and better for
| embeded situations.
| diarrhea wrote:
| Lua can also be massively faster than Python (LuaJIT).
| thement wrote:
| The problem with "lack of classes" is that every non-trivial
| program makes its own implementation of something-like-classes,
| but built on top of metatables.
|
| So before you can start hacking on anything in Lua, you have to
| first understand the class system, which may or may not be
| documented.
| mhh__ wrote:
| Lua is a language that I really hate quite a few aspects of the
| design of but still like quite a lot. Weird that.
| giraffe_lady wrote:
| I have a lot of technical respect for the project, especially
| in how carefully they have selected a goal and always develop
| towards it. And gaining expertise in lua is almost like taking
| a master class in language design: you are nearly forced to
| learn about the underlying constraints and how they have been
| addressed. It definitely improved my understanding of coding
| more than most languages have.
|
| All that said I simply don't like it very much and don't think
| it's a good choice for most things I see it used for. When I
| see people talking about how much they enjoy it it's usually on
| small projects, or solo projects, or both. The simplicity of
| the language and variety of runtimes and distribution methods
| means every significant lua project is a totally unique
| framework with homegrown standard library.
|
| It also really badly needs better string handling utils. I
| appreciate the constraints they're working under and admire the
| decisions they've made in respect to them. But one of its most
| common practical uses is as a DSL or scripting extension to
| another environment. I agree with the decision not to include
| regex, and patterns are incredible for what they are but they
| aren't sophisticated enough for many cases. Some parser
| rudiments or even a peg engine built in would completely solve
| the problem. But if that's too big just a dozen or so common
| string tools would go pretty far.
| xedrac wrote:
| I still can't get over the 1-based indexing, even if you don't
| necessarily need to use it that often.
| nequals30 wrote:
| I'm wrapping up a multi-year personal project, a game written
| fully in lua using love2d.
|
| To me, the beauty of lua is the simplicity and lack of learning
| curve: I can usually accomplish whatever I need to without
| looking anything up (as the author said, everything is a table so
| there isn't much to overthink). Also, the community and support
| around love2d is fantastic.
|
| One thing that's bothered me is that lua silently returns nil
| when you reference non-existing elements. That's been a pain when
| debugging, since a line with a typo (`a = typo`) doesn't fail,
| and the code fails much farther downstream (e.g. when doing
| arithmetic on `a`). So almost all my errors end up being "trying
| to do operation on a nil value", and there is no indication of
| why it's nil.
| dividuum wrote:
| I think you can add a metatable to _G with an __index function.
| This should be called when accessing undefined local variables
| (as they end up trying to access the global scope _G) and you
| can thrown an error.
| edflsafoiewq wrote:
| A linter like luacheck is better for accidental globals, but
| I think the GP was talking about doing a =
| someTable.typoedFieldName.
| wwwigham wrote:
| You can define a metatable on your objects of interest (or the
| root table meta table if you don't mind breaking the language's
| conventions and thus libraries) with __index and __newindex
| members. Then you can throw in those by calling the `error`
| function when they'd otherwise normally return nil, should you
| desire it.
|
| But runtime checks have a cost, and static types that transpile
| away are a bit better for overhead so long as you don't mind
| the build step, so using one of the typed lua variants is
| probably a bit nicer in the long term. Catching those typos
| early is their bread and butter.
| fifilura wrote:
| I have not looked at Lua but this:
|
| > I can usually accomplish whatever I need to without looking
| anything up"
|
| And "everything is a table"
|
| Makes it sound a lot like SQL.
|
| Edit: I prefer replies to downvotes.
| wk_end wrote:
| Lua isn't anything like SQL. "Table"s in Lua are like
| maps/dictionaries/hash tables, not relational tables.
| fifilura wrote:
| But still maybe the concepts for working with them (group
| by/ join/ aggregate) are similar?
|
| There are lots of things you can do with a table as a
| general purpose data structure. And I was curious if this
| was a similarity?
|
| When you say that tables are like dicts/maps, are they
| tables or are they dicts?
|
| And I apologise for not knowing more about Lua. Maybe i
| should have known better than to ask about things I dont
| know.
| vaylian wrote:
| > Maybe i should have known better than to ask about
| things I dont know.
|
| It is fine to not know things. But when I look at your
| post, I see that you didn't ask any question. You only
| made statements that were based on very unfounded
| assumptions.
|
| But to get back to what tables are: They are key-value
| pairs with both array- and hashmap-semantics. By
| convention, arrays start at 1 in Lua. They are very
| similar to dictionaries in Python , associative arrays in
| JavaScript and other key-value data structures in other
| programming languages. However, lua also uses them for
| storing variables in environments (some people would call
| environment "scopes") and there are special callbacks for
| missing variables and accessor functions when working
| with these tables.
| ck45 wrote:
| https://www.lua.org/pil/2.5.html
|
| "The table type implements associative arrays."
|
| Simplified (and some hand waving): In Python associative
| arrays are called dict, in Lua they are called table.
| chatmasta wrote:
| It's really much more like JavaScript (due to its
| prototypical nature), where "everything is an object" is
| effectively saying the same thing.
| nmz wrote:
| What do you want it to return though?
|
| x = f() or "default value"
|
| or maybe you want it to error
|
| x = f() or error"F failed"
|
| or maybe x is an object in which case you can just
|
| setmetatable(x,{__index = function () return "" --[[default
| value here]] end})
|
| or maybe you don't want nils, in which case
|
| debug.setmetatable(nil, {}) -- actually this one is
| complicated, but yeah, you can use this.
| pseudo_meta wrote:
| If you use the lua lsp, you can make type annotations which
| basically work like jsdoc. With those annotations, the lsp will
| warn you about such issues, there is a diagnostic that's called
| something like `needs-nil-check`.
| arp242 wrote:
| I really really don't want to do type annotations. I just
| want to know about: variable = 1
| print(varaible)
|
| It's been a while since I did Lua, but there's been a few
| cases where this caused massive confusion.
|
| Last I checked I couldn't really find a good way to do that;
| but like I said: it's been a while.
| edflsafoiewq wrote:
| Luacheck will warn about unknown globals.
| ItCouldBeWorse wrote:
| My biggest gripe with lua was that depending upon the internals
| of the implementation, it could "swallow" an error entirely.
| The program would just die in absolute silence and not give an
| error at all or any indication it was still running.
| bhaney wrote:
| > I thought I knew C++, but working with ClickHouse showed me
| otherwise
|
| Only language where you can keep having this realization over and
| over forever. Of course people prefer lua if they can get away
| with it.
| marcosdumay wrote:
| As a comparison, Haskell is a language where you can keep
| learning more and more advanced things, forever.
|
| But yeah, I guess C++ is the one single language where you can
| keep learning more and more fundamental things, forever.
| exe34 wrote:
| haskell is great if you enjoy learning haskell. there's
| always a new build system, a complete redesign of how things
| are done, etc. i lost the plot around the time everything
| became an arrow (or was it a lens ?) myself, but I'm sure a
| few more generations of improvement have happened already!
| marcosdumay wrote:
| Everything never became an arrow.
|
| Arrows are a flexible enough abstraction if you are trying
| to cram some things that the language supports badly into
| it, like FRP.
|
| Also, everything never became a lens.
| exe34 wrote:
| it just seemed like the tutorials just pivoted from
| monads to lenses to arrows. but fair enough, I never did
| "get" haskell. I loved the functional aspect of
| functional problems (e.g science equations), but once it
| came to carrying state, everything just turned into a
| mess for me.
| marcosdumay wrote:
| > everything just turned into a mess for me
|
| I just want to say, this one is absolutely normal.
|
| That's what learning new stuff feels like most of the
| time.
|
| Then, after you pass through it, you go and write a
| tutorial so other people are spared. But then... I'm not
| sure this part works :)
| exe34 wrote:
| yeah I look forward to writing my own monad analogy!
| tialaramex wrote:
| There are people who just don't know C++ and people who also
| don't know that they don't know C++
|
| This makes the existence of JTC1/SC22/WG21 aka "The C++
| Standards Committee" more akin to the Academie francaise (which
| officially defines the French language, but that's not how
| natural languages actually work) than many C++ proponents seem
| to grasp.
| kazinator wrote:
| The analogy isn't very good, because the natural French
| language isn't a minefield full of undefined behavior.
|
| In Linguistics, natural language, and native speaker
| intuition is the gold standard. The theory of the language is
| deemed to be wrong where it fails to capture it.
|
| So right off the bat we know that a prescriptive institution
| like Academie francaise is on linguistic shaky ground; it is
| not aligned with science.
|
| In computing, the specification is the gold standard,
| followed by documented, committed implementation behaviors.
| devjab wrote:
| You don't have to follow the specification. If enough
| people don't, the standard committees will eventually
| adjust the standards, or, make more standards.
| BaculumMeumEst wrote:
| My favorite thing about Lua is that it trivially builds anywhere
| with a C compiler. Lots of other languages that bill themselves
| as "embeddable" are a real pain in the ass to build on weird
| platforms.
| thement wrote:
| I even managed to get Lua built on z/OS mainframe! The
| productivity gains were *amazing* (compared to REXX).
| ufo wrote:
| Fun example: there's a project (Lunatik) that embeds Lua inside
| the Linux kernel, where no userspace C APIs are available.
| You'd expect that would require extensive patching but they
| mostly just had to tweak the makefile and a configuration
| header file.
| hgyjnbdet wrote:
| I've been wanting to pick up lua for ages. My only issue, as
| always, is where to start. Is there a runtime I can install where
| I can start creating with lua? Cross platform, windows and Linux?
| That will allow someone with no c/c++ experience to start doing
| stuff with it?
| longor1996 wrote:
| Perhaps redbean might be of interest? It's a web server with
| all the batteries included, scripted via lua.
|
| https://redbean.dev/
| krapp wrote:
| Love2D is popular (https://love2d.org/)
|
| Also Lua binaries are available here
| (https://luabinaries.sourceforge.net/)
|
| And a big list of Lua frameworks
| (https://github.com/uhub/awesome-lua)
|
| I'd suggest working with LuaJIT as well because of the C API
| (you can easily use something like SDL and build metatypes
| around them) with the caveat that it's stuck at an older
| version of Lua[0,1].
|
| [0] https://luajit.org/
|
| [1] https://github.com/LuaJIT/LuaJIT
| Red_Tarsius wrote:
| I have used Lua a long time ago and I don't remember ever
| touching C/C++. You can even make simple games without ever
| going low level thanks to https://love2d.org/! If I recall,
| most https://stabyourself.net/ games are based on Love2d.
|
| If you're using Linux/MacOS, you can copy-paste these commands
| on the terminal and you should be settled: curl
| -L -R -O https://www.lua.org/ftp/lua-5.4.6.tar.gz tar zxf
| lua-5.4.6.tar.gz cd lua-5.4.6 make all test
|
| You should find the lua executable inside the lua-5.4.6/src
| folder.
| thefaux wrote:
| > However, when it comes to separating code into modules or
| packages, Python is more convenient.
|
| Kind of curious about this. I find packaging in Lua quite
| convenient. I make a file and return either a value or a table
| full of values and then I require that file in the dependent file
| that uses the package.
|
| Also, wrt to the missing features like an increment operator. It
| is possible in at most a few thousand lines of lua to implement a
| lua' -> lua transpiler where lua' adds some missing features,
| such as increment operators, in an idiomatic way. In other words,
| the generated code looks almost exactly the same as the input
| code except in places where say `x++` gets translated to `x = x +
| 1`. As long as your file is less than a few thousand lines of
| code, the transpiler can run in < ~200ms (and obviously much less
| for shorter files or much faster if the transpiler is implemented
| in a faster language). Of course the tradeoff is that the
| original source code may break existing tooling for lua, though
| the generated code will work fine.
| JSR_FDED wrote:
| I wrote a trading system where the strategies are written in Lua.
| It has been a delight, fast and simple. The traders have the
| expressivity of a full programming language and I can add any
| function to that language and provide any data as well so that
| their programming (and execution) sandbox is extremely ergonomic
| and suited to their specific task. In other words, a trading DSL.
|
| Other code outside the sandbox pulls in up to date price data and
| if certain safety rules are violated will automatically close out
| positions. So even if the traders code their way into an infinite
| loop or make other mistakes, the supervisor can step in and
| automatically prevent disaster.
|
| Using Lua to make a language for others has been a wonderful
| experience. FYI, it was approx 11K lines of Lua).
| bartwe wrote:
| We used Lua in the past, but mostly because doing quick
| iterations in c++ in that project was unrealistic due to 10+
| minute build times.
| indymike wrote:
| I learned Lua modding the game Homeworld and writing access
| control filters for NGINX. So easy to understand, mostly because
| Lua is pretty bare bones. I've always wanted to fit it into a
| project, but Javascript and Python are tough competition for a
| language like Lua.
| rewgs wrote:
| Congrats to the author, but I really can't stand Lua. It takes
| its commitment to simplicity too far IMO, especially with regards
| to tables not really specifying between (in Python terms) "dict-
| like" and "list-like" tables. Recursively searching through a
| table of tables can for this reason be annoyingly difficult.
|
| Every time I write it, I find myself wanting a language with just
| a few more batteries included.
| kbd wrote:
| Anyone here use https://fennel-lang.org/ to make Lua more
| palatable/fun?
___________________________________________________________________
(page generated 2024-06-01 23:00 UTC)