www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Writing Java in D

reply =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
Here's a followup to the other popular thread here,
"Writing C in D" (even though that one was hijacked)

For fun, I implemented Java's String, List and Map in D.
(not the real classes, just something resembling them...)


I called it "Dcaf" :
http://www.algonet.se/~afb/d/dcaf/html/class_string.html
http://www.algonet.se/~afb/d/dcaf/html/class_string_buffer.html
http://www.algonet.se/~afb/d/dcaf/html/struct_list.html
http://www.algonet.se/~afb/d/dcaf/html/struct_map.html

I didn't make them generic (templates), since it was just
a simple toy example on how one can write Java-like D code ?

The real classes are :
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/StringBuffer.html
http://java.sun.com/j2se/1.4.2/docs/api/java/util/List.html
http://java.sun.com/j2se/1.4.2/docs/api/java/util/Map.html


Also filled in some missing parts on the "Java to D" page:
http://www.prowiki.org/wiki4d/wiki.cgi?JavaToD

The idea was to have it put next to the other such pages,
that is "C to D" and "C++ to D" in the main documentation.
http://www.digitalmars.com/d/ctod.html
http://www.digitalmars.com/d/cpptod.html

I think D would actually be easier for Java programmers than
C or C++ would, due to them having several things in common...


Porting some real Java code and running some benchmarks would be fun ?
Who knows, it might even have some real use... (Like for "molt" or so)
http://dsource.org/projects/molt/

--anders
Mar 29 2005
next sibling parent reply Dejan Lekic <leka entropy.tmok.com> writes:
Anders, IMHO that is too much of wasted energy and time. If someone wants to
REALY contribute to D - better to work on pure, "native" UI, ie. standard D
UI which would be used everywhere, or to help DTL project, or Phobos,
or ... core D .

D needs good, stable, flexible frameworks for common programming tasks - DB,
NET, UI, SCIENCE, ...

-- 
...........
Dejan Lekic
  http://dejan.lekic.org
  
Mar 29 2005
parent reply =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
Dejan Lekic wrote:

 Anders, IMHO that is too much of wasted energy and time.
And I didn't even get paid to do it, either... :-) You might be overestimating the amount of time that went into it, though. (not into D, but into "Java-D") It was just a quick hack.
 If someone wants to
 REALY contribute to D - better to work on pure, "native" UI, ie. standard D
 UI which would be used everywhere, or to help DTL project, or Phobos,
 or ... core D .
I've done those. Too. This was just a little side-track. My reasoning wen't like: If it's easier for Java programmers to start with D, then those same programmers could help out with D too ? --anders
Mar 29 2005
next sibling parent pragma <pragma_member pathlink.com> writes:
In article <d2btof$1nr2$1 digitaldaemon.com>,
=?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= says...
My reasoning wen't like:
If it's easier for Java programmers to start with D,
then those same programmers could help out with D too ?
Don't let anyone's opinion deter you. IMO, anything that can accelerate the adoption of D by new programmers, is a good thing. BTW, I like the 'Dcaf' name. Now, what we really need is something along the lines of a "methodone" lib to get the c++ junkies un-hooked and on to D. <j/k> - EricAnderton at yahoo
Mar 29 2005
prev sibling parent reply nobody d.com writes:
In article <d2btof$1nr2$1 digitaldaemon.com>,
=?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= says...
If it's easier for Java programmers to start with D,
then those same programmers could help out with D too ?
Yes, and I think Java programmers will also be delighted to see those familiar utility classes and APIs instead of learning a new one. This certainly will help them to start using D. BTW, whey you choose to JDK1.4.2? If you hack the 1.5 code, we will get all the good template stuff for free: e.g. http://java.sun.com/j2se/1.5.0/docs/api/java/util/Map.html I hate to cast everything back and forth from Object!
Mar 29 2005
parent =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
nobody d.com wrote:

 Yes, and I think Java programmers will also be delighted to see those familiar
 utility classes and APIs instead of learning a new one.  This certainly will
 help them to start using D.
It wasn't really intended as a standard library, just to show how it *could* be implemented in D...
 BTW, whey you choose to JDK1.4.2? 
Because JDK 1.5 is not available for PowerPC yet ? And besides, I only know JDK 1.4.2 myself anyway :-) --anders
Mar 29 2005
prev sibling next sibling parent reply "Ben Hinkle" <bhinkle mathworks.com> writes:
 I called it "Dcaf" :
cute :-)
 Also filled in some missing parts on the "Java to D" page:
 http://www.prowiki.org/wiki4d/wiki.cgi?JavaToD

 The idea was to have it put next to the other such pages,
 that is "C to D" and "C++ to D" in the main documentation.
 http://www.digitalmars.com/d/ctod.html
 http://www.digitalmars.com/d/cpptod.html

 I think D would actually be easier for Java programmers than
 C or C++ would, due to them having several things in common...
agreed - porting Java to D is pretty easy. I'll add some more tips to that page: non-trivial initialization of data members must go in ctors, how to deal with inner classes and how to port synchronization constructs.
 Porting some real Java code and running some benchmarks would be fun ?
 Who knows, it might even have some real use... (Like for "molt" or so)
 http://dsource.org/projects/molt/
I added the port of Doug Lea's Java locks library to that list as another example.
Mar 29 2005
parent "Walter" <newshound digitalmars.com> writes:
"Ben Hinkle" <bhinkle mathworks.com> wrote in message
news:d2bslg$1mv2$1 digitaldaemon.com...
 I called it "Dcaf" :
cute :-)
I think that's inspired <g>.
 agreed - porting Java to D is pretty easy. I'll add some more tips to that
 page: non-trivial initialization of data members must go in ctors, how to
 deal with inner classes and how to port synchronization constructs.
These will be a big help.
Mar 29 2005
prev sibling next sibling parent J C Calvarese <jcc7 cox.net> writes:
Anders F Björklund wrote:
 Here's a followup to the other popular thread here,
 "Writing C in D" (even though that one was hijacked)
 
 For fun, I implemented Java's String, List and Map in D.
 (not the real classes, just something resembling them...)
 
 
 I called it "Dcaf" :
Awesome! ...
 I think D would actually be easier for Java programmers than
 C or C++ would, due to them having several things in common...
Sure. And there's no reason why we should look only to the C/C++ community for converts. Everyone's invited. -- jcc7 http://jcc_7.tripod.com/d/
Mar 29 2005
prev sibling parent David L. Davis <SpottedTiger yahoo.com> writes:
In article <d2bjsu$1aun$1 digitaldaemon.com>,
=?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= says...
Here's a followup to the other popular thread here,
"Writing C in D" (even though that one was hijacked)

For fun, I implemented Java's String, List and Map in D.
(not the real classes, just something resembling them...)


I called it "Dcaf" :

--anders
A very original name, that's cute...I like it! :)) David L. ------------------------------------------------------------------- "Dare to reach for the Stars...Dare to Dream, Build, and Achieve!"
Mar 29 2005