[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Grokking the Virtual Machine
- From: Peter Kümmel <syntheticpp@...>
- Date: Sun, 15 May 2005 14:55:08 +0200
Hypertext Matters wrote:
I am the new Javascript columnist for hotscripts.com's email newsletter,
with a monthly circulation of 2/3 million. I am using my second month's
article for a little Lua evangelism. The following is my proposed
article which I have to submit in the next couple of days; it must be
100-150 words and I'm near the very top already, so there won't be much
I can add, though I could change things depending on feedback.
Thanks in advance, article follows:
*******************************************************************************
GROKKING THE VIRTUAL MACHINE: This month we consider not Javascript, but
it's syntactic cousin, Lua:
a = {}
a["b"] = "c"
This code is valid in both Lua and Javascript; the first line creates a
Javascript "associative array", or in Lua, a "table". In both languages
these constructs serve as "objects", so both of the following are valid
statements for retrieving the "b" property of "a":
a["b"]
a.b
Other similarities include that functions are first-class values in both
languages: they can be stored in variables, passed as arguments, and
returned as results. Furthermore, both languages support "lexical
closures", which allow "data hiding" (see last month's column).
Lua may well be the lowest-level of the C-based scripting languages: it
is a "register-based" virtual machine, and has some hooks directly into
C. It is popular both in Brazil where it originated, and with game
programmers. Look into Lua, and become a better Javascript programmer!
It's designed for embedding ( http://www.lua.org/pil/p1.html ):
"Lua was designed, from the beginning,
to be integrated with software written
in C and other conventional languages."
Peter