Remix.run Logo
aw1621107 3 days ago

To further elaborate, here's a more detailed breakdown of tokei's line counts for each of the directories you list + the CodeGen directory:

- Analysis: 62821 lines of C++ code, 9254 lines of C headers

- Ast: 8444 lines of C++, 2582 lines of C headers

- CodeGen: 21678 lines of C++, 4456 lines of C headers

- Compiler: 7890 lines of C++, 542 lines of C headers

- VM: 16318 lines of code, 1384 lines of C headers

Compare to Lua 5.1, which tokei says has 11104 lines of C and 1951 lines of C headers in the src/ directory.

HaroldCindy 3 days ago | parent [-]

To be fair, both `Analysis` (the type-checker, not necessary at runtime or compile time) and `CodeGen` (the optional JIT engine) have no equivalent in PUC-Rio Lua.

If you look purely at the VM and things necessary to compile bytecode (AST, Compiler and VM) then the difference in code size isn't as stark.

Having worked with both Lua 5.1 and Luau VM code, Luau's codebase is a heck of a lot nicer to work on than the official Lua implementation even if it is more complex in performance-sensitive places. I have mixed feelings on the structural typing implementation, but the VM itself is quite good.

implicit 3 days ago | parent | next [-]

Further, these extra components are easy to omit if you don't want to use them.

The REPL that we offer in the distribution doesn't include any of the analysis logic and it's just 1.7mb once compiled (on my M1 Macbook). I'm not sure how much smaller it gets if you omit CodeGen.

Luau can be pretty small if you need it to be.

kragen 3 days ago | parent [-]

Did you say just 1.7MB? For the REPL alone? Or is that with a bunch of heavyweight libraries?

The Lua REPL executable on my cellphone is 0.17 megabytes.

kragen 2 days ago | parent [-]

Also for the first ten years I used computers I was using all kinds of REPLs on computers that didn't have 1.7MB of RAM. On my first computer, which had one floppy drive and no hard drive, 1.7MB would have been 17 floppy disks, or 26 times the size of its RAM. So I'm kind of unconvinced by this stance that 1.7MB is a small REPL.

I mean, it's smaller than bash? But even your mom is smaller than bash.

aw1621107 3 days ago | parent | prev [-]

> If you look purely at the VM and things necessary to compile bytecode (AST, Compiler and VM) then the difference in code size isn't as stark.

I suspected as much, but I didn't want to guess since I'm not familiar with either codebase. Thanks for the info!