One more thing about Io and Lua comparison

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

One more thing about Io and Lua comparison

Ashish Ranjan-2
Some time back i saw the mention of Io language available on 
iolanguage.com, and i compared it for a short time.
  Though io compiles in cygwin on windows, but it does NOT compiles 
on mingw+msys. Whereas lua compiles on mingw+msys( Though i am not 
able to compile lua with some features,such as dynamic loading etc. 
turned on on the mingw). So lua is compilable with gnu compilers to 
produce native exe on windows,whereas io is not. So it makes sense 
for me to stick with lua.
 But i will like to say, that many libraries available for io, such 
as curses,regex,xml etc. should also be available in lua some day. 
And socket,sql libraries of lua4.x should be ported to lua5 as soon 
as possible. There SHOULD BE AN OFFICIAL and MATURE WAY OF 
interaction of lua with c++, rather than everyone taking out his own 
library for a repititive and unaviodable task of interaction of C++ 
methods with lua.These learnings from other scripting languages 
apart from introspection will take lua to another milestone.

ONE MORE QUESTION APART FROM ABOVE TOPIC: i want to do fltk gui 
program scripting in lua (and as fltk and lua both compile on mingw, 
linux and cygwin all) in some portable way on mingw,linux and 
cygwin. Is there some fltk binding for lua 5 available, so that i 
can capture events in and out lua 5 acripts and fltk.



Reply | Threaded
Open this post in threaded view
|

Re: One more thing about Io and Lua comparison

Wim Couwenberg-2
Ashish Ranjan wrote:
> There SHOULD BE AN OFFICIAL and MATURE WAY OF
> interaction of lua with c++, rather than everyone taking out his own
> library for a repititive and unaviodable task of interaction of C++
> methods with lua.These learnings from other scripting languages
> apart from introspection will take lua to another milestone.

There is an official and mature way: the Lua API.  I couldn't be happier
with it.  It lets me do things exactly the way I choose in an elegant,
consistent and easy way.  Maybe you should try it once.

Bye,
Wim



Reply | Threaded
Open this post in threaded view
|

Re: One more thing about Io and Lua comparison

Ignacio Castaño
Wim Couwenberg wrote:
> There is an official and mature way: the Lua API.  I couldn't be happier
> with it.  It lets me do things exactly the way I choose in an elegant,
> consistent and easy way.  Maybe you should try it once.

Lua binding interface is a very low level API. I haven't used Io's bindings,
but I've heard that they are very easy to use. Io is a language made by a
single person and with a small comunity, and I belive that it has more
external libraries available than Lua. Maybe Steve can clarify this better
than me.

BTW, I think that Lua API should keep as is. Higher level mechanisms can and
have been implemented on top of it. My only concern is that the API should
stay stable, so that higher level APIs don't have to be rewritten. I think
that the Lua authors don't plan any major API change after this release, so
situation will probably improve in the near future.


Ignacio Castaño
[hidden email]



Reply | Threaded
Open this post in threaded view
|

Re: One more thing about Io and Lua comparison

Steve Dekorte-4

On Saturday, April 19, 2003, at 02:09 PM, Ignacio Castaño wrote:
Lua binding interface is a very low level API. I haven't used Io's bindings, but I've heard that they are very easy to use. Io is a language made by a
single person and with a small comunity, and I belive that it has more
external libraries available than Lua. Maybe Steve can clarify this better
than me.

Hi Ignacio,

Sure. Here's what a binding for a GL function looks like:

--- Io --------------------------------------------------------------------

IoValue *IoGL_glVertex3d(IoGL *self, IoValue *locals, IoMessage *m)
{
  IoNumber *x = IoMessage_locals_numberArgAt_(m, locals, 0);
  IoNumber *y = IoMessage_locals_numberArgAt_(m, locals, 1);
  IoNumber *z = IoMessage_locals_numberArgAt_(m, locals, 2);
  glVertex3d(
    (GLdouble)IoNumber_asDouble(x),
    (GLdouble)IoNumber_asDouble(y),
    (GLdouble)IoNumber_asDouble(z));
  return (IoValue *)self;
}
...
Hash_at_put_(m, IOSTRING("glVertex3d"), IOCFUNCTION(IoGL_glVertex3d));

--- Lua --------------------------------------------------------------------

static int toluaI_gl_glVertex3d00(lua_State* tolua_S)
{
 if (
 !tolua_istype(tolua_S,1,LUA_TNUMBER,0) ||
 !tolua_istype(tolua_S,2,LUA_TNUMBER,0) ||
 !tolua_istype(tolua_S,3,LUA_TNUMBER,0) ||
 !tolua_isnoobj(tolua_S,4)
 )
 goto tolua_lerror;
 else
 {
  GLdouble x = ((GLdouble)  tolua_getnumber(tolua_S,1,0));
  GLdouble y = ((GLdouble)  tolua_getnumber(tolua_S,2,0));
  GLdouble z = ((GLdouble)  tolua_getnumber(tolua_S,3,0));
 {
  glVertex3d(x,y,z);
 }
 }
 return 0;
tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'glVertex3d'.");
 return 0;
}
...
 tolua_function(tolua_S,NULL,"glVertex3d",toluaI_gl_glVertex3d00);
-------------------------------------------------------------------

Very similar. The big difference is that Io's bindings are OO - that is, the glVertex3d() function is a method on an OpenGL object which internally holds any related state. In Lua, you add functions to Lua and custom userdata to hold any state associated with a binding which needs to be passed in with each call. (this example doesn't show that though as GL has static variables to hold it's state) Also, with Io bindings there's no stack that needs to be maintained. Arguments you don't use are ignored and the return argument is passed back in the normal way.

Cheers,
Steve
OSX freeware and shareware: http://www.dekorte.com/downloads.html