summaryrefslogtreecommitdiff
path: root/html/index.html
blob: 3e1576cbcf6896f9c7a40359a3b34b8fae7e1950 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<html lang=en>
	<head>
		<link rel="stylesheet" href="/milligram.min.css"/>
		<link rel="stylesheet" href="/tokyo-night-light.css"/>
		<script src="/highlight.min.js"></script>
		<script>hljs.highlightAll();</script>
	</head>
	<body><main class="wrapper">
		<nav class="navigation">TODO</nav>
		<header class="header"><section class="container">
		<h1 class="title">Lua4Win</h1>
		</section></header>
		<section class="container">
			<p>Lua4Win is a distribution the Lua programming language for Windows.</p>
			<a class="button" href="https://cicd.lua4.win/archive/lua4win-dist-lua/latest/lua4win.msi">Download</a>
		</section>
		<section class="container">
			<h3 class="title">Rational</h3>
			<p>Unlike alternative distributions, Lua4Win comes with the Luarocks package manager and is a "batteries-not-included" distribution of Lua. Binary packages are built in the cloud and can be downloaded as-needed. The Lua4Win installer contains a copy of <a href="https://luajit.org">LuaJIT</a>, <a href="https://luarocks.org">Luarocks</a>, <a href="https://www.busybox.net">Busybox</a>, and <a href="https://7zip.org">7zip</a>; which allows it to come in at a slim 2MB. Updates and bugfixes can be done piecemeal instead of requireing new copies of the whole distribution every time a bug gets fixed.</p>
		</section>
		<section class="container">
			<h3 class="title">Usage</h3>
			<p>After installing, you can launch <code>cmd.exe</code> and run <code>$ lua</code> to get started.</p>
			<pre><code class="language-none">$ lua
LuaJIT 2.0.ROLLING -- Copyright (C) 2005-2023 Mike Pall. https://luajit.org/
JIT: ON CMOV SSE2 SSE3 SSE4.1 AMD fold cse dce fwd dse narrow loop abc sink fuse
> print("Hello, world!")
Hello, world!
></code></pre>
			<p>You can use <code>CTRL+C</code> to escape the read-evaluate-print-loop. You can also write Lua programs with your favorite text editor and run them with <code>$ lua filename.lua</code>
			<div class="row">
				<div class="column">
					note.lua
				</div>
			</div>
			<div class="row">
				<div class="column">
					<pre><code class="language-lua">-- Create a note file with today's date in %APPDATA%
local args = {...} -- extra arguments passed to the program
-- Generate a filename
local notes_folder = os.getenv("APPDATA")
local today = os.date("%Y-%m-%d")
local note_name = table.concat(args,"-"):gsub("[%W]","-")
local note_filename = string.format("%s\note-%s-%s.txt",notes_folder,today,note_name)
-- Create the file
local fd = assert(io.open(note_filename,"w"))
assert(fd:close())
-- Open it in notepad
os.execute("notepad.exe " .. note_filename)</code></pre>
				</div>
				<div class="column">
					<pre><code class="language-bash">$ lua note.lua my first note</code></pre>
				</div>
			</div>
			<p>Run <code>lua --help</code> for more options for the command line tool, and the <a href="https://www.lua.org/manual/5.1/manual.html">Lua Manual</a> for extensive documentation of the Lua programming language. Also note <a href="https://luajit.org/extensions.html">LuaJIT's extensions</a></p>
		</section>
		<section class="container">
			<h3 class="title">Installing Superpowers</h3>
			<p>You can use modules that implement more than the standard lua libraries by running the <code>$ luarocks install &gt;module name&lt; </code> command to download and install modules.</p>
			<div class="row">
				<div class="column">
					color.lua
				</div>
			</div>
			<div class="row">
				<div class="column">
					<pre><code class="language-lua">local eansi = require("eansi")
eansi.enable = true
print(eansi.toansi("green") .. "> implying you need modules" .. eansi(""))</code></pre>
				</div>
				<div class="column">
					<pre><code class="language-bash">$ luarocks install eansi

$ lua color.lua</code></pre>
				</div>
			</div>
			<p> Run <code>luarocks --help</code> for more options on the command line tool, and the <a href="https://github.com/luarocks/luarocks/wiki/Using-LuaRocks">Luarocks wiki</a> for more extensive documentation.</p>
		</section>
		<section class="container">
			<h3 class="title">Sister languages</h3>
			<p>Lua4Win makes it easy to download other programming languages that are distributed through the <code>luarocks</code> package manager. Simply <code>luarocks install</code> them like you would any other package.</p>
			<h4 class="title">Moonscript</h4>
			<div class="row">
				<div class="column column-offset-33">
					example.moon
				</div>
			</div>
			<div class="row">
				<div class="column">
<pre><code class="language-bash">$ luarocks install moonscript</code></pre>
				</div>
				<div class="column">
<pre><code class="language-moonscript">class World
  greet: => print("Hello, world!")

with World!
  \greet!</code></pre>
				</div>
				<div class="column">
<pre><code class="language-bash">$ moonscript example.moon
Hello, world!</code></pre>
				</div>
			</div>
			<br/>
			<h4 class="title">Teal</h4>
			<div class="row">
				<div class="column column-offset-33">
					keys.tl
				</div>
			</div>
			<div class="row">
				<div class="column">
					<pre><code class="language-bash">$ luarocks install tl</code></pre>
				</div>
				<div class="column">
					<pre><code class="language-teal">local function keys<K,V>(xs: {K:V}):{K}
  local ks = {}
  for k, v in pairs(xs) do
    table.insert(ks, k)
  end
  return ks
end

local s: {number:string} = keys({ a = 1, b = 2 })
print(table.concat(s))
</code></pre>
				</div>
				<div class="column">
					<pre><code class="language-bash">$ tl keys.tl
ab</code></pre>
				</div>
			</div>
		</section>
		<section class="container">
			<h3 class="title">Advanced Usage</h3>
			<p>Lua4Win allows you to install system-wide packages with the <pre><code>--tree system</code></pre> flag, these packages will be located at <pre><code>[INSTALLDIR]/luarocks</code></pre>. You may need to be running as an administratior to install to this location.</p>
			<p>Lua4Win's luarocks config lives at <pre><code>[INSTALLDIR]/config/config-5.1.lua</code></pre></p>
			<p>All of Lua4Win's binary packages are built using mingw64, if you intend to build your own modules, they must be built with mingw64 if you want them to operate with Lua4Win-distributed Lua.</p>
			<p>Some of Lua4Win's packages needed patching or modification, source code is generally mirrored at <a href="https://git.lua4.win">git.lua4.win</a>, and packaging code is kept seperate, usually in a repo <pre><code>*-packaging</code></pre></p>

	</body>
</html>