www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Are there any D scripting engines for use with D?

reply Jason Jeffory <JasonJeffory doodle.com> writes:
We have many scripting engines available for use in D more or 
less(lua, python, etc...).

Is there a D scripting engine that can be easily integrated into 
a D project? A sort of "exec(<dcode>)". Something that works at 
compile time and run time possibly? If <dcode> is a static string 
then it should be able to compile it at compile time, else, run 
time. Also, it would be nice if one could set up a unique state 
for the code to run in(so it can't be hacked by harmful coding), 
e.g., "exec(<dcode>, state)", where state is the state used for 
the exec(passed along to the <dcode> to use) for external 
function access and variable passing.

Something that is fast as possible would be nice too! I know 
there this is quite a request, but hopefully there will be work 
on it. I'd love to see scripting capabilities included with most 
programs! This would be a start, at least, for my programs.
Jan 04 2016
next sibling parent cym13 <cpicard openmailbox.org> writes:
On Monday, 4 January 2016 at 18:40:03 UTC, Jason Jeffory wrote:
 We have many scripting engines available for use in D more or 
 less(lua, python, etc...).

 Is there a D scripting engine that can be easily integrated 
 into a D project? A sort of "exec(<dcode>)". Something that 
 works at compile time and run time possibly? If <dcode> is a 
 static string then it should be able to compile it at compile 
 time, else, run time. Also, it would be nice if one could set 
 up a unique state for the code to run in(so it can't be hacked 
 by harmful coding), e.g., "exec(<dcode>, state)", where state 
 is the state used for the exec(passed along to the <dcode> to 
 use) for external function access and variable passing.

 Something that is fast as possible would be nice too! I know 
 there this is quite a request, but hopefully there will be work 
 on it. I'd love to see scripting capabilities included with 
 most programs! This would be a start, at least, for my programs.
Lua and python are already covered ([1] and [2]), for the D code I don't think so. While you can always call rdmd from D to compile and execute something in a script-like fashion it may not provide the level of integration you are looking for. On the other hand you should have a look at Adam Ruppe's script language that is written in D, largely benefits from CTFE but can be used at runtime too and has a JS-like syntax achieved by simply defining new D types (IIUC). That way you get a well-integrated easy to use language (although not quite polished). [3] [1]: http://code.dlang.org/packages/luad [2]: http://code.dlang.org/packages/pyd [3]: http://forum.dlang.org/thread/kuxfkakrgjaofkrdvgmx forum.dlang.org
Jan 04 2016
prev sibling parent reply Max Klyga <max.klyga gmail.com> writes:
On 2016-01-04 18:40:03 +0000, Jason Jeffory said:

 We have many scripting engines available for use in D more or less(lua, 
 python, etc...).
 
 Is there a D scripting engine that can be easily integrated into a D 
 project? A sort of "exec(<dcode>)". Something that works at compile 
 time and run time possibly? If <dcode> is a static string then it 
 should be able to compile it at compile time, else, run time. Also, it 
 would be nice if one could set up a unique state for the code to run 
 in(so it can't be hacked by harmful coding), e.g., "exec(<dcode>, 
 state)", where state is the state used for the exec(passed along to the 
 <dcode> to use) for external function access and variable passing.
 
 Something that is fast as possible would be nice too! I know there this 
 is quite a request, but hopefully there will be work on it. I'd love to 
 see scripting capabilities included with most programs! This would be a 
 start, at least, for my programs.
The fastest one would probably be Lua - http://code.dlang.org/search?q=lua But there are other options: Python - http://code.dlang.org/packages/pyd Javascript - http://code.dlang.org/search?q=javascript and http://pointersgonewild.com/higgs/ Croc (previously miniD, a scripting language implemented in D) - http://jfbillingsley.com/croc/
Jan 04 2016
next sibling parent reply yawniek <dlang srtnwz.com> writes:
On Monday, 4 January 2016 at 19:04:48 UTC, Max Klyga wrote:
 On 2016-01-04 18:40:03 +0000, Jason Jeffory said:
 The fastest one would probably be Lua - 
 http://code.dlang.org/search?q=lua
 But there are other options:
 Python - http://code.dlang.org/packages/pyd
 Javascript - http://code.dlang.org/search?q=javascript and 
 http://pointersgonewild.com/higgs/
 Croc (previously miniD, a scripting language implemented in D) 
 - http://jfbillingsley.com/croc/
there is also http://code.dlang.org/packages/d_mruby mruby is really nice. but i agree, a more native language that would not need to push data via a stack but instead had direct access to strings or defined objects would be something really helpful.
Jan 04 2016
parent Jason Jeffory <JasonJeffory doodle.com> writes:
On Monday, 4 January 2016 at 19:25:18 UTC, yawniek wrote:
 On Monday, 4 January 2016 at 19:04:48 UTC, Max Klyga wrote:
 On 2016-01-04 18:40:03 +0000, Jason Jeffory said:
 The fastest one would probably be Lua - 
 http://code.dlang.org/search?q=lua
 But there are other options:
 Python - http://code.dlang.org/packages/pyd
 Javascript - http://code.dlang.org/search?q=javascript and 
 http://pointersgonewild.com/higgs/
 Croc (previously miniD, a scripting language implemented in D) 
 - http://jfbillingsley.com/croc/
there is also http://code.dlang.org/packages/d_mruby mruby is really nice. but i agree, a more native language that would not need to push data via a stack but instead had direct access to strings or defined objects would be something really helpful.
All these are ok, luaD being the preferred choice(croc looks nice but haven't spent much time with it). I'd prefer a D based scripting engine. I suppose one could simply compile the code for each change, but seems like it would be a mess. The ability to debug and provide real time changes would be great.
Jan 04 2016
prev sibling parent reply Chris Wright <dhasenan gmail.com> writes:
On Mon, 04 Jan 2016 20:04:48 +0100, Max Klyga wrote:
 Croc (previously miniD, a scripting language implemented in D) -
 http://jfbillingsley.com/croc/
Croc is written in C++. Jarrett got annoyed with D around the D2 switch. MiniD is written for D1 and Tango. It would be nontrivial to port it to D2.
Jan 05 2016
parent Jason Jeffory <JasonJeffory doodle.com> writes:
On Tuesday, 5 January 2016 at 17:37:00 UTC, Chris Wright wrote:
 On Mon, 04 Jan 2016 20:04:48 +0100, Max Klyga wrote:
 Croc (previously miniD, a scripting language implemented in D) 
 -
 http://jfbillingsley.com/croc/
Croc is written in C++. Jarrett got annoyed with D around the D2 switch. MiniD is written for D1 and Tango. It would be nontrivial to port it to D2.
Oh ;/ It was looking interesting ;/ I guess one would just need bindings?
Jan 05 2016