The journey to programmer proficiency starts with a single script.
#!/usr/local/bin/lua
print("first post!")
The greater part of this task is to discover how a Lua script can be executed on a computing machine. That is, you have to get Lua and install it on your system. Or seek advisement from your friendly local system administrator. On a Mac OS X box, there are pre-built binary packages available, or you can use the source and do the untar, make and make install dance. I have not toiled on a Windows box for some time now, so you'll have to search the internets for Windows XP/Vista install instructions.
Lua is lightweight, so installing and getting setup is a snap, especially when compared to other development platform environments.
My Lua development environment is fairly spartan — it consists of Vim and Mac OS X Terminal.
$ ./genesis.lua first post!
In genesis.lua, the "shebang" line magic is employed to invoke the script directly. Lua scripts can also be executed by issuing the lua command and specifying the script file to be executed as a command argument.
$ lua -? usage: lua [options] [script [args]]. Available options are: -e stat execute string 'stat' -l name require library 'name' -i enter interactive mode after executing 'script' -v show version information -- stop handling options - execute stdin and stop handling options
Or you can try some interactive Lua:
$ lua Lua 5.1.2 Copyright (C) 1994-2007 Lua.org, PUC-Rio > print(math.pi) 3.1415926535898 > print(os.tmpname()) /tmp/lua_cSugQn > =1600*1200 1920000
Strike control+D to exit the interpreter.
Yes, it's a silly little program of no merit on its own, but the first step of figuring out how to run Lua on your system is the gateway to Lua learning. Baby steps for now…
No comments:
Post a Comment