Re: Dart bindings for D?
On Thursday, 30 October 2014 at 02:27:58 UTC, ketmar via Digitalmars-d-learn wrote: 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. hehe, that was the main idea!
Re: Dart bindings for D?
On Thursday, 30 October 2014 at 17:39:14 UTC, Laeeth Isharc wrote: Dart web server talk to a D analytics server via a socket. And 2) I cannot say that I definitely do not want to cache things and do some work on client, and so I need to see what's possible to avoid getting trapped in purely local optimum. One thing you should consider is that asm.js has this very cool ability to run eval() dynamically on the client and generate machinecode on the fly. You will probably get 30-50% of the D speed, but you will be getting OpenCL on the client in the future which will beat anything on the CPU… Just sayin'. There's some cool JIT capabilities in browsers that can be used for optimized queries on data in combination with local storage (all modern web browsers support this). And it is only getting better… (But dart is still a safe bet… you can call out to Javascript)
Re: Dart bindings for D?
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.
Re: Dart bindings for D?
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/
Re: Dart bindings for D?
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
Re: Dart bindings for D?
I know that there is way to write all on JS. But I can't understand what the reason that there are no single language that can work on web and as native language.
Re: Dart bindings for D?
On Thursday, 30 October 2014 at 08:39:15 UTC, Suliman wrote: I know that there is way to write all on JS. But I can't understand what the reason that there are no single language that can work on web and as native language. It is possible, but you need to design the language within the constraints of javascript: 1. single threaded (or worker threads) 2. 53 bits integers, 26 bits for multiplies. 4. weird fixed size heaps (ArrayView) 5. if garbage collection then it has to be javascript style 6. no tricks: forget coroutines
Re: Dart bindings for D?
It is possible, but you need to design the language within the constraints of javascript: 1. single threaded (or worker threads) 2. 53 bits integers, 26 bits for multiplies. 4. weird fixed size heaps (ArrayView) 5. if garbage collection then it has to be javascript style 6. no tricks: forget coroutines I can't understand why this restructions? Could you explain them?
Re: Dart bindings for D?
On Thursday, 30 October 2014 at 09:35:04 UTC, Suliman wrote: It is possible, but you need to design the language within the constraints of javascript: 1. single threaded (or worker threads) Javascript is single threaded by nature. Parallel execution is done in isolation. No shared memory. 2. 53 bits integers, 26 bits for multiplies. Javascript only support double. Double has 53 bits precision. So without emulation javascript support: 53 bit division / 52 bit addition +, - 32 bit masking , | 26 bit fast multiply * 4. weird fixed size heaps (ArrayView) You can allocate a fixed size byte array and put aligned typed views on it in modern browsers. This is used in asm.js 5. if garbage collection then it has to be javascript style You have no notion of a stack in javascript. You are therefore stuck with what javascript provides. 6. no tricks: forget coroutines You cannot implement your own coroutines without an emulation layer which will be heavy. I can't understand why this restructions? Could you explain them? The restrictions come from what javascript can do efficiently (execution time, code size and memory use).
Re: Dart bindings for D?
No! I mean not translation to js. I mean theoretical ability of creation new programming language that can work every where!
Re: Dart bindings for D?
On Thursday, 30 October 2014 at 10:18:40 UTC, Suliman wrote: No! I mean not translation to js. I mean theoretical ability of creation new programming language that can work every where! It's already created - C++! http://www.chromium.org/nativeclient
Re: Dart bindings for D?
On Thursday, 30 October 2014 at 10:28:06 UTC, Kagamin wrote: On Thursday, 30 October 2014 at 10:18:40 UTC, Suliman wrote: No! I mean not translation to js. I mean theoretical ability of creation new programming language that can work every where! It's already created - C++! http://www.chromium.org/nativeclient PNACL is using the Pepper API, which is kind of limited: you still need javascript for a HTML5 web app. And PNACL is limited to Chrome and result in large binaries (and asm.js does too).
Re: Dart bindings for D?
On Thursday, 30 October 2014 at 10:18:40 UTC, Suliman wrote: No! I mean not translation to js. I mean theoretical ability of creation new programming language that can work every where! Yes, you can create a new programming language that can work everywhere if you restrict the semantics to the least common denominator of platforms or take a speed/space penalty. But the key to speed in browser apps is to leverage the browser engine or OpenGL, and in the future OpenCL and worker threads. So… portability is limited unless you bundle the browser with the app.
Re: Dart bindings for D?
On Thursday, 30 October 2014 at 10:18:40 UTC, Suliman wrote: No! I mean not translation to js. I mean theoretical ability of creation new programming language that can work every where! The problem is getting new features into the browsers that people use. You could also just write native programs and use the web as nothing more than a delivery system. You might have a harder time getting people to install it though.
Re: Dart bindings for D?
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? You can also run D code on the web server and do very little on the web client itself for a lot of programs.
Re: Dart bindings for D?
Hi. Thanks for all the thoughts, and sorry it has taken me a little while to reply. Adam - I liked your book very much: it really complemented the other resources out there, especially in communicating a refreshing spirit of enthusiasm and fearless exploration. ketmar - I took a look at script.d very briefly. I would love if I could use some kind of D-like and D-friendly scripting language on the client (Suliman has a point!), but my understanding is that I cannot if I want to use standard browsers without a plugin - Chrome, Firefox, etc. BTW what was the story behind dscript? It seems to have changed its name and no longer have so much connection to D: http://forum.dlang.org/thread/422be824.6030...@nospam.org 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. Etienne - yes, indeed. That is exactly the problem. In theory your suggestion of compiling D to Javascript sounds intriguing, but I wonder if in practice it will be worth it on the client (I confess that you likely know much more about this than me). Even if interoperability with the ecosystem is possible, I suppose it will be clunkier to write in D compiled to JS than in Dart because there are fewer people pouring energy into the project to make it easy. I don't mind reimplementing some things on the back end in order to make it fast, beautiful, and efficient but I have no interest in re-writing anything in user interface domain. (Others may be different). As a second-best, but overall pretty appealing choice (superficially, since I haven't written anything substantial in it), Dart at least has a C-like syntax, seems to avoid most of the JS infelicities, and has some of the benefits of type-checking. It hasn't taken off yet, but my guess is it will. 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. - Adam Ruppe Proprietary trading analytics and charting - still at an early stage so the design is not fully mapped out. I understand that if I run D on server and Dart on client then I don't need to worry about APIs. But 1) if I decide to run Dart on server and write my number-crunching analytics in D then I suppose I either need the Dart headers translated to D (API) or have the Dart web server talk to a D analytics server via a socket. And 2) I cannot say that I definitely do not want to cache things and do some work on client, and so I need to see what's possible to avoid getting trapped in purely local optimum. 3) It's a long way from being relevant, but ultimately realtime data licensing occurs at local user level for Bloomberg etc, so much better to be able to tap in to a data source the user already has. Dart makes most sense for internal web applications.- Ola Yes - exactly my situation. 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? - Ola There are already C headers, and it is simple to wrap any C function manually so you can call it from Dart. Perhaps it would be possible to do something like PyD (I am still learning templates/CTFE so I don't know), but for now I was just thinking of converting the 3000 line odd (but mostly whitespace) header from .h to .d. Most of it's easy, but I struggled a bit with syntax for using alias in D to declare function pointer return types and parameters (I think I get it now). Why bother? D seems just perfect for the particular kind of quant financial work I want to do, but for the time being it is lacking on web server and client. Vibe.d is great, but is not a complete framework from what I have seen (which is fine, since it doesn't pretend to be one, but makes it harder if you don't want to spend your time on this). And we discussed the client above. So I need to have some way for Dart to talk to D. 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. Thanks for the warning. I will have a low number of users, and whilst on occasion working data sets might be large, they won't stick around for very long so pre-allocating buffers should work fine (I hope). Thanks once again to everyone for all the suggestions and observations. Laeeth/ On Wednesday, 29 October 2014 at 22:12:32 UTC, Laeeth Isharc wrote: 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
Re: Dart bindings for D?
On Thu, 30 Oct 2014 17:39:13 + Laeeth Isharc via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: BTW what was the story behind dscript? It seems to have changed its name and no longer have so much connection to D: http://forum.dlang.org/thread/422be824.6030...@nospam.org we have rdmd now, which can be used in shebangs and allows to run D programs as shell scrips. it is able to track dependencies and caching compiled script, so 2nd and other invocations will be very fast. signature.asc Description: PGP signature
Re: Dart bindings for D?
Ah - makes sense. It is satisfyingly fast... On Thursday, 30 October 2014 at 21:33:59 UTC, ketmar via Digitalmars-d-learn wrote: On Thu, 30 Oct 2014 17:39:13 + Laeeth Isharc via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: BTW what was the story behind dscript? It seems to have changed its name and no longer have so much connection to D: http://forum.dlang.org/thread/422be824.6030...@nospam.org we have rdmd now, which can be used in shebangs and allows to run D programs as shell scrips. it is able to track dependencies and caching compiled script, so 2nd and other invocations will be very fast.
Re: Dart bindings for D?
On Thu, 30 Oct 2014 22:18:22 + Laeeth Isharc via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Ah - makes sense. It is satisfyingly fast... the only bad thing is that it trashes /tmp/.rdmd-$UID dir. i wrote another simple script that is clearing that dir (but doesn't touch 'locked' dirs, as they are obviously in use) and put it in cron. this may or may not be the issue for you. signature.asc Description: PGP signature
Re: Dart bindings for D?
On 31/10/2014 6:39 a.m., Laeeth Isharc wrote: Hi. Thanks for all the thoughts, and sorry it has taken me a little while to reply. Adam - I liked your book very much: it really complemented the other resources out there, especially in communicating a refreshing spirit of enthusiasm and fearless exploration. ketmar - I took a look at script.d very briefly. I would love if I could use some kind of D-like and D-friendly scripting language on the client (Suliman has a point!), but my understanding is that I cannot if I want to use standard browsers without a plugin - Chrome, Firefox, etc. BTW what was the story behind dscript? It seems to have changed its name and no longer have so much connection to D: http://forum.dlang.org/thread/422be824.6030...@nospam.org 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. Etienne - yes, indeed. That is exactly the problem. In theory your suggestion of compiling D to Javascript sounds intriguing, but I wonder if in practice it will be worth it on the client (I confess that you likely know much more about this than me). Even if interoperability with the ecosystem is possible, I suppose it will be clunkier to write in D compiled to JS than in Dart because there are fewer people pouring energy into the project to make it easy. I don't mind reimplementing some things on the back end in order to make it fast, beautiful, and efficient but I have no interest in re-writing anything in user interface domain. (Others may be different). As a second-best, but overall pretty appealing choice (superficially, since I haven't written anything substantial in it), Dart at least has a C-like syntax, seems to avoid most of the JS infelicities, and has some of the benefits of type-checking. It hasn't taken off yet, but my guess is it will. 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. - Adam Ruppe Proprietary trading analytics and charting - still at an early stage so the design is not fully mapped out. I understand that if I run D on server and Dart on client then I don't need to worry about APIs. But 1) if I decide to run Dart on server and write my number-crunching analytics in D then I suppose I either need the Dart headers translated to D (API) or have the Dart web server talk to a D analytics server via a socket. And 2) I cannot say that I definitely do not want to cache things and do some work on client, and so I need to see what's possible to avoid getting trapped in purely local optimum. 3) It's a long way from being relevant, but ultimately realtime data licensing occurs at local user level for Bloomberg etc, so much better to be able to tap in to a data source the user already has. Dart makes most sense for internal web applications.- Ola Yes - exactly my situation. 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? - Ola There are already C headers, and it is simple to wrap any C function manually so you can call it from Dart. Perhaps it would be possible to do something like PyD (I am still learning templates/CTFE so I don't know), but for now I was just thinking of converting the 3000 line odd (but mostly whitespace) header from .h to .d. Most of it's easy, but I struggled a bit with syntax for using alias in D to declare function pointer return types and parameters (I think I get it now). Why bother? D seems just perfect for the particular kind of quant financial work I want to do, but for the time being it is lacking on web server and client. Vibe.d is great, but is not a complete framework from what I have seen (which is fine, since it doesn't pretend to be one, but makes it harder if you don't want to spend your time on this). And we discussed the client above. So I need to have some way for Dart to talk to D. That's Cmsed, it can generate javascript (prototype currently but possible for jquery) ajax code for calling routes and CRUD for data models. The next version is a bit off from having that support but it will have much better development. 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. Thanks for the warning. I will have a low number of users, and whilst on occasion working data sets might be large, they won't stick around for very long so pre-allocating buffers should work fine (I hope). Thanks once again to everyone for all the suggestions and observations. Laeeth/ On Wednesday, 29
Re: Dart bindings for D?
On Thursday, 30 October 2014 at 17:39:14 UTC, Laeeth Isharc wrote: Thanks for the warning. I will have a low number of users, and whilst on occasion working data sets might be large, they won't stick around for very long so pre-allocating buffers should work fine (I hope). Dart+DartVM+D/C/C++ sounds like a good option for you. I have not tried integration with DartVM, but it looks like Dart team is aiming for App Engine support and they need to compete with node.js. So, it looks like DartVM support is a priority for Google.
Dart bindings for D?
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.
Re: Dart bindings for D?
On Wed, 29 Oct 2014 22:12:30 + 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. signature.asc Description: PGP signature
Re: Dart bindings for D?
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.
Re: Dart bindings for D?
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.
Re: Dart bindings for D?
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.
Re: Dart bindings for D?
On Thu, 30 Oct 2014 01:31:23 + 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. signature.asc Description: PGP signature
Re: Dart bindings for D?
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.