Thread overview
javascript or typescript
Nov 05, 2018
Fred
Nov 05, 2018
Adam D. Ruppe
Nov 05, 2018
Fred
Nov 05, 2018
Laurent Tréguier
Nov 05, 2018
Fred
Nov 05, 2018
Dukc
Nov 05, 2018
Dukc
November 05, 2018
hi,
my javascript skill is bad.
but i want to host some nodejs app

i am aware that there is converter to js like dtojs. but it is out of date.

i'd like to give d a try. is there any other converter available. a decent one.
November 05, 2018
On Monday, 5 November 2018 at 02:51:19 UTC, Fred wrote:
> i'd like to give d a try.

Why do you need to convert it to javascript? D can serve up web stuff by itself too.
November 05, 2018
On Monday, 5 November 2018 at 05:07:49 UTC, Adam D. Ruppe wrote:
> On Monday, 5 November 2018 at 02:51:19 UTC, Fred wrote:
>> i'd like to give d a try.
>
> Why do you need to convert it to javascript? D can serve up web stuff by itself too.

did you mean vibe.d?

but i want to use in a shared hosting environment where my options are : ruby, python, nodejs and as usual php

vibe.d as standalone app will not work.

i know kotlin with js support, but maybe there is another option ..


thanks for your answer and insight.
November 05, 2018
On Monday, 5 November 2018 at 02:51:19 UTC, Fred wrote:
> hi,
> my javascript skill is bad.
> but i want to host some nodejs app
>
> i am aware that there is converter to js like dtojs. but it is out of date.
>
> i'd like to give d a try. is there any other converter available. a decent one.

I haven't personally tried it, but there is an example of compiling D to Javascript here : https://github.com/Ace17/dscripten
November 05, 2018
On Monday, 5 November 2018 at 08:49:42 UTC, Laurent Tréguier wrote:
> On Monday, 5 November 2018 at 02:51:19 UTC, Fred wrote:
>> hi,
>> my javascript skill is bad.
>> but i want to host some nodejs app
>>
>> i am aware that there is converter to js like dtojs. but it is out of date.
>>
>> i'd like to give d a try. is there any other converter available. a decent one.
>
> I haven't personally tried it, but there is an example of compiling D to Javascript here : https://github.com/Ace17/dscripten

ok will look at it. thanks.
November 05, 2018
On Monday, 5 November 2018 at 02:51:19 UTC, Fred wrote:
> hi,
> my javascript skill is bad.
> but i want to host some nodejs app
>
> i am aware that there is converter to js like dtojs. but it is out of date.
>
> i'd like to give d a try. is there any other converter available. a decent one.

Let me recommend https://bridge.net/

Transpiles C# to JavaScript. I use it at work as my main tool. Feels very mature. IMO C# < D, but it still wipes the floor with using JavaScript directly.

Minority of my JavaScript is also transpiled from D. If you do the same, you will need a lot more determination and know-how than normal, and you can't except to use all D features. Multithearding and GC among other features are out.

You could use DScripten which will probably make D better in this regard, but still not like normal. Personally I haven't still tried DScripten because there is not much I could easily port to D.

The reason for that is that D cannot call most js functions directly, because it cannot handle most JavaScript types. Except if you manage to translate Emscripten headers val.h and wire.h (which are heavily templated c++) into D. I have put some effort to that, but it's not going well.

Because of the reasoms above, I don't currently recommend D as a JavaScript source for the average programmer. However, you will most likely want to make some utility programs to assist you -build scripts, mass file handling, translating configuration file formats etc. There D works very well.

Also, as said, the server backend does not have to be JavaScript - only the frontend. For backend, you can use D web frameworks -vibe.d/hunt/diamond- instead.
November 05, 2018
On Monday, 5 November 2018 at 08:49:42 UTC, Laurent Tréguier wrote:
> On Monday, 5 November 2018 at 02:51:19 UTC, Fred wrote:
>> hi,
>> my javascript skill is bad.
>> but i want to host some nodejs app
>>
>> i am aware that there is converter to js like dtojs. but it is out of date.
>>
>> i'd like to give d a try. is there any other converter available. a decent one.
>
> I haven't personally tried it, but there is an example of compiling D to Javascript here : https://github.com/Ace17/dscripten

The example I used (thanks to Cosinuns): https://github.com/cosinus2/dlang-emscripten-demo

I'd try DScripten first, though. Without, I need to compile parts of Phobos myself to JS. Plus the Emscripten linker seemingly can't link D symbols because of some bug.

I have to manually call the LLVM linker, which sometimes seems to have different ideas about what the program is calling.