lua-users home
lua-l archive

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

On 18/06/2012 11:51, Alex Queiroz wrote:
You say you have a lot of programming experience, but I dispute that.
You seem to have used only languages what were inspired by C (C++,
Java, Javascript etc.). Try some Forth, Standard ML or Lisp.

Or Pascal, with begin / end and 1-based arrays (actually they are more flexible than that, but that's not the point).

Patrick, you can find many threads raising similar questions. Search the archive to find some answers.

On 18/06/2012 11:21, Patrick Masotta wrote:
> 1) I couldn’t believe when I saw LUA arrays indexed from “1”; that’s for kids not for
> programmers.

Yeah, there are lot of aphorisms on "real programmers", like coding directly in bytecode instead of using a compiler / assembler.

Well, I believe that "real programmers" must have no rigid mind thinking there is only One True Syntax for languages... but I don't try to persuade other programmers that's the only truth. ;-)

> 2) Why you guys do not use {} instead of the wordy BEGIN END sequences???

Because the programming world doesn't end at the C syntax? I love the C syntax, but I appreciate alternatives. I don't see 'do' (not BEGIN) / 'end' much more wordy / longer to type than { }, especially on a French keyboard where I have to do AltGr+4 to do {

> No matter that modern IDE’s auto-completion save us the extra work punching more
> characters, The real problem is when we have to read LUA code instead; The bloated text
> makes harder to understand the code lay-out

Again, lot of discussions on this topic: some people only swear by symbols (I suppose they have fun reading APL), other prefer English-like code.
With proper indentation, I have no problem at all with code layout.

A frequently given argument is that Lua's different syntax allows the mind to recognize immediately if you are in a Lua or a C part, and to prepare it to switch to different programming paradigms and idiom. Particularly, when you see do / end you know you have to handle 1-based arrays... :-)

> 3) Why there’s not a switch statement?

It isn't really needed in Lua. There are alternatives, given in this list, and probably listed in the wiki.

Philippe Lhoste
--  (near) Paris -- France
--  --  --  --  --  --  --  --  --  --  --  --  --  --