lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Jerome Vuarand wrote:
> In my opinion, syntax doesn't matter much. It matters in small companies
> and projects for the reason that it's easier to find C programmers than
> smart programmers that could learn a new language.

Syntax should not matter to any programmer with any professionalism at all ---
it takes, maybe, an hour to switch syntax styles provided there's no
underlying semantic changes.

However, one crucial aspect of using a particular syntax is that it raises
expectations. Javascript uses C-style syntax, which leads people to believe
that that's how it works. In fact, Javascript is radically different. It's
even *less* like C or C++ or Java than Lua is, as a matter of fact. Example (I
found out about this two days ago):

function foo()
	var i = 1;
	var j = 2;
		var j = 3;
	return i + j;

What do you think this returns? 3? Wrong! It returns 4. var isn't lexically

I learned about by reading the Javascript 1.7 spec, which is introducing a new
keyword, 'let', for defining lexically scoped variables. It never occurred to
me for a moment that such a thing might be needed, because all my training was
encouraging me to believe that 'var' behaved sensibly, and was lexically
scoped. I've mentioned this to some people at work, and have received, without
exception, expressions of surprise and disbelief.

The designers' decision not to make var behave that way strikes me as being
downright *dangerous*.

(I suspect, in Lua terms, that each call frame has an environment, and 'var'
declares an entry in that environment; so accessing a variable is actually
doing a table lookup in the environment. Lua's local variables are much more
like C registers.)

I'm not particularly keen on Lua's syntax, simply because it's a bit wordy and
I don't like that. However, I learnt it, and now I'm used to it. The fact that
it *is* different helps me to distinguish it from other languages that behave
differently, such as C++ --- I program in both frequently and hardly ever get
them confused. What's more, now I'm used to it, I'd violently oppose changing
it simply because I *am* used to it. I would much rather the language stayed
as it is so that I can remain productive, than to have it change to follow the
current fashions and require me to relearn things. (I still do most of my
coding in Lua 5.0, for this reason.)

If a company is rejecting Lua simply because it looks funny, well, screw 'em.
If they're not competent enough to judge a tool on its technical merits I
reckon we're better off without them.

+- David Given --McQ-+ "Gaping from its single obling socket was
|    | scintillating, many fauceted scarlet emerald..."
| ( | --- Jim Theis, _The Eye of Argon_ (spelling
+- --+ original)

Attachment: signature.asc
Description: OpenPGP digital signature