Run nelua 'scripts' - out of the box
Strictly speaking, this works right away:
#! /usr/bin/env nelua
print('a script?')Usage, when this is in an executable file named 'script':
$ ./script a script?
You can also pass one flag to a fixed path:
#! /usr/local/bin/nelua --cc=tcc
print('a script?')But, the performance isn't nearly what you'd expect from competitors like rdmd or nimcr, even with the caching. For example:
$ nelua -o bin -i 'print "a script?"'; hyperfine -N --warmup=3 ./bin ./script 'perl -le "print \"a script?"\"'
Benchmark 1: ./bin
Time (mean ± σ): 2.5 ms ± 0.2 ms [User: 1.2 ms, System: 1.0 ms]
Range (min … max): 1.8 ms … 3.5 ms 1554 runs
Benchmark 2: ./script
Time (mean ± σ): 186.4 ms ± 5.5 ms [User: 138.1 ms, System: 43.0 ms]
Range (min … max): 179.4 ms … 194.3 ms 16 runs
Benchmark 3: perl -le "print \"a script?"\"
Time (mean ± σ): 8.2 ms ± 0.5 ms [User: 1.9 ms, System: 5.7 ms]
Range (min … max): 6.3 ms … 9.6 ms 418 runs
Summary
'./bin' ran
3.22 ± 0.37 times faster than 'perl -le "print \"a script?"\"'
73.67 ± 7.43 times faster than './script'
Why is it so slow? Because Lua always runs:
$ cat script
#! /usr/bin/env nelua
print('a script?')
## print('preprocessor running')
$ ./script ; ./script ; ./script ; ./script
preprocessor running
a script?
preprocessor running
a script?
preprocessor running
a script?
preprocessor running
a script
$ ~/.cache/nelua/script ; ~/.cache/nelua/script
a script?
a script?
$ stat -c%Y ~/.cache/nelua/script
1697672209
$ ./script
preprocessor running
a script?
$ stat -c%Y ~/.cache/nelua/script
1697672209
$ echo 'print("a change")' >> script
$ ./script
preprocessor running
a script?
a change
$ stat -c%Y ~/.cache/nelua/script
1697672219