https://pluto-lang.org/web/#env=lua%3A5.4.6&code=if%20_PVERS...
But interoperability with the DOM is the missing key.
Still, if lua was used instead of javascript, I could see myself saying... man, I wonder what browser development would be like if we replaced lua with x.
I can see people liking or disliking Lua and JS both, depending on taste, but it's hard to see someone liking one and disliking the other.
Lua also has operational advantages compared to javascript. You can build it from source in at most a few seconds and run it anywhere that has a c compiler. The startup time is negligible even compared to a compiled c program so you can run entire scripts that do very useful things faster than most js engines can print hello world. There is also the benefit that in spite of what this article discusses, it is possible for most problems to write a lua solution that works for all lua >= 5.1. This is wonderful because it means if I stick to the standard library, the bitrot is essentially zero.
Calling into c is very straightforward in Lua, especially with luajit, which makes it superior to js as a scripting language (the node ffi api is quite painful in my experience and ffi runs against the js execution model).
Lua also essentially got lexical scoping of local variables correct from the beginning while js blessed us with the nightmare of var.
Of course Lua is far from perfect, but while there are some similarities, the differences are quite significant and meaningful.
That was not my experience when I was working with lua. Did anything change since? Asked google. Answered :
> In Lua, if a variable is assigned a value inside a function without being explicitly declared with the local keyword, it will automatically become a global variable. This is because, by default, all variables in Lua are global unless explicitly specified as local.
As a scripting language for browsers this is an antifeature, and the fact Lua comes by default with a bunch of features that allow loading arbitrary binary code in the process makes it pretty annoying to properly use it as a sandboxed scripting language.
All of that is trivial when you consider the Lua reference implementation. It is beautiful.
The things I do not like about Javascript can easily be shot down in an argument. Some of it was having to work with Javascript (and it's evil cousin JScript) in the 90s and early 00s.
The type coercion and in the early days people used '=='. I think === did not even appear until ie6?
[] == ![] // true
The lack of a lot of easy helper functions in the standard lib. That now are provided by people writing a bunch of stuff in the npm ecosystem.
The npm ecosystem itself. Lack of security. Lack of... curation? (Also, all this would have probably happened anyway if Lua was in the browser)
I also think javascripts long history has created a legacy of different paradigms
variable declaration var, let, const
function declaration
function f1() {}
const f2 = function() {};
const f3 = () => {};
const obj = { f4() {} };
There is a lot of stuff like this in javascript. I could probably make a blog post about it. But the above gives the general idea of my complaints.
The implicit conversions is a definite footgun tho.
One killer feature of Lua (that surprisingly few scripting languages have) is stackful coroutines, i.e. you can yield across nested stack frames. Unlike JS or Python, there is no artificial split between generators and async/await and no need for function coloring.
If Lua had zero-based indexing, it would be close to perfect :)
"But, just write good code" you will say. Just like with Perl, some languages are designed in a way to discourage writing good code...
> No static typing to rest your eye on.
That goes for any dynamically typed language. How is that an argument against Lua in particular?
> Have you read large Lua codebases written by others?
No, because I use it as a scripting language, as intended. I totally agree that one shouldn't use dynamically typed languages for building large applications. But again, this is not specific to Lua.
But once that project gets passed to next maintainer — I'm not sure I'd pick Lua over Forth or Scheme.
Even the fact that people really want to write object oriented code, but every project rolls its own class system is a problem.
When I write lua is just tables of data and functions. I try to keep it as simple as possible.
I've been enjoying writing games for the Playdate, and in Love2d.
My main example is self in lua which is just the first argument of a function with some syntactic sugar vs this in javascript which especially before 'bind' often tripped people up. The coercion rules are also simpler largely by virtue of making 0 true.
Lua's metatables also cover a fair bit more ground than JS. For example, indexing, math operations (including bitwise), comparisons and equality can be overriden.
There are parts about the language I really enjoy. I like dynamic languages; I don't run into type issues so often it bothers me, but the tooling around Lua still leaves me wishing for me.
Part of this is really my own ability, or lack thereof, but I feel slow and constrained in lua. I have a hard time debugging, but I don't feel these things in other languages.
Otoh, missing ++, +=, ..= operators really bothers me.
But that's just personal taste, not objective by any means.
I love ++, but you know what? I was shocked when a co-worker pointed out that it is frowned upon to use ++ in javascript. It some big companies, their linter settings mark ++ as something that should be changed.
Appearently its really confusing if you put a bunch of newlines between the ++ operator and its ophand. No kidding.
From JavaScript: The Good Parts (May 2008):
> The ++ (increment) and -- (decrement) operators have been known to contribute to bad code by encouraging excessive trickiness. They are second only to faulty architecture in enabling viruses and other security menaces. The JSLint option plusplus allows the use of these operators.
Needless to say, I'm with you and hackthemack on this.
https://github.com/fengari-lua/fengari-web
I don’t know if this can access the DOM in Lua, but considering that Fengari is in Javascript, adding a _DOM global variable should not be too hard (if it hasn’t already been done).
local js = require "js"
local window = js.global
local document = window.document
window:addEventListener("load", function()
local el = document:getElementById("main")
el:addEventListener("click", function(evt) js.console:log(evt.target) end
document.body:appendChild(el)
end
Lua has improved substantially from version to version because it’s been able to break compatibility. That wouldn’t be possible in the browser, so today we’d still be stuck using (an augmented version of) the outdated Lua 2.x.
https://web.archive.org/web/20191024193930/https://twitter.c...
“Lua in 1995 was very different, no coros e.g., and no one would be happy if it flash-froze and then slow-forked on a different path from Lua's. See https://news.ycombinator.com/item?id=1905155 and yes, wasm is the right long-term plan. In 1995 it was supposed to be Java, but that didn't pan out!”
I'm sure there are a few unrelated factors going on to influence that plus some inadvertent cherry-picking. But I do think there is a thing to the observation too.
If I had to make a guess, I'd point to a combination of:
1. This was right around the time that computers were fast enough to afford the runtime cost of garbage collection while still delivering usable apps. The GC languages before the 90s (Lisp, Scheme, Smalltalk, Self) had reputations for abysmal performance and have largely (but not entirely) died out.
2. This was also the boom of the Internet and web which shifted a lot of computation to server-side after the PC boom had shifted it client-side. That also enabled somewhat slower languages with GC to thrive because first-mover advantage was more valuable than using your servers efficiently. You could just throw more hardware at it.
3. That boom also created a huge influx of new developers who picked up whatever language happened to be hot at the time. And once they had, they tended to stick with it. I can't find a good graph of the number of software engineers over time but I'd bet that there's a noticeable uptick around the dotcom boom.
C, C++, Ada, Basic, Fortran. Those were written assuming they were going to be writing systems code and numerical code. There is then some inertia keeping the most successful ones of from those periods going in their spaces.
Then these new languages with new ideas (GCs, Dynamic Typing, etc) they came out and became successful in the newer Web and Application spaces. Now why they won out and not LISP or SmallTalk or what have you, I am not sure. But my hypothesis is that the web is a big part of it.
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.
https://www.usenix.org/legacy/publications/compsystems/1994/...
>Elk, the Extension Language Kit, is a Scheme implementation that is intended to be used as a general, reusable extension language subsystem for integration into existing and future applications. Applications can define their own Scheme data types and primitives, providing for a tightly-knit integration of the CIC++ parts of the application with Scheme code. Library interfaces, for example to the UNIX operating system and to various X window system libraries, show the effectiveness of this approach. Several features of Elk such as dynamic loading of object files and freezing of fully customized applications into executables (implemented for those UNIX environments where it was feasible) increase its usability as the backbone of a complex application. Elk has been used in this way for seven years within a locally-developed ODA-based multimedia document editor; it has been used in numerous other projects after it could be made freely available five years ago.
Also Gnu Guile:
https://en.wikipedia.org/wiki/GNU_Guile
>GNU Ubiquitous Intelligent Language for Extensions[3] (GNU Guile) is the preferred extension language system for the GNU Project[4] and features an implementation of the programming language Scheme. Its first version was released in 1993.[1] In addition to large parts of Scheme standards, Guile Scheme includes modularized extensions for many different programming tasks.[5][6]
Also Winterp, which used XLisp:
https://dl.acm.org/doi/10.1145/121994.121998
>Winterp is an interactive, language-based user-interface and application-construction environment enabling rapid prototyping of applications with graphical user interfaces based on the OSF/Motif UI Toolkit. Winterp also serves as a customization environment for delivered applications by providing a real programming language as an extension language. Many existing user-interface languages only have the expressive power to describe static layout of user interface forms; by using a high-level language for extensions and prototyping, Winterp also handles the dynamic aspects of UI presentation, e.g. the use of direct manipulation, browsers, and dialog. Winterp makes rapid prototyping possible because its language is based on an interpreter, thereby enabling interactive construction of application functionality and giving immediate feedback on incremental changes.Winterp's language is based on David Betz's public domain Xlisp interpreter which features a subset of Common Lisp's functionality. The language is extensible, permitting new Lisp primitives to be added in the C language and allowing hybrid implementations constructed from interpreted Lisp and compiled C. Hybrid implementation gives Winterp-based applications the successful extension and rapid-prototyping capabilities of Lisp-based environments, while delivering the multiprocessing perfor- mance of C applications running on personal Unix workstations.
And TCL/Tk of course!
And on the commercial side, there was Visix Galaxy, which was extensible in PostScript, inspired by NeWS:
https://www.ambiencia.com/products.php
https://0-hr.com/Wolfe/Programming/Visix.htm
https://groups.google.com/g/comp.lang.java.programmer/c/LPkz...
https://donhopkins.com/home/interval/pluggers/galaxy.html
https://wiki.c2.com/?SpringsAndStruts
>The Visix Galaxy project was a ridiculously overpriced and overfeatured portable GraphicalUserInterface. You could do things like swivel an entire panel full of their custom widgets 32 degrees clockwise, and it would render all its text at this new angle without jaggies. The company went out of business after gaining only a handful of customers. For USD$ 10,000 a seat they sure didn't see the OpenSource movement coming. Their last attempt before going under was (guess what?) a Java IDE.
Galaxy competed with Neuron Data Systems in the "cross platform gui framework" space (which got steamrolled by the web permanently and for a window of time Java):
https://donhopkins.com/home/interval/pluggers/neuron.html
Here is a great overview of User Interface Software and Tools by Brad Myers:
https://www.cs.cmu.edu/~bam/uicourse/2001spring/lecture05too...
https://www.cs.cmu.edu/~bam/toolnames/
https://docs.google.com/document/d/1hQbMwK_iyjX-wpu_Xw_H-3zL...
It goes to show how much investment is required for a programming language to actually take off at scale.
However in a couple of years, we will be asking the computers to perform tasks for us and the actually compiler frontend will be irrelevant to the AI runtime.
The language of R is S, which originated at Bell Labs in 01976. Python began development in 01989, although Guido didn't release it until 01991. And the top 20 on https://www.tiobe.com/tiobe-index/ are Python, C (01972?), C++ (01982?), Java, C# (01999? though arguably it's just a dialect of Java), JS, Visual Basic (first released 01991, within your window), Golang (02007), Delphi (under this name in 01995 but a dialect of Object Pascal from 01986, in turn a dialect of Pascal, from 01970), SQL (01973), Fortran (01957), Perl (01987), R, PHP (01995, within your window!), assembly (01947), Rust (02006), MATLAB/Octave (01984), Scratch (! 02003), Ada (01978?), and Kotlin (02011).
By decade, that's one language from the 40s, one language from the 50s, no languages from the 60s, 5 languages from the 70s, 5 languages from the 80s, 4 languages from the 90s, 3 languages from 0200x, one language from the 02010s, and no languages from the 02020s.
Lua is #33 on TIOBE's list, but given its prevalence in Roblox (as Luau), WoW, and other games, I suspect it should be much higher.
For some reason, CUDA (a dialect of C++) and shader languages like GLSL don't show up in the list at all.
— ⁂ —
I think most of what's going on here is that it takes a new language a long time to get good, and it takes a new good language a long time to get popular. Perl, Python, Java, PHP, and JS became popular because of the Web; https://philip.greenspun.com/panda/server-programming explains why Perl, Python, and PHP did, and of course Java and JS became popular because they were the only languages you could make interactive web pages in:
> You would think that picking a Web site development language would be trivial. Obviously the best languages are safe and incorporate powerful object systems. So let's do everything in Common Lisp or Java. Common Lisp can run interpeted as well as compiled, which makes it a more efficient language for developers. So Common Lisp should be the obvious winner of the Web server language wars. Yet nobody uses Common Lisp for server-side scripting. Is that because Java-the-hype-king has crushed it? No. In fact, to a first approximation, nobody uses Java for server-side scripting. Almost everyone is using simple interpreted languages such as Visual Basic, PHP, Perl, or Tcl.
> How could a lame string-oriented scripting language possibly compete in power with systems programming languages? Well, guess what? The only data type that you can write to a Web browser is a string. And all the information from the relational database management system on which you are relying comes back to to the Web server program as strings. So maybe it doesn't matter whether your scripting language has an enfeebled type system.
It's a Long Now Foundation thing: slower, deeper, longer. Y10K compliance.
https://longnow.org/ideas/long-now-years-five-digit-dates-an...
"The present moment used to be the unimaginable future." -Steward Brand
"How can we invest in a future we know is structurally incapable of keeping faith with its past? The digital industries must shift from being the main source of society’s ever-shortening attention span to becoming a reliable guarantor of long-term perspective. We’ll know that shift has happened when programmers begin to anticipate the Year 10,000 Problem, and assign five digits instead of four to year dates. 01998 they’ll write, at first frivolously, then seriously." -Steward Brand
10,000 Year Clock:
- this comment will still be around in 8000 years
- we will still be using the same calendar system in 8000 years
- people 8000 years in the future will leave off the leading 1 of years for some reason, and will use a leading 0 to disambiguate dates from the previous 10000 year period.
That selling point, for Lua, is the super easy integration via C-API to me (=> making existing compiled applications scriptable), thanks to uncomplicated build (dependency free, simple), the straightforward C-API and the ease of exposing C "modules" to Lua.
On a sidenote:
Don't you think that Y10k-safe dates are somewhat inconsistent with referencing previous decades directly? Those dates are also obnoxious to parse for humans (myself, at least).
That's like saying Java is a dialect of C++. Java was specifically designed as a "fuck you" to C++, and C# was specifically designed as a "fuck you" to Java.
https://cs.gmu.edu/~sean/stuff/java-objc.html
.NET was being designed with J++, Microsoft's Java extensions, Cool research language only became C# and took over J++'s role in .NET due to Sun's lawsuit.
The lawsuit is more than well known, and the background to .NET planned used of .NET is on the papers published by Don Syme of F# fame, regarding the history of .NET and F# HOPL.
- Microsoft Java Virtual Machine: https://en.wikipedia.org/wiki/Microsoft_Java_Virtual_Machine
- Visual J++: https://en.wikipedia.org/wiki/Visual_J%2B%2B
James's email that convinced me to go work with him at Sun on NeWS in 1990:
https://news.ycombinator.com/item?id=22457490
James' original 1985 paper on SunDew (later called NeWS):
https://www.chilton-computing.org.uk/inf/literature/books/wm...
David Rosenthal on NeWS -vs- X11 in 2024:
https://www.theregister.com/2024/07/10/dshr_on_news_vs_x/
James Gosling on how he'd do it over again in 2002:
https://web.archive.org/web/20240126041327/https://hack.org/...
Me on the X-Windows Disaster, comparing X11 and NeWS in the 1994 Unix Haters Handbook:
https://donhopkins.medium.com/the-x-windows-disaster-128d398...
Here's a Stanford talk James Gosling gave about Java that I attended in 1995, where he talks about C++, his original tape copy program that turned into a satellite ground control system, how he holds the world record for writing the largest number of cheesy little extension languages to go, and his implementation of Emacs sold by UniPress (which RMS calls "Evil Software Hoarder Emacs"), and his design and implementation of NeWS (formerly SunDew), a PostScript based network extensible window system.
James Gosling - Sun Microsystems - Bringing Behavior to the Internet - 1995-12-1:
https://www.youtube.com/watch?v=dgrNeyuwA8k
>Video of James Gosling's historic talk about Java, "Bringing Behavior to the Internet", presented to Terry Winograd's user interface class at Stanford University, December 1, 1995.
In that talk I asked him a couple questions about security and the "optical illusion attack" that he hedged on (44:53, 1:00:35). (The optical illusion attack is when the attacker simply draws a picture of a "secure" pop up dialog from your bank asking for your password.)
He mentioned off hand how a lot of the command and control systems for Operation Desert Storm was written in PostScript. That was his NeWS dialect of PostScript, and was written primarily by Josh Siegel at LANL called "LGATE", who later came to work at Sun in 1990 and rewrote the NeWS PostScript interpreter himself, then went on to write an X11 window manager in PostScript, again proving James's point that people always did a lot more with his cheesy little extension languages than he ever expected (which also held true with Java).
Josh's work on simulating Desert Storm and WWIII with NeWS at LANL:
https://news.ycombinator.com/item?id=44540509
Some of Terry Winnograd's other guest speakers:
https://news.ycombinator.com/item?id=39252103
I also saw Bill Joy's much earlier talk at the 1986 Sun Users Group in Washington DC, where he announced a hypothetical language he wanted to build called "C++++-=", and that he talked about in subsequent presentations.
I think that was the same talk when Bill said "You can't prove anything about a program written in C or FORTRAN. It's really just Peek and Poke with some syntactic sugar". More Bill Joy quotes:
https://www.donhopkins.com/home/catalog/unix-haters/slowlari...
James eventually realized that concept as Java, showing that the kernel inspiration of writing a "fuck you to C++" language existed long before James invented "Live Oak", even soon after C++ was invented. But "Java" was a much better name than "Live Oak" or "C++++-=" fortunately -- thanks to Kim Polese -- though not as succinct and musically inspired as "C#"!
https://en.wikipedia.org/wiki/Bill_Joy#Joy's_law
https://news.ycombinator.com/item?id=30113944
Bill Joy’s Law: 2^(Year-1984) Million Instructions per Second
https://donhopkins.medium.com/bill-joys-law-2-year-1984-mill...
>The peak computer speed doubles each year and thus is given by a simple function of time. Specifically, S = 2^(Year-1984), in which S is the peak computer speed attained during each year, expressed in MIPS. -Wikipedia, Joy’s law (computing)
>“C++++-= is the new language that is a little more than C++ and a lot less.” -Bill Joy
>In this talk from 1991, Bill Joy predicts a new hypothetical language that he calls “C++++-=”, which adds some things to C++, and takes away some other things.
>“Java is C++ without the guns, knives, and clubs.” -James Gosling
A beta version is now available:
The main change from 5.4 seems to be the (optional?) removal of global-by-default, instead requiring declarations for 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
That's also solvable using metatables.
https://www.tcl-lang.org/community/tcl2017/assets/talk93/Pap...
It's because Tcl, like SQLite, operates on a peculiar metaphysical principle: everything is a string until proven otherwise, and even then, it's probably still a string.
Also, D. Richard Happ, who we owe thanks for SQLite, was and perhaps still sits on the TCL Board (I may be wrong about that, but Happ holds significance in the TCL community).
In my mind:
Tcl is the quietly supportive roommate who keeps making coffee and feeding LISP-like functionality until the world finally notices its genius.
Lua sits across the table, sipping espresso with a faintly amused expression, wondering how everyone got so emotionally entangled with their configuration files.
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.
Performance is up, but so is my inertia. So while TCL 9 could be transformative, for now it remains a white paper I've skimmed, not a revolution I've implemented.
I still prefer Lua personally. Their type system is easy for me to understand
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.
I enjoy Lua and use it professionally, but when bash (and AWK) don't suffice, the glue is Perl. Because it has pipes which you can use to connect the output of one command to the input of another, or to a file.
That's it. It's not great on its own, in my opinion.
It becomes really gnarly if you have a bigger Lua codebase.
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!
The TOC looks great, I will read this soon. Need to finish "Debugging CSS" first (another good book IMO).
Lunacy also has a few built in libraries which are not included with Lua 5.1, such as binary bitwise operations (and/or/xor). It also fixes some security issues with Lua 5.1 (better random number generator, hash compression algorithm which is protected from hash flooding attacks).
In addition, I have made a tiny Windows32 binary of Lunacy.
Don’t worry about the Lunacy changes; all of the examples in the book work with bog standard Lua 5.1 with a bit32 library (bit32 is common enough most OSes with a Lua 5.1 package also have a bit32 package for Lua 5.1).
Maybe I should reconsider and dive more into game dev.
> It's aimed at programmers who have some experience but are just starting out with game development, or game developers who already have some experience with other languages or frameworks but want to figure out Lua or LÖVE better.
Also on the topic of game engines with lua scripting, the wonderful Defold always deserves a mention https://defold.com/
Seems like a no brainer that would help bring in more revenue too, it'd also be an "evergreen" book as new others can contribute over time.
I can't be the only one that would immediately buy a copy. :D
None of these are published because the popular ones are better and provide more functionality, but I want to share what I believe is more valuable: what I learned while writing them.
https://www.youtube.com/@nocturing
If you want a sneak peak of what I want to walk through, check this repo (see the examples/ folder): https://github.com/jrop/u.nvim
function(x) return x; end
[ (x) | x ]
http://lua-users.org/files/wiki_insecure/power_patches/5.4/l...And for Lua 5.1:
http://lua-users.org/files/wiki_insecure/power_patches/5.1/l...
(I personally don’t use patches like this because “Lua 5.1” is something pretty standardized with a bunch of different implementations; e.g. I wrote my Lua book with a C# developer who was using the moonsharp Lua implementation)
Here, you're gonna need this:
dino is slightly faster than lua (not luajit)
but spitbol is actually faster than lua, dino and luajit
ngn k is slightly faster than spitbol but lacks built-in pattern matching or RE
FWIW, I do not use a terminal emulator. I only use textmode No graphics layer. No "desktop"
Are you sure you aren't being bottlenecked by your terminal?
statically-linked 64-bit spitbol is only 175k
static-pie luajit 2.1 is 667k
static-pie lua 5.1.5 is 259k
static-pie ngn k is 271k
Leafo's itch.io is built with it and I maintain snap.berkeley.edu. A great tool, but I'm also many times more productive in Rails. (It's an unfair comparison, to be sure!) and Openresty + Lapis is quite performant and low overhead which is great.
https://turbo.readthedocs.io/en/latest/
Its a very flexible way to do realtime/embedded, performance-critical services (e.g., a game server or API gateway) where Lua's speed and low overhead matter.
Neovim lua has https://github.com/jbyuki/one-small-step-for-vimkind but it doesn't seem there's any DAP server for regular lua.
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.
-- 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 < b
end
return ta < tb
end
end
local keyList = {}
local index = 1
for k,_ in pairs(inTable) do
table.insert(keyList,k)
end
table.sort(keyList, sFunc)
return function()
key = keyList[index]
index = index + 1
return key, inTable[key]
end
end
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)https://news.ycombinator.com/newsguidelines.html
https://hn.algolia.com/?sort=byDate&dateRange=all&type=comme...
But no, I'm a real person, I just post things that I (randomly) find interesting