www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - GWT clone

reply "Mathias Laurenz Baumann" <anonym001 supradigital.org> writes:
Greetings,

I want to write a web-library/framework, similar to [1]Webtoolkit or  
[2]GWT.
For that I need to transform a sub portion of D code to javascript.
Additionally, I dislike changing the toolchain, which means it has all to  
happen at the
compilation time.
I want to know what you think about the following possibilities and  
whether you know better ones.

a)
Write a compile-time template based parser for D to JS code and parse the  
.d files and transform them
b)
write a initialization-time parser for D to JS code, to access the D code,  
each to-be-converted file
needs to have its own code as string, like char[] src = __FILE__;


well, yea that's it, I had no more ideas to do that.
Thoughts about a):
I was told that the compile-time features are not yet that mature to do  
things like that, and that dmd would allocate
a lot of memory without freeing it to reach its goal. This could become a  
problem when the app gets bigger.

Thought about b):
It's very ugly. Very. But it should work.



[1]http://www.webtoolkit.eu/wt
[2]http://code.google.com/intl/de-DE/webtoolkit/
May 22 2010
parent reply Ellery Newcomer <ellery-newcomer utulsa.edu> writes:
On 05/22/2010 01:19 PM, Mathias Laurenz Baumann wrote:
 Greetings,

 I want to write a web-library/framework, similar to [1]Webtoolkit or
 [2]GWT.
 For that I need to transform a sub portion of D code to javascript.
 Additionally, I dislike changing the toolchain, which means it has all
 to happen at the
 compilation time.
 I want to know what you think about the following possibilities and
 whether you know better ones.

 a)
 Write a compile-time template based parser for D to JS code and parse
 the .d files and transform them
 b)
 write a initialization-time parser for D to JS code, to access the D
 code, each to-be-converted file
 needs to have its own code as string, like char[] src = __FILE__;
Sounds like an absolutely enormous job. Assuming you had a working d parser and semantic analyzer (and in-depth understanding of its inner workings), it could probably be done in less than six months (as long as the language it was written in doesn't *cough* suck). Currently, I believe there is only one semantic analyzer for D on the planet: the dmd front end. Use it as is, use Ary's port, use Denis' port. (a) is not an option in this case, unless you want to spend most of forever porting the dmd front end to compile time evaluatable D. And you will have to support the entire D language if by toolchain you mean you want access to the routines in phobos or tango or whatever. (If not, then I don't see the point of converting your D code to JS mechanically.) And then you're going to have to deal with things like extern(C), which are all over the place in both libraries, which I suspect is nontrivial or not possible. So unless I've misunderstood something, I don't think avoiding JS is really worth all the effort. Sorry for being a pessimist. Question: as someone who has never used either of the engines that you reference, do they actually perform impl language -> JS conversions?
May 22 2010
parent reply "Mathias Laurenz Baumann" <anonym001 supradigital.org> writes:
 Question: as someone who has never used either of the engines that you  
 reference, do they actually perform impl language -> JS conversions?
GWT does that for sure. Webtoolkit has a different approach, something along stateless slots. It kinda records what the serverside does and rebuilds that behavior in javascript.
 Sounds like an absolutely enormous job. Assuming you had a working d  
 parser and semantic analyzer (and in-depth understanding of its inner  
 workings), it could probably be done in less than six months (as long as  
 the language it was written in doesn't *cough* suck).
Do you think I need such a deep understanding? Couldn't I just choose to support a certain subset of D and do only more simple conversation without in-depth analysis and all this? --Marenz Am 22.05.2010, 21:15 Uhr, schrieb Ellery Newcomer <ellery-newcomer utulsa.edu>:
 On 05/22/2010 01:19 PM, Mathias Laurenz Baumann wrote:
 Greetings,

 I want to write a web-library/framework, similar to [1]Webtoolkit or
 [2]GWT.
 For that I need to transform a sub portion of D code to javascript.
 Additionally, I dislike changing the toolchain, which means it has all
 to happen at the
 compilation time.
 I want to know what you think about the following possibilities and
 whether you know better ones.

 a)
 Write a compile-time template based parser for D to JS code and parse
 the .d files and transform them
 b)
 write a initialization-time parser for D to JS code, to access the D
 code, each to-be-converted file
 needs to have its own code as string, like char[] src = __FILE__;
 Currently, I believe there is only one semantic analyzer for D on the  
 planet: the dmd front end. Use it as is, use Ary's port, use Denis'  
 port. (a) is not an option in this case, unless you want to spend most  
 of forever porting the dmd front end to compile time evaluatable D.

 And you will have to support the entire D language if by toolchain you  
 mean you want access to the routines in phobos or tango or whatever. (If  
 not, then I don't see the point of converting your D code to JS  
 mechanically.) And then you're going to have to deal with things like  
 extern(C), which are all over the place in both libraries, which I  
 suspect is nontrivial or not possible.

 So unless I've misunderstood something, I don't think avoiding JS is  
 really worth all the effort. Sorry for being a pessimist.
May 22 2010
parent Ellery Newcomer <ellery-newcomer utulsa.edu> writes:
On 05/22/2010 09:15 PM, Mathias Laurenz Baumann wrote:
 Question: as someone who has never used either of the engines that you
 reference, do they actually perform impl language -> JS conversions?
GWT does that for sure.
Interesting. Maybe I'll have a look at it sometime.
 Do you think I need such a deep understanding? Couldn't I just choose to
 support a certain subset of D and do only more simple conversation
 without in-depth analysis and all this?
I was mostly alluding to dmd. It's a complicated critter and rather large. Maybe not so friendly. But I really don't know what else you'd use. But yeah, if you restrict the language and library use enough, you could probably reduce it to a workable problem.
May 22 2010