Improving the lua interface - LUA Scripting - CHDK Forum

Poll

Lua interface should be

As close as possible to ubasic
0 (0%)
Only really ugly things should be changed
1 (5.3%)
Don't worry about usbasic, do whatever makes most sense in lua
18 (94.7%)

Total Members Voted: 19

Improving the lua interface

  • 5 Replies
  • 4069 Views
*

Online reyalp

  • ******
  • 11794
Improving the lua interface
« on: 27 / October / 2008, 23:45:37 »
Advertisements
I'm not sure if this belongs in development or scripting, but I figure it's more aimed at the people who would be writing scripts.

Right now, the lua interface is mostly a copy of the ubasic interface. This is limiting because lua is much more flexible, and also results in an interface that is more clumsy and less intuitive than it needs to be (see motion detection for example. Or compare the ubasic time functions to os.date())

A few things that lua can do, which ubasic can't:
- Interfaces to CHDK code can easily be exposed as functions, objects or tables.
- C functions can accept or return multiple values of any lua type.
- Lua functions could act as "call backs" that are run when a particular event happens in C.
- Structures and arrays in C can easily be made to appear as lua tables.

Many things that ubasic needs done in C can be handled by lua modules, which can be included in the distribution. The propcase stuff is a simple example. This keeps the CHDK core simple, while letting script writers only load what they need.

If we want to design a nice interface, it's better to do it before there are a bunch of legacy scripts that would need re-writing.

OTOH, there is an argument that making the lua and ubasic as similar as possible makes maintenance easier, and makes it easier for users to switch back and forth. I don't find either very compelling, but I am open to being convinced. Even if the interface diverges significantly, you could probably make a lua module that made it look like the old interface.

So, script writers, what would do you want ? Is similarity to ubasic important ? What would your ideal scripting interface look like ?
Don't forget what the H stands for.

*

Offline fe50

  • ******
  • 3096
  • IXUS50 & 860, SX10 Star WARs-Star RAWs
    • fe50
Re: Improving the lua interface
« Reply #1 on: 28 / October / 2008, 04:34:26 »
My vote: 'Don't worry about ubasic,...'

IMHO we should 'freeze' ubasic in it's actual state & make it conditional compile ( Bugtracker, issue #75 ).
But it should be enabled by default as long we have no need to disable it (e.g. because of less free mem).

Then we should 'do whatever makes most sense in lua', at this state we have the chance to create an ideal interface for Lua scripting without making compromises due to ubasic compatibility.

*

Offline msl

  • *****
  • 1255
  • A720 IS, SX220 HS 1.01a
    • CHDK-DE links
Re: Improving the lua interface
« Reply #2 on: 28 / October / 2008, 06:24:59 »
I'm the same opinion like fe50.

But we should respect uBasic as a good idea to make scripts possible for everyone.

msl
CHDK-DE:  CHDK-DE links

*

Offline fbonomi

  • ****
  • 469
  • A570IS SD1100/Ixus80
    • Francesco Bonomi
Re: Improving the lua interface
« Reply #3 on: 28 / October / 2008, 07:04:12 »

Quote
OTOH, there is an argument that making the lua and ubasic as similar as possible makes maintenance easier, and makes it easier for users to switch back and forth.

While ubasic must be kept for back-compatibility, lua is so much better from all points of view that developing new scripts in ubasic (or switching betwen the two) would seem a bit odd to me.

So I basically agree:
1) ubasic should be freezed, made optionally-compiled (ON by default)
2) Lua should be able to grow without worrying of keeping similarities with ubasic.


*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: Improving the lua interface
« Reply #4 on: 28 / October / 2008, 10:30:53 »
i agree to all of the above posters, though i think a few things are still missing in ubasic, which basically means that i wont do a feature-freeze on that - unless it is kicked out alltogether, which i dont believe.

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Improving the lua interface
« Reply #5 on: 28 / October / 2008, 14:05:42 »
I don't see a good enough reason to artificially restrain Lua either. I don't know it well enough to suggest how things should be, but I do like the simple way ordinary everyday things like "shoot" or "sleep()" look and work and think that to do simple things, there shouldn't be a high learning curve requiring knowledge of how more complex structures work.

 

Related Topics