Live data from Hacker News

The evolution of Lua, continued [pdf]

lua.org

31–40 of 175 posts

Re: The evolution of Lua, continued [pdf]

#31

Lua is the SQLite of program languages, absolutely blast

Lua is the glue when sh/bash doesn't suffice.

Lua is simple and elegant, and I much prefer it to Tcl.

Lua is in games and in LuaTeX, and when you have the choice of embedding a LISP, a FORTH or Lua in a larger application, it is often the most maintainable, runtime-efficient and low-memory footprint option of all.

Re: The evolution of Lua, continued [pdf]

#32
post #28
post #16

Earlier quoted context omitted.

Lua is one of the easiest configuration file formats I've had the pleasure of working with. Readable. Has comments. Variables. Conditionals. Everyone (including me): "oh no, no, you don't want a full Turing complete language in your configuration file format" Also Everyone: generating their configuration files with every bespoke templating language dreamed of by gods and men, with other Turing complete languages.

It's a security issue. Configs are user interfaces. Devs generating configs is irrelevant.

Indeed - it would depend greatly one's workflow and threat model.

Re: The evolution of Lua, continued [pdf]

#33

My only context in using Lua is my neovim configuration, does any know of any good books or tutorials that make something more advance using only lua? Anything of note to consider/read/watch?

Shameless plug time: I have written a public domain book which looks at using Lua (Lua 5.1 but the code works in newer versions as well as Lua 5.1/Luau/LuaJIT) as a text parsing engine. The book assumes familiarity with other common *NIX scripting languages (such as AWK, Perl, or Python) and goes over in detail the pain points for people coming from a *NIX scripting background:

https://maradns.samiam.org/lunacy/SamDiscussesLunacy.pdf

Source files (.odt file, fonts used by book):

https://github.com/samboy/lunacy/tree/master/doc

Hope this helps!

Re: The evolution of Lua, continued [pdf]

#34
post #29

That's it - I'm building my next startup in Lua!

A useful design pattern is to write highly efficient "engine" code in C/C++ and then tie it together to highly customizable application code with an embedded scripting language.

Lua is great for this, and while you could use a LISP (Emacs, AutoCad) or a FORTH (any real-life example not from the radio telescope domain?) or Tcl/Tk (https://wiki.tcl-lang.org/page/Who+Uses+Tcl), Lua is small (as in number of concepts to understand), easy to read and understand, and compact (as in tiny codebase to integrate, few dependencies).

So many gaming startups have put their money on Lua.

Re: The evolution of Lua, continued [pdf]

#36
post #13

> work has begun on Lua 5.5 A beta version is now available: https://www.lua.org/work/ The main change from 5.4 seems to be the (optional?) removal of global-by-default, instead requiring declarations for global variables.

As it turns out, it’s possible with Lua going back to 5.1 to not allow undeclared global variables:

https://www.lua.org/pil/14.2.html

That code looks like this in Lua 5.1:

  function set(name, val)
    rawset(_G, name, val or false)
  end
  function exists(name)
    if rawget(_G, name) then return true end
    return false
  end
  throwError = {__newindex = function(self,name) error("Unknown global " .. name) end,
                __index = function(self,name) error("Unknown global " .. name) end
  }
  setmetatable(_G,throwError)
Then, to use

  set("a") -- set"a" also works
  a = 1

Re: The evolution of Lua, continued [pdf]

#37

My only context in using Lua is my neovim configuration, does any know of any good books or tutorials that make something more advance using only lua? Anything of note to consider/read/watch?

Don't have tutorials or books, but I've had a ton of fun using Lua with LOVE2D [0] for gamedev, and also Redbean [1] for building super small portable web applications. Earlier this year, I built a mini CMS [2] inspired by rwtxt with Redbean.

[0] https://love2d.org/

[1] https://redbean.dev

[2] https://github.com/kevinfiol/beancms

Re: The evolution of Lua, continued [pdf]

#38

My only context in using Lua is my neovim configuration, does any know of any good books or tutorials that make something more advance using only lua? Anything of note to consider/read/watch?

Take a look at Roblox, their market cap is almost 100B, they developed Luau and their game engine runs on it.

- https://luau.org/ - https://luau.org/why

Re: The evolution of Lua, continued [pdf]

#39
post #14

Earlier quoted context omitted.

Languages developed in that time matured just as good binary package managers started popping up, is my pet theory. Before that, getting a development environment for a new language was serious work, and people did things like stick to Perl since it happened to be installed already.

Not true. I was programming in the 90s when these languages emerged. Developments environments were emacs, vi, Brief, Borland IDE, etc. There were a few other IDEs available, but about $200 per seat. All the scripting languages mentioned didn't come as default in Unix or Windows. You had to download from their own websites. It was mostly Visual Basic, C, COBOL that were popular.

I think that's what I mean. After the time you talk about ('90s), these languages matured, and they happened to mature around the same time binary package managers became a thing, i.e. in the early-to-mid '00s.

Re: The evolution of Lua, continued [pdf]

#40
Here’s my bit of public domain code for iterating through tables in Lua so that the elements are sorted. This routine works like the pairs() function included with Lua:

  -- Like pairs() but sorted
  function sPairs(inTable, sFunc)
    if not sFunc then
      sFunc = function(a, b)
        local ta = type(a)
        local tb = type(b)
        if(ta == tb)
          then return a 
Example usage of the above function:

  a={z=1,y=2,c=3,w=4}
  for k,v in sPairs(a) do
    print(k,v)
  end
With a sort function:

  a={z=1,y=2,c=3,w=4}
  function revS(a,b)
    return a>b
  end
  for k,v in sPairs(a,revS) do
    print(k,v)
  end
(Yes, this is a lot easier to do in Perl or Python, since those languages unlike Lua have built in list iterators, but it’s possible to do in Lua too)
Post reply on HN