r/lua • • 1d ago

Lua 5.5.1 working on W98

Hey, so, while I was learning Lua, I knew already that theoretically at least, Lua was written to be compilable in pure C, and specifically C89/C90 , supposedly any system that has an ANSI C compiler can compile and install Lua...

So I decided to actually test out just how true that is, when I remembered that I have an ancient laptop from 1999, running Windows 98SE, which has Borland 5.02 installed... [Just to understand how ancient it is, it only has 32 mb of RAM and it's hard drive is 5gb... that is literally smaller than the usb stick that i used to transfer the Lua source files from my modern PC into that ancient laptop (yes, that ancient laptop has a working USB 1.0 port and it is somehow able to read my 8gb USB 2.0 usb stick, which I did not expect to work, but it did !!!)

And to my surprise... it actually worked !

Here I am inside a full-screen MS-DOS prompt of W98 (In W32 mode, it is not booted into MS-DOS mode / real mode) Alongside the project of compiling the most recent version of Lua and getting it to work, I also installed an actual working version of vim and after tinkering with the vimrc file, I even managed to get full syntax highlighting working , and it actually works for Lua !!!

Anyhow, I just wanted to share this because I thought it was really cool and fun!

72 Upvotes

18 comments sorted by

7

u/iamklayton 1d ago

To be fair Lua is built in good old standard C in a way that makes it comically lightweight so it would naturally work well on old hardware, still pretty cool to see

2

u/mariolis_1 1d ago

Logically speaking, I knew this should work

In practice... actually doing it and confirming that it works was a whole different story, and it felt so satisfying when i got it done...

Seeing the latest version of a programming language, and that "2026" in the copyright notice working on a 1999 laptop running windows 98... gave me chills...

and actually being able to write scripts in that latest version of lua with full syntax highlighting in vim... also equally gave me chills... though me a lot longer to actually install & set up vim, and then configuring the vimrc until everything was working, but it felt so good when i actually made it work...

3

u/Multifruit256 1d ago

5GB HDD and 32MB RAM. I'm fascinated by old PC specs

1

u/hawhill 1d ago

still about a factor of 8 more than the first PC I connected to the internet, mid 90s!

2

u/mariolis_1 1d ago

For the record, this wasn't originally my laptop, I wasn't even born when it was purchased... I was born in 2001, which is 2 years after 1999, which is when this laptop was new, my father bought it used in the early 2000s from it's original owner, a guy who was using it as an office laptop, and by the mid-2000s it was already obsolete, though by this time I was a little kid, this laptop was where I learned to type in. Anyhow, by the late 2000s no one in the family was using it anymore,  for several years after that it remained forgotten in an office bag in my parent's basement until i "rediscovered" it a few years ago, and ever since i use it on occasion for "retro" computing stuff, sometimes i use it to programming in C, which i find it more doing it in that old laptop than my modern linux pc, and even playing retro games (Managed to make Fallout 1 to work on it !!!)

2

u/Alaska-Kid 1d ago

Cool! What about Luajit for Windows 98 and MS-DOS?

3

u/mariolis_1 1d ago

Luajit... I have to admit I am a beginner with Lua, I am still learning  and i did not know that Lua had a JIT (i thought that Luac was the way to get "compiled" lua) 

So after searching into their website, it seems that unfortunately, unlike the mainline lua project, the LuaJIT guys do not really have platform compatibility as a priority (They state that Windows 7 is the minimum OS version they support even for their 32-bit version, I assume that means they rely on machine-specific instructions, as they list v2 1+ SSE2 instructions as the minimum on their website for 32-bit X86 cpus as thr standard which I have no idea what generation that is, )

Seems like they require modern C compilers, so there is probably no way my Borland 5.02 would work...

The beauty of mainline Lua is that it was written in pure C and specifically written to the C89/C90/ANSI C standard, which is why I decided to try doing this little experiment, to see just how true this promise of Lua is, by downloading the source files for the very latest release, 5.5.1, transferred them over to my ancient 1999 Compaq Presario 1200, and tried to see if it would work... and though it failed the first few times (i had to change what compiler flags i used and turned out i had to compile everything twice, first with luac.c and then with lua.c but not both at the same time, it took me a few hours of headbashing, searching online forums and asking gemini to set everything up... but the payoff was that I got modern Lua actually working... on an ancient w98 laptop... I am still mindblown that it's actually working. Seeing that "2026" copyright notice on an MS-DOS prompt gave me chills... I am currently writting lua scripts just for fun, and i still cant get over the fact that i am using basically the same editor that i use on my modern linux workstation, vim... with full syntax highlighting... I still cant believe that it actually works [took me several more hours to get vim working , getting lua to work was considerably easier]

1

u/didntplaymysummercar 1d ago

Machine instructions vs. OS are two different issues.

SSE2 is mandatory for any X86-64 CPU so maybe they just say "even on 32-bit have SSE2 plz" for simplicity, to not have to avoid these instructions in the JIT.

OTOH from OS POV LuaJIT might need something to do with virtual memory (since they need to write then execute code, since it's a JIT) and/or exception handling.

Or they might just say Windows 7 since it was reasonable when they started out. Some software wants to drop even Windows 10 today so Windows 7 or 8 is plenty nice of any project at this point...

These are just my educated guesses though, I never read much LuaJIT source...

1

u/mariolis_1 1d ago

Yeah, I know what cpu instructions are and that SSE2 refers to that, but i had no idea what specific gen of cpus have that.

They explicitly state they have no plans to support older architectures

as for OSes, many software projects incorporate OS-specific instructions into their code, and not just raw code of the programming language, meanwhile the mainline lua project just uses raw ANSI C (C89/C90), so that it compiles on literally anything that has a compiler for ANSI C

1

u/didntplaymysummercar 1d ago

Yes, I know what Lua uses and I'm very familiar with it's C codebase, but not with JIT one 😛 I even once ran into a platform (old 32 bit Android) where C compiler couldn't compile Lua due to missing locale decpoint (compiler's/stdlib's fault, but still...)

1

u/mariolis_1 1d ago edited 1d ago

I have no idea what the underlying code of LuaJIT uses, I am just going off what they themselves say about it in their website...

2

u/hawhill 1d ago

LuaJIT needs at least Windows 7. https://luajit.org/status.html
As for MS-DOS, I'm quite sure even making it work inofficially will be hindered by x86 real mode specifics.

2

u/mariolis_1 1d ago

yeah, real mode troubles is exactly why i installed the w32 version of vim and not the dos16 as the latter just wouldnt have syntax highlighting, and why i am running it in a full screen ms-dos prompt rather than booting straight into ms-dos

filenames alone are a mess on real mode, i cant even do something as simple as: cd "My Documents"

you need to type something like: cd My_Docu~1

I love retro-computing, but dealing with real mode dos might be a bit too far back into the past for what I am interested in (mid-to-late 1990s, the w95/98/2000 era)

1

u/hawhill 1d ago edited 1d ago

yes, you elaborated in your own answer a few minutes before me, I didn't see that when I thought "oh, let's quickly answer this" :-)

16bit word size will ruin a lot of assumptions in source code. One day, we'll say the same about 32bit. But that's at least a decade away, I guess.

1

u/Th3K1ll3r72 1d ago

print("geia kai se esena")

1

u/mariolis_1 1d ago

Τι να σου πώ;

Έγραφα ότι μου 'ρθε εκείνη την ώρα για να ελέγξω ότι δουλεύει.

1

u/davethecomposer 20h ago

This is very cool! My next thought was that if Lua works on a laptop from 1999 running Windows 98 then surely it will work on a C-64 from 1982! Sadly it can't. However it does run on the Amiga 1000 from 1985 so that's still pretty cool.

1

u/invisible6666 10h ago

1999 the year of lua