SafeD & Java
Jacob Carlborg
doob at me.com
Thu Jul 8 01:53:07 PDT 2010
On 2010-07-08 08.02, Jeremy Powers wrote:
>> In any case, while Java should be fairly easily converted to D automatically (at
>> least as far as the language itself goes - not the libraries), I'm not aware of
>> any project that's designed to do that.
>
> What you describe is pretty close to the track that DWT(2) has taken -
> porting SWT from Java by basically stubbing out the Java standard
> library and then tweaking the Java source.
>
> http://www.dsource.org/projects/dwt
>
> There's also this project, though I don't know what state it is in:
>
> http://www.dsource.org/projects/tioport
As far as I know that project is dead. The goal of the project was to
automatically port SWT from Java to D. It failed since you basically
have to implement the whole (or at least a too big part) of the Java
standard library.
Another problem is that some language constructs in Java have the same
syntax in D but with different semantics.
> 2010/7/7 Jonathan M Davis<jmdavisprog at gmail.com>:
>> On Wednesday 07 July 2010 21:46:01 fantasticfears wrote:
>>> I know Java programs can be machine-translated into SafeD from
>>> http://www.digitalmars.com/d/2.0/safed.html.
>>> But what's the difference between SafeD and Java?
>>
>> SafeD is the safe subset of D. So, it disallows stuff like pointers, but most of
>> the language qualifies as "safe," so asking what the difference between SafeD and
>> Java pretty much amounts to asking what the difference between D and Java is, and
>> since they're two separate languages, that's a fair bit. Now, for the most part,
>> D has more than Java, so it would be easier to convert Java to D than the other
>> way around (for instance, D has structs while Java doesn't, but they both have
>> classes; so converting the Java classes to D classes would be fairly
>> straightforward, but converting D structs to Java classes would not). Generally
>> speaking, I think that a Java program will have pretty much the same semantics
>> as D if you tried to compile it as D (though there are bound to be differences -
>> like how they char types are totally different). The main problem that you're
>> going to run into is that the libraries are completely different.
>>
>> So, while the language itself might convert quite easily, as soon as you're
>> using the libraries (as you inevitably will be), you're going to have to figure
>> out what libraries in D do the same thing, and given the size of Java's standard
>> library, depending on what you're doing there's a good chance that you'd have to
>> implement a fair bit of it yourself in D. D has some great library stuff, but
>> it's nowhere near as complete as Java's libraries.
>>
>> In any case, while Java should be fairly easily converted to D automatically (at
>> least as far as the language itself goes - not the libraries), I'm not aware of
>> any project that's designed to do that.
>>
>> - Jonathan M Davis
>>
--
Jacob Carlborg
More information about the Digitalmars-d
mailing list