Scripting Languages [closed]
Asked Answered
G

7

7

I am looking for a good scripting language to link to my program. I am looking for 2 important attributes:

  • Scripting language should be hard linked into the executable (not requiring 3rd party installations). This is important to me to simplify distribution.
  • Scripting should allow some run-time debugging option (When running a script inside my program I would like to easily run it inside a debugger while it is running in the context of my program)

Can python,lua or some other language supply me with this?

Gates answered 7/7, 2010 at 8:18 Comment(2)
You should provide more information about your program, i.e. language used and target OS.Hokanson
The more important question would be what libraries do you need.Gogh
D
13

Both Lua and Python can provide the features you mention, so choosing one of them will depend on other criteria.

Lua is a lighter weight solution, it will have a much smaller disk footprint and likely a smaller memory overhead than Python too. For some uses it may be faster. Python has a much richer standard library, more mature third party libraries and a more expressive language.

Both have been embedded into major applications. Python can be found in Blender, OpenOffice and Civilization 4. Lua can be found in World of Warcraft and Adobe Lightroom. I'd recommend looking at a few tutorials for each and the facilities available to embed them in your application and just choose the one that fits your brain best.

Dastardly answered 7/7, 2010 at 10:33 Comment(2)
Unfortunately Python is lacking real support for a "one single executable" linking. The DLL/so libs can't easily statically compiled and linked. LUA prevents the problem by not having a serious library at all.Gogh
Civilization 5 switched to Lua for performance reasons.Planchet
H
9

Lua is designed for this:

Hamrnand answered 7/7, 2010 at 9:1 Comment(0)
R
7

Typically, Lua is the better choice for embedding into another project. Python is better as a standalone platform because the library support is so much broader. See Lua Versus Python for more details.

Personally, I use both very frequently depending on the job at hand. I always use Lua for embedding into C/C++ applications or scripting functionality that is imported from C/C++ shared libraries (i.e. a DLL). Python is always my first choice for standalone tasks that do not require low-level C/C++ code.

Resinate answered 7/7, 2010 at 14:9 Comment(0)
P
2

I'd put my two cents in for python. I don't know a lot of the details, but the computer graphics suite blender does a wonderful job of implementing python scripting.

As far as I can tell in blender 2.5 the interpreter is run from inside the executable,

import sys
sys.executable

shows /blender/blender.exe and there is good debugging support, it even has a full interactive interpreter inside.

For more info check out: http://www.blender.org/

Prana answered 7/7, 2010 at 8:59 Comment(0)
C
1

I really like Lua for embedding, but just as another alternative, JavaScript is easily embeddable in C, C++ (SpiderMonkey and V8) and Java (Rhino) programs.

Criswell answered 7/7, 2010 at 14:17 Comment(2)
+1 True, it's another viable option. I'd only recommend it if you, or more properly your user/scripters are likely to already know it. One thing I forgot to mention in my answer above is that unless you're embedding the scripting engine for your own use, you should consider the likely preferences and needs of those who will be using the scripting interface.Dastardly
Simon: I'm not sure how much I agree with that. There was a time when everyone said they wanted REXX as an extension language, and I can't name a single program I've seen with REXX in 10+ years. I don't know anyone who asked for Lisp for their editor (even Lisp programmers!), but look at Emacs now. Javascript (roughly 'Scheme with Java-like syntax') was originally way over the heads of the typical people writing webpages, yet somehow people managed to adjust. I think if the language is sufficiently powerful, and users want to hack your program/platform, then users will figure it out.Interested
I
1

In addition to Tcl, Lua, and Javascript (all already mentioned), Guile is another language designed explicitly for this.

Interested answered 10/7, 2010 at 13:55 Comment(0)
J
0

I'll add Tcl to the mix. It's designed to be easily embedded into other programs.

Judaist answered 10/7, 2010 at 4:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.