# Scripting engine?

**URL:** <https://forum.juce.com/t/scripting-engine/490>\
**Category:** Useful Tools and Components\
**Created:** [November 8, 2005, 11:34am UTC](https://forum.juce.com/t/scripting-engine/490 "2005-11-08T11:34:31Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![kunitoki](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/kunitoki/32/15_2.png) [@kunitoki](https://forum.juce.com/u/kunitoki)\
**Post date:** [November 8, 2005, 11:34am UTC](https://forum.juce.com/t/scripting-engine/490/1 "2005-11-08T11:34:31Z")

</div>

hey juce folks…  
looking in the public share you’ll find a gift!  
is just a proof of a concept and very very lazy coding…  
but is a starting point !

[http://www.anticore.org/juce/](http://www.anticore.org/juce/)  
same place

lou

---

<div class="post-metadata">

**Author:** ![kunitoki](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/kunitoki/32/15_2.png) [@kunitoki](https://forum.juce.com/u/kunitoki)\
**Post date:** [November 8, 2005, 4:25pm UTC](https://forum.juce.com/t/scripting-engine/490/2 "2005-11-08T16:25:50Z")

</div>

i slightly modified the scriptengine to be extensible. i’m running in winzoze,  
and would like to now if there are compiling problems on other platforms.

lou

---

<div class="post-metadata">

**Author:** ![OvermindDL1](https://avatars.discourse-cdn.com/v4/letter/o/a8b319/32.png) [@OvermindDL1](https://forum.juce.com/u/OvermindDL1)\
**Post date:** [November 9, 2005, 1:54am UTC](https://forum.juce.com/t/scripting-engine/490/3 "2005-11-09T01:54:39Z")

</div>

Never used Angelscript, used to Python and LUA. From the examples it appears that it only supports linking methods to global functions, can you map a class into it?

---

<div class="post-metadata">

**Author:** ![kunitoki](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/kunitoki/32/15_2.png) [@kunitoki](https://forum.juce.com/u/kunitoki)\
**Post date:** [November 9, 2005, 10:01am UTC](https://forum.juce.com/t/scripting-engine/490/4 "2005-11-09T10:01:46Z")

</div>

yeah of course. but don’t support perfectly (it can be simulated tho) inheritance, pure virtuals or static methods. i prefer angelscript over lua or python because it have a more c/c++ like syntax.  
here is an example directly from angelscript code. is a simple string. but here u have the tipical setup for exporting objects to the script. type registering, constructor/destructor definition, operator exporting, global and object behaviours and methods. very powerful and exporting a class is very easy. i’ll do a go on exporting some methods from the Component class.

```
[code]// Register the type
r = engine->RegisterObjectType("string", sizeof(asCScriptString), asOBJ_CLASS_CDA);

// Register the object operator overloads
// Note: We don't have to register the destructor, since the object uses reference counting
r = engine->RegisterObjectBehaviour("string", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ConstructString), asCALL_CDECL_OBJLAST);
r = engine->RegisterObjectBehaviour("string", asBEHAVE_ADDREF, "void f()", asMETHOD(asCScriptString,AddRef), asCALL_THISCALL);
r = engine->RegisterObjectBehaviour("string", asBEHAVE_RELEASE, "void f()", asMETHOD(asCScriptString,Release), asCALL_THISCALL);
r = engine->RegisterObjectBehaviour("string", asBEHAVE_ASSIGNMENT, "string &f(const string &in)", asMETHODPR(asCScriptString, operator =, (const asCScriptString&), asCScriptString&), asCALL_THISCALL);
r = engine->RegisterObjectBehaviour("string", asBEHAVE_ADD_ASSIGN, "string &f(const string &in)", asMETHODPR(asCScriptString, operator+=, (const asCScriptString&), asCScriptString&), asCALL_THISCALL);

// Register the global operator overloads
// Note: We can use std::string's methods directly because the
// internal std::string is placed at the beginning of the class
r = engine->RegisterGlobalBehaviour(asBEHAVE_EQUAL, "bool f(const string &in, const string &in)", asFUNCTIONPR(operator==, (const string &, const string &), bool), asCALL_CDECL);
r = engine->RegisterGlobalBehaviour(asBEHAVE_NOTEQUAL, "bool f(const string &in, const string &in)", asFUNCTIONPR(operator!=, (const string &, const string &), bool), asCALL_CDECL);
r = engine->RegisterGlobalBehaviour(asBEHAVE_LESSTHAN, "bool f(const string &in, const string &in)", asFUNCTIONPR(operator <, (const string &, const string &), bool), asCALL_CDECL);
r = engine->RegisterGlobalBehaviour(asBEHAVE_GREATERTHAN, "bool f(const string &in, const string &in)", asFUNCTIONPR(operator >, (const string &, const string &), bool), asCALL_CDECL);
r = engine->RegisterGlobalBehaviour(asBEHAVE_ADD, "string@ f(const string &in, const string &in)", asFUNCTIONPR(operator +, (const asCScriptString &, const asCScriptString &), asCScriptString*), asCALL_CDECL);

// Register the index operator, both as a mutator and as an inspector
r = engine->RegisterObjectBehaviour("string", asBEHAVE_INDEX, "uint8 &f(uint)", asFUNCTION(StringCharAt), asCALL_CDECL_OBJLAST);
r = engine->RegisterObjectBehaviour("string", asBEHAVE_INDEX, "const uint8 &f(uint) const", asFUNCTION(StringCharAt), asCALL_CDECL_OBJLAST);

// Register the object methods
r = engine->RegisterObjectMethod("string", "uint length() const", asMETHOD(string,size), asCALL_THISCALL);

```

[/code]

---

<div class="post-metadata">

**Author:** ![kunitoki](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/kunitoki/32/15_2.png) [@kunitoki](https://forum.juce.com/u/kunitoki)\
**Post date:** [November 9, 2005, 2:07pm UTC](https://forum.juce.com/t/scripting-engine/490/5 "2005-11-09T14:07:06Z")

</div>

have you tried to embed lua scripting into juce ? i would like to know your results. 😉 i’m really interested in having very fast and easy scripting to embed and with the less efforts in scripting itself.

lou

---

<div class="post-metadata">

**Author:** ![OvermindDL1](https://avatars.discourse-cdn.com/v4/letter/o/a8b319/32.png) [@OvermindDL1](https://forum.juce.com/u/OvermindDL1)\
**Post date:** [November 9, 2005, 5:37pm UTC](https://forum.juce.com/t/scripting-engine/490/6 "2005-11-09T17:37:47Z")

</div>

I use lua to bind things quite often, although I’ve rarely used it myself, I just set it up for others. I have not put lua into juce, if you just want a basic scripting engine using lua that would be very little and simple code, then I could do it if I get time this weekend. However, if you wanted to be able to do things like create components, then it becomes more interesting. Lua is made for speed and quick calculations and function, ergo, it has no class support, although you can emulate it with tables. Do you want a basic scripting engine to do stuff, or do you want it to be integrated into juce, as in being able to write your entire program in lua, the latter would take quite a bit more time to bind everything.

If you want classes and full features, you can’t beat python, it is slower then lua, but when you really need full class and binding support, it’s the way to go.

Don’t suppose you could post a quick snapshot of some angelscript code with comments explaing what does what and why? I’ve been looking for a reason to learn it.

---

<div class="post-metadata">

**Author:** ![\_john](https://avatars.discourse-cdn.com/v4/letter/_/898d66/32.png) [@\_john](https://forum.juce.com/u/_john)\
**Post date:** [November 9, 2005, 6:17pm UTC](https://forum.juce.com/t/scripting-engine/490/7 "2005-11-09T18:17:36Z")

</div>

By the way, I did some python bindings for JUCE (using SWIG). I gave up for a while and still have things to commit to the subversion repository. Maybe I’ll post some updates soon if anyone is interested …  
For more info : [http://pyjuce.tuxfamily.org](http://pyjuce.tuxfamily.org)

---

<div class="post-metadata">

**Author:** ![OvermindDL1](https://avatars.discourse-cdn.com/v4/letter/o/a8b319/32.png) [@OvermindDL1](https://forum.juce.com/u/OvermindDL1)\
**Post date:** [November 9, 2005, 10:13pm UTC](https://forum.juce.com/t/scripting-engine/490/8 "2005-11-09T22:13:24Z")

</div>

Yea, found it a while ago. Never have used SWIG, always have used boost, so I have yet to take a detailed look at it. I should sometime.

---

<div class="post-metadata">

**Author:** ![kunitoki](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/kunitoki/32/15_2.png) [@kunitoki](https://forum.juce.com/u/kunitoki)\
**Post date:** [November 10, 2005, 4:42pm UTC](https://forum.juce.com/t/scripting-engine/490/9 "2005-11-10T16:42:09Z")

</div>

well, is just an experiment. i’m just experimenting to find the good things and bad bottlenecks on every technological solutions. for now i’ve experimented only with angelscript and gamemonkey. they’re my choice for a some facts, they’re extensible, they permit to publish objects (althought with some difficulties in the angelscript side) and functions in a easy manner, they’re used in games for controlling the logic and sometimes the ui behaviour (games menu selections and such), they are pretty fast, their codebase is stripped down, and more over they not need to have installed external dll or something.  
my need is embed into juce a scripting engine without any kind of dependancies or whatever. with python i need to have it installed on the machine i run my app, and sometimes i can’t, or can’t force someone to install it. with lua i’ll see next days, i’m trying to embed it, and see what are the capabilities. embedding javascript could be another choice…  
anyway swig can be setup for every scripting language ? or there are limitations ?

---

<div class="post-metadata">

**Author:** ![\_john](https://avatars.discourse-cdn.com/v4/letter/_/898d66/32.png) [@\_john](https://forum.juce.com/u/_john)\
**Post date:** [November 10, 2005, 5:28pm UTC](https://forum.juce.com/t/scripting-engine/490/10 "2005-11-10T17:28:25Z")

</div>

Well SWIG has a LOT of limitation.  
It only support a given subset of languages and only fits well to do bindings of C/C++ libraries to be called from the target language runtime. The main advantage is that it’s easy to write an interface description file for a whole library : SWIG parses the headers and generates most of the embedding code automatically.

---

<div class="post-metadata">

**Author:** ![OvermindDL1](https://avatars.discourse-cdn.com/v4/letter/o/a8b319/32.png) [@OvermindDL1](https://forum.juce.com/u/OvermindDL1)\
**Post date:** [November 11, 2005, 7:11am UTC](https://forum.juce.com/t/scripting-engine/490/11 "2005-11-11T07:11:16Z")

</div>

You can embed python into your application without needing external dll’s. That is often used in some games as well.

---

<div class="post-metadata">

**Author:** ![mickeyl](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/mickeyl/32/475_2.png) [@mickeyl](https://forum.juce.com/u/mickeyl)\
**Post date:** [May 10, 2006, 11:15pm UTC](https://forum.juce.com/t/scripting-engine/490/12 "2006-05-10T23:15:28Z")

</div>

If we really want to have Python scripting, I recommend doing them with sip ([http://riverbankcomputing.co.uk](http://riverbankcomputing.co.uk)). It’s dedicated to C++ – the Python Qt bindings are made with that.

---

<div class="post-metadata">

**Author:** ![kunitoki](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/kunitoki/32/15_2.png) [@kunitoki](https://forum.juce.com/u/kunitoki)\
**Post date:** [May 10, 2006, 11:40pm UTC](https://forum.juce.com/t/scripting-engine/490/13 "2006-05-10T23:40:04Z")

</div>

actually my goals are the opposite, as i don’t want to bind juce to a scripting engine, i just want to bind (or embed) a scripting engine to juce itself. that’s why i’m developing angeljuice.

---

<div class="post-metadata">

**Author:** ![OvermindDL1](https://avatars.discourse-cdn.com/v4/letter/o/a8b319/32.png) [@OvermindDL1](https://forum.juce.com/u/OvermindDL1)\
**Post date:** [May 11, 2006, 2:21am UTC](https://forum.juce.com/t/scripting-engine/490/14 "2006-05-11T02:21:42Z")

</div>

No, no Sip, just took a look at that, ugly…

I use boost::python, idiotically easy way to bind. I bound a library with over 500 function a few months ago in a single evening with boost::python.

I took a look an angelscript, too limiting, and scripting left quite a bit to be desired.

And yea, hate SWIG with a passion…

---

<div class="post-metadata">

**Author:** ![kunitoki](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/kunitoki/32/15_2.png) [@kunitoki](https://forum.juce.com/u/kunitoki)\
**Post date:** [May 11, 2006, 2:29am UTC](https://forum.juce.com/t/scripting-engine/490/15 "2006-05-11T02:29:48Z")

</div>

i idiotically hate python… :roll:

---

<div class="post-metadata">

**Author:** ![\_john](https://avatars.discourse-cdn.com/v4/letter/_/898d66/32.png) [@\_john](https://forum.juce.com/u/_john)\
**Post date:** [May 11, 2006, 12:20pm UTC](https://forum.juce.com/t/scripting-engine/490/16 "2006-05-11T12:20:05Z")

</div>

> [@](#):
>
> I use boost::python, idiotically easy way to bind. I bound a library with over 500 function a few months ago in a single evening with boost::python.

Really ? I’ve tried to use boost::python as an alternative to SWIG.  
I first tried to use Pyste, which was not maintained anymore (acording to what I was told on the developer mailing list when I send a patch to fix a few bugs I found), because of important design flaws.  
Then I turned to use pygccxml as I was told on the same list it was better. I encounterd some new problems which looked unsolvable and finaly went back to SWIG.

OvermindDL1 : Maybe I could send you what I did with boost so you could have a look …

---

<div class="post-metadata">

**Author:** ![OvermindDL1](https://avatars.discourse-cdn.com/v4/letter/o/a8b319/32.png) [@OvermindDL1](https://forum.juce.com/u/OvermindDL1)\
**Post date:** [May 13, 2006, 1:33am UTC](https://forum.juce.com/t/scripting-engine/490/17 "2006-05-13T01:33:28Z")

</div>

I love python. 🙂

And yea, I don’t use Pyste or whatnot, I use boost::python directly. Pyste was similier to (but easier to use then) swig, and I didn’t like that style at all in either case. Heard of pygccxml (or something similier), but never looked at it. I like boost::python directly, compared to angelscripting, lua scripting, squirrel scripting, the binds for it are so much easier then even the most simple binds for all of those.

Sure, post a link or pm a link or whatnot and I can look at it.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [May 12, 2017, 9:51am UTC](https://forum.juce.com/t/scripting-engine/490/18 "2017-05-12T09:51:47Z")

</div>

Closed on May 12, 2017, 9:51am UTC


