Jump to page: 1 2 3
Thread overview
Dart bindings for D?
Oct 29, 2014
Laeeth Isharc
Oct 29, 2014
ketmar
Oct 30, 2014
Adam D. Ruppe
Oct 30, 2014
ketmar
Oct 31, 2014
Adam D. Ruppe
Oct 29, 2014
Etienne Cimon
Oct 30, 2014
Adam D. Ruppe
Oct 30, 2014
Suliman
Oct 30, 2014
Paolo Invernizzi
Oct 30, 2014
Suliman
Oct 30, 2014
Suliman
Oct 30, 2014
Suliman
Oct 30, 2014
Kagamin
Oct 30, 2014
Adam D. Ruppe
Oct 30, 2014
Adam D. Ruppe
Oct 30, 2014
Laeeth Isharc
Oct 30, 2014
ketmar
Oct 30, 2014
Laeeth Isharc
Oct 30, 2014
ketmar
Oct 31, 2014
Rikki Cattermole
October 29, 2014
Hi.

I have had a look around for these, but was not able to see them.  It looks perhaps like dart_api.h is the main file to convert - I will have a crack at starting this unless anyone knows of any already in existence.

Rationale for using Dart in combination with D is that I am not thrilled about learning or writing in Javascript, yet one has to do processing on the client in some language, and there seem very few viable alternatives for that.  It would be nice to run D from front to back, but at least Dart has C-like syntax and is reasonably well thought out.

Am I missing any existing bindings somewhere?

Thanks.


Laeeth.
October 29, 2014
On Wed, 29 Oct 2014 22:12:30 +0000
Laeeth Isharc via Digitalmars-d-learn
<digitalmars-d-learn@puremagic.com> wrote:

it's OT, but haven't you tried Adam Ruppe's script.d? it has d-like syntax with influences from javascript, written entirely in D, and has simple interoperability with D code.

it's not lightning fast, though, but the code is understandable and it's fairly easy to extend the language if necessary. maybe it will fit to your tasks.

you can take it in ARSD repository: https://github.com/adamdruppe/arsd what you need is jsvar.d and script.d, just two files and no external libs required.


October 29, 2014
On 2014-10-29 18:12, Laeeth Isharc wrote:
> Rationale for using Dart in combination with D is that I am not thrilled
> about learning or writing in Javascript, yet one has to do processing on
> the client in some language, and there seem very few viable alternatives
> for that.  It would be nice to run D from front to back, but at least
> Dart has C-like syntax and is reasonably well thought out.

I actually thought this over in the past and posted my research here:
http://forum.dlang.org/thread/ll38cn$ojv$1@digitalmars.com

It would be awesome to write front-end tools in D. However, there won't be much browser support unless you're backed by Google or Microsoft.

What's going to replace javascript? Will it be typescript? asm.js? dart? PNaCl?

The solution is obviously to compile from D to the target language. But what's the real advantage? Re-using some back-end MVC libraries? All the communication is actually done through sockets, there's never any real interaction between the back-end/front-end.

Also, you realize the front-end stuff is so full of community contributions that you're actually shooting yourself in the foot if you divert away from the more popular language and methodologies.

So, I settle with javascript, and I shop for libraries instead of writing anything at all. There's so much diversity in the front-end world, a few hundred lines of code at most are going to be necessary for an original piece of work. Heh.
October 30, 2014
On Wednesday, 29 October 2014 at 22:12:32 UTC, Laeeth Isharc wrote:
> I will have a crack at starting this unless anyone knows of any already in existence.

I haven't heard of any.

> Rationale for using Dart in combination with D is that I am not thrilled about learning or writing in Javascript, yet one has to do processing on the client in some language, and there seem very few viable alternatives for that.

What kind of client are you doing? If you are writing a web page, you don't need any kind of script language API. JavaScript or dart or whatever talk with your server application through http requests or websockets, whereas script language APIs are meant for extending your application in the same process. For example, a text editor might have a script language to make custom functions for hotkeys.
October 30, 2014
On Wednesday, 29 October 2014 at 22:22:39 UTC, ketmar via Digitalmars-d-learn wrote:
> it's not lightning fast, though, but the code is understandable and it's fairly easy to extend the language if necessary.

Curious, what have you tried with it?

I wanted to keep it simple but actually complicated it more than I wanted to, it is cool to know it isn't hard to use.

What I really like though is that the var type works in D too, making interoperation so easy. My only disappointment is @property still doesn't work, making foo.bar()() need the double parens!

> you can take it in ARSD repository: https://github.com/adamdruppe/arsd
> what you need is jsvar.d and script.d, just two files and no external libs required.

Here's an example usage:


import arsd.script;

void main() {
        // this var holds the global variables of the script engine
        var globals = var.emptyObject;

        // you can set up values or functions with plain assignment in D
        globals.myFunction = (int a, int b) { return a + b; };

        import std.file;
        // run the interpret function passing script code and the variables
        interpret(readText("scriptcode.js"), globals);

        // you can then access script values or functions from D too
        import std.stdio;
        writeln(globals.foo()("adr"));

        // and also interpret strings here. The interpret function
        // returns the value of the last expression
        writeln(interpret("myFunction(12, 24);", globals));

}


Here's what my scriptcode.js looks like:

         // 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 ~ " you are " ~ myFunction(12, 53) ~ " years old"; }
         // set a global variable too
         var myname = "adam";


kinda like a hybrid of D and JavaScript.
October 30, 2014
On Thu, 30 Oct 2014 01:31:23 +0000
"Adam D. Ruppe via Digitalmars-d-learn"
<digitalmars-d-learn@puremagic.com> wrote:

> On Wednesday, 29 October 2014 at 22:22:39 UTC, ketmar via Digitalmars-d-learn wrote:
> > it's not lightning fast, though, but the code is understandable and it's fairly easy to extend the language if necessary.
> 
> Curious, what have you tried with it?
nothing really complicated for now. simply used it in some utilities where i need something more than a config file. conditions, loops, some data processing. it looks like a mixture of D and JS, and i like it.

it surely won't do as a scripting language for realtime videogame, but i'm not writing videogames now. ;-) and it works ok for adding some easily modifyable logic/processing to various software without resorting to external libraries and wrappers like LuaD (which is great too, by the way).

> I wanted to keep it simple but actually complicated it more than I wanted to, it is cool to know it isn't hard to use.
yes, it was very straightforward. besides, i like to write scripting languages myself, so i enjoyed reading the source code too. but i did that after i used the engine several times. ;-)

what it really needs is more documentation and samples, so people can just throw it into the project and be happy. and to give some language description to software users. i mostly using it by myseld, so didn't bother to write any dox though. ;-)

> What I really like though is that the var type works in D too, making interoperation so easy. My only disappointment is @property still doesn't work, making foo.bar()() need the double parens!
it was great, but in the end i removed opDispatch from var, 'cause it confuses me. i'm not a fan of opDispatch anyway. ;-) but it was very funny to show some people D code with your jsvar and listenting how they don't want to learn just another scripting language. and then compile the code with DMD to confuse them even more.


October 30, 2014
On Wednesday, 29 October 2014 at 22:12:32 UTC, Laeeth Isharc wrote:
> I have had a look around for these, but was not able to see them.
>  It looks perhaps like dart_api.h is the main file to convert - I will have a crack at starting this unless anyone knows of any already in existence.

Dart VM is available as a standalone, which can be set up to act as a web server. But you want to integrate it into D?

> Rationale for using Dart in combination with D is that I am not thrilled about learning or writing in Javascript, yet one has to do processing on the client in some language, and there seem very few viable alternatives for that.

Javascript is easy, but compiling to Javascript from D with dart2js is also ok if you only want to support the latest browsers.

Dart makes most sense for internal web applications.

> It would be nice to run D from front to back, but at least Dart has C-like syntax and is reasonably well thought out.
>
> Am I missing any existing bindings somewhere?

I don't think so, but integrating DartVM into D means you have to deal with two different garbage collectors or put a substantial amount of work into making D use the Dart collector.
October 30, 2014
Is it's possible to create single language that cover desktop and web? Like D+Dart?

I ask becouse I can't understand why it's need 2 language if they are very simmiler and it's can be 1 language instead 2.
October 30, 2014
On Thursday, 30 October 2014 at 06:14:18 UTC, Suliman wrote:
> Is it's possible to create single language that cover desktop and web? Like D+Dart?

It is probably not possible with D or any other language that is too far off from Javascript since the generated code becomes to large for fast download. Even Dart has this problem.

It is in theory possible to use DartVM on the desktop using native bindings:
https://www.dartlang.org/articles/native-extensions-for-standalone-dart-vm/

> I ask becouse I can't understand why it's need 2 language if they are very simmiler and it's can be 1 language instead 2.

There are several languages that do source2source compilation and that can compile both to C and javascript. The problem is to find good tools and libraries…

There are also scripting frameworks that let you write portable code for web and mobile platforms, but they tend to be geared towards a special type of application.

E.g.
http://www.tidesdk.org/
http://cordova.apache.org/
http://get.adobe.com/air/
October 30, 2014
On Thursday, 30 October 2014 at 06:57:23 UTC, Ola Fosheim Grøstad wrote:
> There are also scripting frameworks that let you write portable code for web and mobile platforms, but they tend to be geared towards a special type of application.
>
> E.g.
> http://www.tidesdk.org/
> http://cordova.apache.org/
> http://get.adobe.com/air/

At work we are using Meteor [1] for everything related to the web products, and it's a VERY successful experience: easy to use, easy to deploy, incredible fast development timings.

Right now you can also target Android/iOS, so actually you can manage everything with just plain JS.

It turned to 1.0 release just yesterday, it's well funded I've bet it should be a long-runner framework.
Warmly suggested.

---
/Paolo

[1] http://www.meteor.com

« First   ‹ Prev
1 2 3