Scripts vs Modules

Started by garry23, December 02, 2018, 09:25:23 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

garry23

@a1ex

In the past I toyed with the idea of learning C and how to compile ML etc, but with Lua scripting I simply don't see the need.

So, my question is, am I missing anything by restricting my work to Lua?

What would a module, say, of my DoF Bar, give me that a script wouldn't?

Cheers

Garry

a1ex

Generally speaking, the main reasons to choose a low-level language (such as C or ASM) over a high-level one (such as Lua or Python) are:
- speed (of program execution)
- resource usage (memory, CPU cycles)
- API availability

Most of the C APIs are not yet available in Lua. Right now there's no way to get the value of some image pixel, for example. AFAIK there are some other languages out there with easier C integration, i.e. without the need to manually write wrappers, but I didn't really look into them. Maybe others who already have this experience could chime in.

Even if I'll provide a get_pixel function, you may not be able to do image analysis at reasonable speeds, even if you'll be looking at some small buffer (such as the 720x480 LCD image). However, with some functions able to analyze an image region and return a summary (e.g. a histogram), Lua might be fast enough for exposure decisions in photo mode, for example.

If what you are doing is time-critical (e.g. some computations that need to run for every single frame in LiveView), then Lua is no longer the best choice. Or, if you want to do some low-level stuff in Canon firmware, you will need some function implemented in C and an API to allow Lua scripts to use it.

If you want some custom bracketing sequence or automation over existing functionality, Lua is probably just fine. In this case, its overhead is usually no longer noticeable.

In your particular case, you'll probably see a difference if redraw speed becomes a problem, or if you've got some other speed-related issues, or if you want some tighter integration with other ML code. Otherwise, Lua is probably just fine.

Which one is easier to use? Lua has one advantage: you don't have to setup a development environment (compiler & stuff); you can get away with a plain text editor. However, whenever I try to write something in Lua, I find myself going into C and tweaking the API. I don't find it robust enough for regular use, and I'm unable to change that during breaks and weekends :(

garry23

@a1ex

Many, many thanks for the insight.

Maybe one day I'll find the time to get into C and all that compiling overhead ;-)

Once again: many thanks for the response.

Cheers

Garry