lua-users home
lua-l archive

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


On 13 July 2017 at 12:07, Javier Guerra Giraldez <javier@guerrag.com> wrote:
> On 13 July 2017 at 10:44, Dibyendu Majumdar <mobile@majumdar.org.uk> wrote:
>> I am not sure what has propelled Python to this spot - perhaps the
>> adoption by Google several years ago.
>
>
> I think part of the merit is in NumPY library.

So I have been trying to understand if there is something about Python
that apart from the availability of NumPY makes it more attractive to
numeric users than Lua.

I asked a few weeks ago what Lua users thought about having a distinct
array type (http://lua-users.org/lists/lua-l/2017-06/msg00299.html)
but responses indicated no one thought this was important.

However, as I learn Python, I am finding a few things pretty useful
for certain types of programming needs.

1) First the existence of arrays - an array is fundamentally different
from a Lua table as it has certain guarantees. In particular it is an
ordered set, with no holes, and has efficient indexing and length
operations. Lua tables cannot efficiently provide these guarantees (I
am not including LuaJIT into consideration here).

2) Array slicing operations.

3) Ability to specify multiple operands in array indexing []
operation. In Python you can write a[1,2] - which is convenient for
accessing matrices - and you can go higher dimensions. The syntax is
natural. But comparatively in Lua the indexing operation takes a
single argument. Of course you can pass a table as argument but
syntactically that is ugly - apart from the inefficiency (although
Python is probably no more efficient). One can use the call () syntax
but that introduces inconsistency as well.

I have always wished I could support at least [x,y] syntax in Ravi.
Recently after using Python I have begun to think that maybe I could
do this by adding a new type in Ravi - <integer-pair> - which would be
a pair of 32-bit integers. This can fit into the Lua value structure
nicely - and would allow indexing operation to take two integer
arguments. It could even be extended to a tuple of three 32-bit
integer values - useful for representing slicing operations.

Anyway - I have no enough evidence for this yet - but my gut feel is
that the lack of a distinct array type could be a factor with Lua's
popularity in certain domains.

Regards
Dibyendu