Thread overview | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
November 04, 2013 Embed JavaScript into D | ||||
---|---|---|---|---|
| ||||
Is there a way I can embed javascript into my D application? I basically want to create a modular application which allows adding and removing plugins by dragging and dropping them into a folder. I love the idea of them being editable on the fly. |
November 04, 2013 Re: Embed JavaScript into D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jeroen Bollen | On Monday, 4 November 2013 at 19:35:55 UTC, Jeroen Bollen wrote: > Is there a way I can embed javascript into my D application? I basically want to create a modular application which allows adding and removing plugins by dragging and dropping them into a folder. I love the idea of them being editable on the fly. Don't know about JavaScript but there is a well-maintained Lua integration library : https://github.com/JakobOvrum/LuaD Also with dmd compilation speeds you actually can just compiler shared library binaries of the fly from D plugin sources and get pretty much the same thing with pure D. |
November 04, 2013 Re: Embed JavaScript into D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dicebot | On Monday, 4 November 2013 at 19:45:23 UTC, Dicebot wrote:
> On Monday, 4 November 2013 at 19:35:55 UTC, Jeroen Bollen wrote:
>> Is there a way I can embed javascript into my D application? I basically want to create a modular application which allows adding and removing plugins by dragging and dropping them into a folder. I love the idea of them being editable on the fly.
>
> Don't know about JavaScript but there is a well-maintained Lua integration library : https://github.com/JakobOvrum/LuaD
>
> Also with dmd compilation speeds you actually can just compiler shared library binaries of the fly from D plugin sources and get pretty much the same thing with pure D.
I would still prefer to use a scripting language though because of a lot of removed complexity for simple tasks.
|
November 04, 2013 Re: Embed JavaScript into D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jeroen Bollen | On Monday, 4 November 2013 at 20:18:19 UTC, Jeroen Bollen wrote: > On Monday, 4 November 2013 at 19:45:23 UTC, Dicebot wrote: >> On Monday, 4 November 2013 at 19:35:55 UTC, Jeroen Bollen wrote: >>> Is there a way I can embed javascript into my D application? I basically want to create a modular application which allows adding and removing plugins by dragging and dropping them into a folder. I love the idea of them being editable on the fly. >> >> Don't know about JavaScript but there is a well-maintained Lua integration library : https://github.com/JakobOvrum/LuaD >> >> Also with dmd compilation speeds you actually can just compiler shared library binaries of the fly from D plugin sources and get pretty much the same thing with pure D. > > I would still prefer to use a scripting language though because of a lot of removed complexity for simple tasks. LuaD is great. There is also https://bitbucket.org/ariovistus/pyd/ |
November 04, 2013 Re: Embed JavaScript into D | ||||
---|---|---|---|---|
| ||||
Posted in reply to John Colvin | On Monday, 4 November 2013 at 20:43:46 UTC, John Colvin wrote:
> On Monday, 4 November 2013 at 20:18:19 UTC, Jeroen Bollen wrote:
>> On Monday, 4 November 2013 at 19:45:23 UTC, Dicebot wrote:
>>> On Monday, 4 November 2013 at 19:35:55 UTC, Jeroen Bollen wrote:
>>>> Is there a way I can embed javascript into my D application? I basically want to create a modular application which allows adding and removing plugins by dragging and dropping them into a folder. I love the idea of them being editable on the fly.
>>>
>>> Don't know about JavaScript but there is a well-maintained Lua integration library : https://github.com/JakobOvrum/LuaD
>>>
>>> Also with dmd compilation speeds you actually can just compiler shared library binaries of the fly from D plugin sources and get pretty much the same thing with pure D.
>>
>> I would still prefer to use a scripting language though because of a lot of removed complexity for simple tasks.
>
> LuaD is great. There is also https://bitbucket.org/ariovistus/pyd/
The reason I'm not picking up any of these is purely based on my opinion, I hate developping in LUA or Python. Are there no JavaScript / PHP bindings available yet?
|
November 04, 2013 Re: Embed JavaScript into D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jeroen Bollen | On Monday, 4 November 2013 at 20:57:28 UTC, Jeroen Bollen wrote:
> The reason I'm not picking up any of these is purely based on my opinion, I hate developping in LUA or Python. Are there no JavaScript / PHP bindings available yet?
None that are widely known at least. There can always be some hidden treasures on GitHub of course. But general attitude to PHP and JS in this community does not seem very friendly, so this stuff would be surprising to find.
|
November 04, 2013 Re: Embed JavaScript into D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dicebot | On Monday, 4 November 2013 at 21:07:38 UTC, Dicebot wrote: > On Monday, 4 November 2013 at 20:57:28 UTC, Jeroen Bollen wrote: >> The reason I'm not picking up any of these is purely based on my opinion, I hate developping in LUA or Python. Are there no JavaScript / PHP bindings available yet? > But general attitude to PHP and JS in this community does not seem very friendly. Yup. I'm no massive fan of Lua or Python, but in comparison to php and JS they look like works of genius. |
November 04, 2013 Re: Embed JavaScript into D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jeroen Bollen | On Monday, 4 November 2013 at 19:35:55 UTC, Jeroen Bollen wrote: > Is there a way I can embed javascript into my D application? You could use any C javascript lib too, but for ones already wrapped or something, I know there's a few D implementations of javascript: dmdscript <http://www.digitalmars.com/dscript/index.html> (written in D1 but there's two or three ports out there to D2), an experimental implementation by Maxime Chevalier-Boisvert <http://dconf.org/talks/chevalier_boisvert.html>, and I think a couple more. I also wrote a language that is kinda like javascript but isn't actually the same and is buggy... but might be easier to integrate https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff get script.d and jsvar.d, don't need the other files. usage: import arsd.jsvar; import arsd.script; void main() { var globals = var.emptyObject; // add a variadic write function... globals.write._function = (var _this, var[] args) { import std.conv; import std.stdio; string s; foreach(a; args) s ~= a.get!string; writeln(s); return var(null); }; // you can also add D functions pretty straightforwardly globals.otherFunction = (int a, int b) { return a+b; }; // can also set values easily in D globals.yourValue = 10; import std.file; // read the user's code file interpret(readText("scriptcode.js"), globals); /* // suppose the code there is: // the syntax is kinda like javascript and kinda like D // the concat operator is D style, but function decls are JS style function foo(name) { return "hello, " ~ name; } // set a global variable too var myname = "adam"; // my language requires variables be declared, even if global */ // and functions/variable set in the script code are also available via the globals object // extra parens are needed to call script funs because D's @property is broken auto message = globals.foo()(globals.myname); // calls the script function with a script variable import std.stdio; writeln(message); // write what the script returned globals.write()(globals.foo()("D code")); // can also call it with D variables/data } If you use my little language, you'll probably find bugs, but I think it is about as easy as you can get when interfacing with D: the jsvar module gives you a var type, in D, that works very similarly to the javascript style var in the script language (except the double parens needed when calling a function) so the line can be easily blurred between native and script functions, as you see here. Compile easily too: dmd yourfile.d jsvar.d script.d |
November 04, 2013 Re: Embed JavaScript into D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | On 2013-11-04 21:20:46 +0000, Adam D. Ruppe said: > On Monday, 4 November 2013 at 19:35:55 UTC, Jeroen Bollen wrote: >> Is there a way I can embed javascript into my D application? > > You could use any C javascript lib too, but for ones already wrapped or something, I know there's a few D implementations of javascript: dmdscript <http://www.digitalmars.com/dscript/index.html> (written in D1 but there's two or three ports out there to D2) D1 version is now on github: https://github.com/DigitalMars/DMDScript D2 version: http://dsource.org/projects/dmdscript-2/ pretty sure it will need tweaks to compile with current DMD version You could rather easyly embed Mozilla Spidermonkey engine, as it provides a C api and D work great with C |
November 04, 2013 Re: Embed JavaScript into D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jeroen Bollen | On Mon, 04 Nov 2013 20:35:53 +0100, Jeroen Bollen wrote: > Is there a way I can embed javascript into my D application? I basically want to create a modular application which allows adding and removing plugins by dragging and dropping them into a folder. I love the idea of them being editable on the fly. Check out this presentation: http://dconf.org/2013/talks/ chevalier_boisvert.html Source code: https://github.com/maximecb/Higgs Also, there is the DMScript project at DSource: http://dsource.org/ projects/dmdscript-2/ |
Copyright © 1999-2021 by the D Language Foundation