www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Making D Lang More easy.

reply Matthew Ong <ongbp yahoo.com> writes:
Hi All,

Recently I have been looking into another alternative programming
language to Java 1.6 and C++:

I narrowed downed to 2: Google Go and D Programming.
Preference has been given to D compare to Go for a few reasons like
more keywords than java(superset) and supports build in

I also downloaded the http://d-ide.sourceforge.net/.
This IDE is small foot print and tries to be like visual studio.
Why not someone in D consider porting this to a more mature IDE like:

SharpDevelop
http://sharpdevelop.net/OpenSource/SD/Default.aspx
Or
NetBeans or Eclipse
Instead of re-inventing the wheel?

1) D is a feature rich and seems to generate a really small file size
foot print for both *.dll and *.exe (Nice!!) compare to Google Go.


2) D Supports Interface and Class inheritance. (Nice!!)
   However I seems to have problem to model something like this in D:

   public class MyException extends Exception implements
SomeInterface{
   }

   I tried:
   class MyException : Exception, SomeInterface{ // << That cause
compilation error. Why??? How to work around or solution?
   }

   This allow me to move some of my library that I have build in java
into D without much remodeling and refactoring lots of code. (Really
nice!!!) compare to google go which build around a entirely different
object modeling concept. (That concepts sounded good and uses a lot of
interfaces and . Like java.sql.*)

3) As D seems to have direct support to C API which make direct OS
resource access and writing cool OS level tool a really nice work.
Have not tried anything yet, but seems to be more matured than Google
Go.

4) Is there also a Code formatting tool like:
   gofmt Gofmt formats Go programs. // That save me a lot to time.
   The Netbeans and eclipse has this build in feature.

5) import std.stdio; // The imports seems to be more complex to use
than java's import. There should be a tool to help resolved this and
also makes the order of importing of not important like in java.

6) Is there some build in source code checking command like:
 govet
http://golang.org/cmd/

7) How about unit test, is there a library like junit or cppunit
   is there something similar that can allow code to be profile,
tested and validated?

May I also ask, does the compiler and linker highlight the unused
import to the user so that they can be removed from source code.


The have experienced with C++ and C since back in the turbo c dos day
and Java. D seems to be promising. Overall nice and good. But can be
improved more to simplified coding cycle.
May 11 2011
next sibling parent reply Mafi <mafi example.org> writes:
Am 11.05.2011 15:41, schrieb Matthew Ong:
 Hi All,
Hi
 Recently I have been looking into another alternative programming
 language to Java 1.6 and C++:

 I narrowed downed to 2: Google Go and D Programming.
 Preference has been given to D compare to Go for a few reasons like
 more keywords than java(superset) and supports build in

 I also downloaded the http://d-ide.sourceforge.net/.
 This IDE is small foot print and tries to be like visual studio.
 Why not someone in D consider porting this to a more mature IDE like:

 SharpDevelop
 http://sharpdevelop.net/OpenSource/SD/Default.aspx
 Or
 NetBeans or Eclipse
 Instead of re-inventing the wheel?
For Eclipse there is for example DDT and there are VisualD and Descent. http://code.google.com/a/eclipselabs.org/p/ddt/
 1) D is a feature rich and seems to generate a really small file size
 foot print for both *.dll and *.exe (Nice!!) compare to Google Go.


 2) D Supports Interface and Class inheritance. (Nice!!)
     However I seems to have problem to model something like this in D:

     public class MyException extends Exception implements
 SomeInterface{
     }

     I tried:
     class MyException : Exception, SomeInterface{ //<<  That cause
 compilation error. Why??? How to work around or solution?
     }
That is strange. Maybe you did something else wrong. The following works on my machine and dmd 2.051 (not the newest!). class C {} interface I { void print(); } abstract class D : C, I {} void main() {}
     This allow me to move some of my library that I have build in java
 into D without much remodeling and refactoring lots of code. (Really
 nice!!!) compare to google go which build around a entirely different
 object modeling concept. (That concepts sounded good and uses a lot of
 interfaces and . Like java.sql.*)

 3) As D seems to have direct support to C API which make direct OS
 resource access and writing cool OS level tool a really nice work.
 Have not tried anything yet, but seems to be more matured than Google
 Go.

 4) Is there also a Code formatting tool like:
     gofmt Gofmt formats Go programs. // That save me a lot to time.
     The Netbeans and eclipse has this build in feature.

 5) import std.stdio; // The imports seems to be more complex to use
 than java's import. There should be a tool to help resolved this and
 also makes the order of importing of not important like in java.
The module system has been given much attention so that the import order doesn't matter and you cannot use an ambigous symbol without error. Because there's no VM, you have to import everything you want to use. If you know C++, think of it like #include and using namespace x; at the same time. http://d-programming-language.org/module.html#ImportDeclaration
 6) Is there some build in source code checking command like:
   govet
 http://golang.org/cmd/

 7) How about unit test, is there a library like junit or cppunit
     is there something similar that can allow code to be profile,
 tested and validated?
Simple unittesting is built in with the unittest block. Use -unittest to compile a unit test version (dmd). D also supports contracts and asserts. http://d-programming-language.org/dbc.html http://d-programming-language.org/unittest.html If you want to benchmark use std.datetime.StopWatch (http://d-programming-language.org/phobos/std_datetime.html#StopWatch).
 May I also ask, does the compiler and linker highlight the unused
 import to the user so that they can be removed from source code.
That sounds like an interesting feature but is AFAIK not implemented yet.
 The have experienced with C++ and C since back in the turbo c dos day
 and Java. D seems to be promising. Overall nice and good. But can be
 improved more to simplified coding cycle.
I hope I could help you, Mafi
May 11 2011
next sibling parent reply Matthew Ong <ongbp yahoo.com> writes:
Hi Mafi,

Thanks very much for the prompt reply. Thanks for the various links.
BTW, are you an employee within digitalmars?


class C {}
interface I { void print(); }
abstract class D: C,I {}
void main() {}
I need class D to be solid class doing both inherits from C but allow me to provide code and for interface I. BTW, does it matter if the compilation process goes this way? The order of the code appearing in different file.
abstract class D: C,I {}
class C {}
interface I { void print(); }
I am aware about dmd -Ipath option. And yes, import works like include which means (yucks!) I believe it would use the behavior of import in java. I like to maintain different class/interface/function into different file, the dmd process seem to be too particular to compile the file in a specific order unlike javac all I need to make sure those other class/interfaces i needed are within the directory or -classpath options. That is also why I posted the import question in item 5. Google Go seems to not care about this, if I am not wrong. I believe the compiler and linker should be smart to resolved this using some internal mapping. Any new programming language should frees the developer to focus more on their business logic than to maintain library and dependency. Btw, any benchmark done officially comparing google go/java/D? I do run cygwin and D on a windows vista platform. Matthew ongbp yahoo.com
May 11 2011
next sibling parent reply Mafi <mafi example.org> writes:
Am 11.05.2011 16:48, schrieb Matthew Ong:
 Hi Mafi,

 Thanks very much for the prompt reply. Thanks for the various links.
 BTW, are you an employee within digitalmars?


 class C {}
 interface I { void print(); }
 abstract class D: C,I {}
 void main() {}
I need class D to be solid class doing both inherits from C but allow me to provide code and for interface I.
import std.stdio; class C { void print() { writeln("print");} } interface I { void print(); void print2();} class D : C, I { void print() { super.print(); } void print2() { writeln("print2"); } } void main() { auto d = new D; d.print(); d.print2(); }
 BTW, does it matter if the compilation process goes this way?
 The order of the code appearing in different file.
The order in which appear declarations does not matter in D. If it does, it's a bug. The file in which you define and the order in which you import does not matter. There's never function shadowing in that form. (functions in this module shadow imported functions and some other minor stuff).
 abstract class D: C,I {}
 class C {}
 interface I { void print(); }
I am aware about dmd -Ipath option. And yes, import works like include which means (yucks!) I believe it would use the behavior of import in java.
There are modules in D meaning that every file corresponds to exactly one module which builds a namespace. When you import you just make symbols of other modules visible. They are not compiled in. Have to link with the module to make them available.
 I like to maintain different class/interface/function into different
 file, the dmd process seem to be too particular to compile the file
 in a specific order unlike javac all I need to make sure those other
 class/interfaces i needed are within the directory or -classpath
 options.
The order in which you compile and link does not matter in D.
 That is also why I posted the import question in item 5. Google Go
 seems to not care about this, if I am not wrong. I believe the
 compiler and linker should be smart to resolved this using some
 internal mapping.

 Any new programming language should frees the developer to focus
 more on their business logic than to maintain library and
 dependency.
Here you are probably right but a language can't have this with having both: - being compiled to native machine code - and not have a standard install mechanism, which D should avoid so it doesn't interfere with OS install systems (eg apt).
 Btw, any benchmark done officially comparing google go/java/D?

 I do run cygwin and D on a windows vista platform.

 Matthew
 ongbp yahoo.com
Mafi
May 11 2011
parent Matthew Ong <ongbp yahoo.com> writes:
Hi Walter/Mafi/anyone,

There are modules in D meaning that every file corresponds to exactly
one module which builds a namespace.
When you import you just make symbols of other modules visible. They are not
compiled in. Have to link with the module to make them available.

Using the sample code that mafi provided, how to break them into different file
like:

I.d , C.d and import both C & I within D.d file from entirely different
module/or
same module namespace?

See the code:
 I need class D to be solid class doing both inherits from C but
 allow me to provide code and for interface I.
import std.stdio; class C { void print() { writeln("print");} } interface I { void print(); void print2();} class D : C, I { void print() { super.print(); } void print2() { writeln("print2"); } } void main() { auto d = new D; d.print(); d.print2(); }
May 12 2011
prev sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 5/11/2011 7:48 AM, Matthew Ong wrote:
 Btw, any benchmark done officially comparing google go/java/D?
We don't do official benchmarks because of the bad feeling and accusations of of manipulation they inevitably engender.
May 11 2011
parent reply Russel Winder <russel russel.org.uk> writes:
On Wed, 2011-05-11 at 11:27 -0700, Walter Bright wrote:
 On 5/11/2011 7:48 AM, Matthew Ong wrote:
 Btw, any benchmark done officially comparing google go/java/D?
=20 We don't do official benchmarks because of the bad feeling and accusation=
s of of=20
 manipulation they inevitably engender.
I have some rather more anecdotal than experimental benchmarks for a couple of classes of problem covering a large number of languages. What is the information OP is after? The summary I have is that D is faster than Go which is faster than Java in some circumstance for some problems. Conversely the reverse is also true for different problems. Of course source development and evolution time is a different metric and D and Go win hands down over Java, but then so does Groovy. And indeed Python. I guess the overall summary is that OP's "any benchmark done officially comparing" is a complete underspecification of the parameters of comparison. --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel russel.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
May 11 2011
parent reply Matthew Ong <ongbp yahoo.com> writes:
 Dr Russel Winder:

The summary I have is that D is faster than Go which is faster than Java
in some circumstance for some problems.  Conversely the reverse is also
true for different problems.
-------------------------------------

Performace over java with D/Go that for sure. I have narrowed down to this 2 as


but then so does Groovy. And indeed Python.
Groovy, Python, JRuby, Mirah. They are not compile time type checking. They are strong for writing limited scope like to replace jsp/php... Because of that, the large scale programming needs to have some sort of compile time type checking to minimized the runtime casting error. Do u have the sample code for a typical data access of, kindly please email to: ongbp yahoo.com
May 12 2011
parent reply Russel Winder <russel russel.org.uk> writes:
On Thu, 2011-05-12 at 10:31 +0000, Matthew Ong wrote:
  Dr Russel Winder:
=20
 The summary I have is that D is faster than Go which is faster than Java
 in some circumstance for some problems.  Conversely the reverse is also
 true for different problems.
 -------------------------------------
=20
 Performace over java with D/Go that for sure. I have narrowed down to thi=
s 2 as

a? CLR is just Microsoft's version of JVM but altered so as to avoid law suits. I think JVM optimization has had more work done than CLR problem on the same hardware. Generally for large computations Go is currently slower than Java but D is much faster than either, and C++ and C faster still. Fortran beats all. The JVM is not a barrier to performance, indeed there is some data to show that dynamic optimization can lead to faster code than static optimization. Do not assume "bytecode interpreter means slow", just in time compilation can give lie to this.
but then so does Groovy. And indeed Python.
Groovy, Python, JRuby, Mirah. They are not compile time type checking. They are strong for writing limited scope like to replace jsp/php... Because of that, the large scale programming needs to have some sort of c=
ompile
 time type checking to minimized the runtime casting error.
=20
=20
 Do u have the sample code for a typical data access of, kindly please ema=
il to:
=20
 ongbp yahoo.com
I put my little experimental codes in microbenchmarking in Bazaar branches accessible on my web site. Note this is microbenchmarking with all the hassles that go with it. Especially when using JITs. --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel russel.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
May 12 2011
parent reply Matthew Ong <ongbp yahoo.com> writes:
On 5/12/2011 7:19 PM, Russel Winder wrote:
Hi Russel,
I looked into this URL,
http://www.russel.org.uk/Bazaar/

 I put my little experimental codes in microbenchmarking in Bazaar
 branches accessible on my web site.  Note this is microbenchmarking with
 all the hassles that go with it.  Especially when using JITs.
Not quite sure which one you are refering to. -- Matthew Ong email: ongbp yahoo.com
May 16 2011
parent reply Russel Winder <russel russel.org.uk> writes:
On Mon, 2011-05-16 at 22:54 +0800, Matthew Ong wrote:
 On 5/12/2011 7:19 PM, Russel Winder wrote:
 Hi Russel,
 I looked into this URL,
 http://www.russel.org.uk/Bazaar/
=20
 I put my little experimental codes in microbenchmarking in Bazaar
 branches accessible on my web site.  Note this is microbenchmarking wit=
h
 all the hassles that go with it.  Especially when using JITs.
=20 Not quite sure which one you are refering to.
Apologies I underspecified. The one you are probably looking for is Pi_Quadrature. This is a simple embarrasingly parallel calculation (of the value of Pi using a straightforward quadrature. This allows for simple comparison of data parallelism and the various message passing and explicit thread usage systems. It is not really intended for serious benchmarking, it is more a "toy" problem for showing all the issues -- include JVM JIT startup issues. If you want to branch the branch using Bazaar then use the URL http://www.russel.org.uk/Bazaar/Pi_Quadrature. If you want to browse the code then there is an instance of Loggerhead running so point your browser at the URL http://www.russel.org.uk:8080/Pi_Quadrature Hopefully that is a better explanation :-) --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel russel.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
May 16 2011
parent reply bearophile <bearophileHUGS lycos.com> writes:
Russel Winder:

 If you want to branch the branch using Bazaar then use the URL
 http://www.russel.org.uk/Bazaar/Pi_Quadrature.  If you want to browse
 the code then there is an instance of Loggerhead running so point your
 browser at the URL http://www.russel.org.uk:8080/Pi_Quadrature
There's even a Chapel version :-) I like several ideas of the Chapel language design. Where are the results of the benchmarks? Bye, bearophile
May 16 2011
parent Russel Winder <russel russel.org.uk> writes:
On Mon, 2011-05-16 at 13:32 -0400, bearophile wrote:
 Russel Winder:
=20
 If you want to branch the branch using Bazaar then use the URL
 http://www.russel.org.uk/Bazaar/Pi_Quadrature.  If you want to browse
 the code then there is an instance of Loggerhead running so point your
 browser at the URL http://www.russel.org.uk:8080/Pi_Quadrature
=20 There's even a Chapel version :-) I like several ideas of the Chapel lang=
uage design.
 Where are the results of the benchmarks?
Chapel is very good if you like PGAS (which I am not sure I do), it is also quite efficient in use of resources (kudos to Brad et al.). X10 is profligate with resources so is definitely not on my "like" list just now (apologies to Igor and the rest of the X10 team, but . . . ). Fortress is interesting as it goes for the "you write mathematics and we'll code generate" approach, which is very interesting -- assuming Oracle continue to fund the activity. There are no published results from my codes, it is all very much "do it yourself" as far as numbers are concerned. The codes are all about anecdotal evidence not about structured statistical results. Yes structured statistical results could be created, but is it worth it? =20 --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel russel.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
May 16 2011
prev sibling parent reply Jonathan M Davis <jmdavisProg gmx.com> writes:
On 2011-05-11 07:22, Mafi wrote:
 The module system has been given much attention so that the import order
 doesn't matter and you cannot use an ambigous symbol without error.
 Because there's no VM, you have to import everything you want to use.
 If you know C++, think of it like #include and using namespace x; at the
 same time.
 http://d-programming-language.org/module.html#ImportDeclaration
That's an odd comment to make. D's import is very similar to Java's import and is far more like Java's import than C/C++'s #include. D is probably pickier about possible name conflicts, but in general, importing in D and Java and pretty much the same. You're specifically importing _modules_ in D, and D doesn't enforce 1 public class per file, so the syntax is a bit different when importing specific classes rather than a whole module, and you do have to deal with the possibility of conflicting free functions whereas they aren't even legal in Java, but overall importing in Java and D and pretty similar. I don't know why you'd be comparing D's import to C/C++'s #include rather than Java's import. - Jonathan M Davis
May 11 2011
parent reply Mafi <mafi example.org> writes:
Am 11.05.2011 18:17, schrieb Jonathan M Davis:
 On 2011-05-11 07:22, Mafi wrote:
 The module system has been given much attention so that the import order
 doesn't matter and you cannot use an ambigous symbol without error.
 Because there's no VM, you have to import everything you want to use.
 If you know C++, think of it like #include and using namespace x; at the
 same time.
 http://d-programming-language.org/module.html#ImportDeclaration
That's an odd comment to make. D's import is very similar to Java's import and is far more like Java's import than C/C++'s #include. D is probably pickier about possible name conflicts, but in general, importing in D and Java and pretty much the same. You're specifically importing _modules_ in D, and D doesn't enforce 1 public class per file, so the syntax is a bit different when importing specific classes rather than a whole module, and you do have to deal with the possibility of conflicting free functions whereas they aren't even legal in Java, but overall importing in Java and D and pretty similar. I don't know why you'd be comparing D's import to C/C++'s #include rather than Java's import. - Jonathan M Davis
(Note that I meant #including .h-files) What I wanted to make absolutely clear is that you can't just say java.util.ArrayList without explicitely importing java.util in D. It is possible in Java but not in D. Importing in Java is like 'using some_class;' in C++.
May 11 2011
next sibling parent Jonathan M Davis <jmdavisProg gmx.com> writes:
On 2011-05-11 09:26, Mafi wrote:
 Am 11.05.2011 18:17, schrieb Jonathan M Davis:
 On 2011-05-11 07:22, Mafi wrote:
 The module system has been given much attention so that the import order
 doesn't matter and you cannot use an ambigous symbol without error.
 Because there's no VM, you have to import everything you want to use.
 If you know C++, think of it like #include and using namespace x; at the
 same time.
 http://d-programming-language.org/module.html#ImportDeclaration
That's an odd comment to make. D's import is very similar to Java's import and is far more like Java's import than C/C++'s #include. D is probably pickier about possible name conflicts, but in general, importing in D and Java and pretty much the same. You're specifically importing _modules_ in D, and D doesn't enforce 1 public class per file, so the syntax is a bit different when importing specific classes rather than a whole module, and you do have to deal with the possibility of conflicting free functions whereas they aren't even legal in Java, but overall importing in Java and D and pretty similar. I don't know why you'd be comparing D's import to C/C++'s #include rather than Java's import. - Jonathan M Davis
(Note that I meant #including .h-files) What I wanted to make absolutely clear is that you can't just say java.util.ArrayList without explicitely importing java.util in D. It is possible in Java but not in D. Importing in Java is like 'using some_class;' in C++.
Well, in a way. The issue is that in Java, you must have one public class per file, whereas in D, you can have whatever you want in a module. So, you're specifically importing a file in either case. It's just that Java is much more fine-grained about what goes in a file. But I see what you're saying. In that sense, D is more like C++. The import mechanism is very similar between the two, but the difference in how files are laid out does definitely change things. - Jonathan M Davis
May 11 2011
prev sibling parent reply Matthew Ong <ongbp yahoo.com> writes:
Hi Mafi,

Thanks very much for the response in earlier post about the solid class.

just FYI: import java.util.ArrayList; // can be written as
import std.container : SList;


module gc.gcalloc;// from here.
 private import gcx : PAGESIZE; // are they the same or very different?
May 12 2011
parent reply Jonathan M Davis <jmdavisProg gmx.com> writes:
On 2011-05-12 04:01, Matthew Ong wrote:
 Hi Mafi,
 
 Thanks very much for the response in earlier post about the solid class.
 
 just FYI: import java.util.ArrayList; // can be written as
 import std.container : SList;
The syntax is valid for importing only a specific type or function from a module, though I'd point out that SList and ArrayList are very different container types in case you thought that they were at all the same.
 module gc.gcalloc;// from here.
  private import gcx : PAGESIZE; // are they the same or very different?
All imports are private by default, so adding private to it does nothing. Adding public to it makes it so that any module importing the module with the import in it also imports what that import imports. So public does something there, but private is a no-op. - Jonathan M Davis
May 12 2011
parent Matthew Ong <ongbp yahoo.com> writes:
On 5/12/2011 11:17 PM, Jonathan M Davis wrote:
 On 2011-05-12 04:01, Matthew Ong wrote:
 Hi Mafi,

 Thanks very much for the response in earlier post about the solid class.

 just FYI: import java.util.ArrayList; // can be written as
 import std.container : SList;
The syntax is valid for importing only a specific type or function from a module, though I'd point out that SList and ArrayList are very different container types in case you thought that they were at all the same.
 module gc.gcalloc;// from here.
   private import gcx : PAGESIZE; // are they the same or very different?
All imports are private by default, so adding private to it does nothing. Adding public to it makes it so that any module importing the module with the import in it also imports what that import imports. So public does something there, but private is a no-op. - Jonathan M Davis
Thanks Jonathan & Mafi for really contributing to allow me to learn the detail differences of D importing. The ugly trail I posted about compilation error is due to -lib option always being dropped by the D-IDE and since, I switched to eclipse DDT as mafi suggested and also ONLY have ONE file(I do not like this limitation) per module. That problem is resolved. -- Matthew Ong email: ongbp yahoo.com
May 16 2011
prev sibling next sibling parent reply "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
I'll reply to points not addressed by others.

On Wed, 11 May 2011 16:41:25 +0300, Matthew Ong <ongbp yahoo.com> wrote:

 1) D is a feature rich and seems to generate a really small file size
 foot print for both *.dll and *.exe (Nice!!) compare to Google Go.
Funny, many people (myself included) think the executable size is still much larger than it can/should be :)
 4) Is there also a Code formatting tool like:
    gofmt Gofmt formats Go programs. // That save me a lot to time.
    The Netbeans and eclipse has this build in feature.
IIRC, Descent (D Eclipse plugin) has a decent code formatter. Uncrustify ( http://uncrustify.sourceforge.net/ ) supports D.
 6) Is there some build in source code checking command like:
  govet
 http://golang.org/cmd/
There isn't, but you can pass the -c -o- flags to dmd to only compile given modules and not write object files. -- Best regards, Vladimir mailto:vladimir thecybershadow.net
May 11 2011
parent reply Matthew Ong <ongbp yahoo.com> writes:
Hi Vladimir,

Thanks for the response. It was helpful.

IIRC, Descent (D Eclipse plugin) has a decent code formatter.
Uncrustify ( http://uncrustify.sourceforge.net/ ) supports D.
There is not much documentation. How do u include that into an IDE? Do u use D-IDE or others. Currently I use D-IDE from sourceforge.
May 12 2011
parent reply "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Thu, 12 May 2011 13:15:23 +0300, Matthew Ong <ongbp yahoo.com> wrote:

 Hi Vladimir,

 Thanks for the response. It was helpful.

 IIRC, Descent (D Eclipse plugin) has a decent code formatter.
 Uncrustify ( http://uncrustify.sourceforge.net/ ) supports D.
There is not much documentation. How do u include that into an IDE?
It's a command-line tool. IDE integration depends on your IDE's capabilities.
 Do u use D-IDE or others. Currently I use D-IDE from sourceforge.
I use FAR ( http://thecybershadow.net/d/colorer/ ), and I can integrate Uncrustify with it if I wanted to, but it's not for everyone. -- Best regards, Vladimir mailto:vladimir thecybershadow.net
May 13 2011
next sibling parent Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
You can use http://universalindent.sourceforge.net/, which embeds
several code-formatters, one of which is uncrustify, and provides a
nice GUI.

You'll have to replace the Uncrustify executable when new updates come
out, as UniversalIndent isn't kept up to date at all times. The
uncrustify author does regular updates, he recently fixed some enum
indentation bug for D so you can always report new bugs to his
sourceforge page: http://uncrustify.sourceforge.net/.
May 13 2011
prev sibling parent reply Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
And here is how I use uncrustify via a batch file:

"D:/Apps/UniversalIndentGUI_win32/indenters/uncrustify.exe"
--no-backup --replace %1 -c
"D:/Apps/UniversalIndentGUI_win32/indenters/uncrustify.cfg"

%1 is the filename, e.g. "C:/main.d", --no-backup means exactly what
it says, you might want to remove that to be safe.

You could easily make a key shortcut to invoke such a script, as long
as you can get the name of the currently opened file in whatever IDE
you're using.
May 13 2011
parent Matthew Ong <ongbp yahoo.com> writes:
On 5/14/2011 5:52 AM, Andrej Mitrovic wrote:
 And here is how I use uncrustify via a batch file:

 "D:/Apps/UniversalIndentGUI_win32/indenters/uncrustify.exe"
 --no-backup --replace %1 -c
 "D:/Apps/UniversalIndentGUI_win32/indenters/uncrustify.cfg"

 %1 is the filename, e.g. "C:/main.d", --no-backup means exactly what
 it says, you might want to remove that to be safe.

 You could easily make a key shortcut to invoke such a script, as long
 as you can get the name of the currently opened file in whatever IDE
 you're using.
Hi Andrej, Thanks very much. -- Matthew Ong email: ongbp yahoo.com
May 16 2011
prev sibling next sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 5/11/2011 6:41 AM, Matthew Ong wrote:
 5) import std.stdio; // The imports seems to be more complex to use
 than java's import. There should be a tool to help resolved this and
 also makes the order of importing of not important like in java.
Not sure what you mean by more complex than Java. The order of imports in D is not important.
 6) Is there some build in source code checking command like:
   govet
 http://golang.org/cmd/
No.
 7) How about unit test, is there a library like junit or cppunit
     is there something similar that can allow code to be profile,
 tested and validated?
D has builtin unittest support with the -unittest switch: http://www.digitalmars.com/d/2.0/unittest.html a builtin profiler enabled with the -profile switch: http://www.digitalmars.com/ctg/trace.html and builtin code coverage analysis with the -cov switch: http://www.digitalmars.com/d/2.0/code_coverage.html
 May I also ask, does the compiler and linker highlight the unused
 import to the user so that they can be removed from source code.
This was discussed and we decided it was not a good idea for various reasons.
May 11 2011
next sibling parent reply bearophile <bearophileHUGS lycos.com> writes:
Walter:

 May I also ask, does the compiler and linker highlight the unused
 import to the user so that they can be removed from source code.
This was discussed and we decided it was not a good idea for various reasons.
Maybe we'll discuss about that again, because giving a help to remove unwanted dependencies has its advantages. Bye, bearophile
May 11 2011
parent reply Timon Gehr <timon.gehr gmx.ch> writes:
 Walter:

 May I also ask, does the compiler and linker highlight the unused
 import to the user so that they can be removed from source code.
This was discussed and we decided it was not a good idea for various reasons.
Maybe we'll discuss about that again, because giving a help to remove unwanted
dependencies has its advantages.
 Bye,
 bearophile
I do not think this should be a compiler feature. It sounds like a task more suitable for a source code analyzer. Apart from that, if you need that functionality, you can easily write a small script that comments out all imports in turn and tries to recompile.
May 11 2011
parent reply bearophile <bearophileHUGS lycos.com> writes:
Timon Gehr:

 I do not think this should be a compiler feature. It sounds like a task more
 suitable for a source code analyzer.
The compiler already has the information.
 Apart from that, if you need that functionality, you can easily write a small
 script that comments out all imports in turn and tries to recompile.
This is a way to waste lot of time, especially in larger programs. You want something better. Bye, bearophile
May 11 2011
next sibling parent reply Timon Gehr <timon.gehr gmx.ch> writes:
 Timon Gehr:

 I do not think this should be a compiler feature. It sounds like a task more
 suitable for a source code analyzer.
The compiler already has the information.
The compiler has the symbol tables. Everything beyond that is additional computation. (arguably not too complex) Another concern is, that if it is not optional, it will just nag you all the time. I agree that having some means of finding dead imports would be a nice thing. But only with the -w switch enabled. But I also think it is more important that the compiler improves on compiling D code. I'd like to hear some of Walter's arguments on the matter.
 Apart from that, if you need that functionality, you can easily write a small
 script that comments out all imports in turn and tries to recompile.
This is a way to waste lot of time, especially in larger programs. You want
something better. I agree.
 Bye,
 bearophile
Timon
May 11 2011
parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 5/11/2011 3:52 PM, Timon Gehr wrote:
 I'd like to hear some of Walter's arguments on the matter.
Because such an error would be highly annoying when: 1. you're using version/debug/staticif conditional compilation 2. you're commenting out code when trying different things or searching for a bug 3. you're using the "import all;" idiom Annoying programmers doesn't make them feel good about using D. D also has very solid protection against problems caused by importing multiple modules with conflicting names. This means that the likelihood of actual bugs being caused by unused imports is pretty much nil.
May 11 2011
parent reply Jonathan M Davis <jmdavisProg gmx.com> writes:
On 2011-05-11 16:32, Walter Bright wrote:
 On 5/11/2011 3:52 PM, Timon Gehr wrote:
 I'd like to hear some of Walter's arguments on the matter.
Because such an error would be highly annoying when: 1. you're using version/debug/staticif conditional compilation 2. you're commenting out code when trying different things or searching for a bug 3. you're using the "import all;" idiom Annoying programmers doesn't make them feel good about using D. D also has very solid protection against problems caused by importing multiple modules with conflicting names. This means that the likelihood of actual bugs being caused by unused imports is pretty much nil.
Out of curiosity, do you have any idea what kind of impact it has on compilation performance to import unused modules? - Jonathan M Davis
May 11 2011
parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 5/11/2011 5:16 PM, Jonathan M Davis wrote:
 Out of curiosity, do you have any idea what kind of impact it has on
 compilation performance to import unused modules?
That of course is highly dependent on the contents of those modules, and what they correspondingly import.
May 11 2011
parent Jonathan M Davis <jmdavisProg gmx.com> writes:
On 2011-05-11 17:48, Walter Bright wrote:
 On 5/11/2011 5:16 PM, Jonathan M Davis wrote:
 Out of curiosity, do you have any idea what kind of impact it has on
 compilation performance to import unused modules?
That of course is highly dependent on the contents of those modules, and what they correspondingly import.
I figured as much. It's just that if it's known to be generally expensive, then that would increase the insentive to remove unnecessary imports. Otherwise, I would tend to favor something closer to just importing everything and not worrying about it. But it is quite common in Java to import only exactly what you use, though I think that that's at least partially to avoid symbol clashes, and D doesn't work quite the same way in that regard. - Jonathan M Davis
May 11 2011
prev sibling parent Matthew Ong <ongbp yahoo.com> writes:
Hi Tom,

 Apart from that, if you need that functionality, you can easily write a small
 script that comments out all imports in turn and tries to recompile.
This is a way to waste lot of time, especially in larger programs. You >want
something better. I agrees with bearophile entirely, the approaches that is done in Java IDE (NetBeans) and development process does allow us remove the need to care too much about import java.util.*; // Better because the compiler handles it for the developer. or import java.util.LinkedList; import java.util.ArrayList; // Not being used here within this java file. IDE does highlight it.
May 12 2011
prev sibling next sibling parent reply Matthew Ong <ongbp yahoo.com> writes:
Hi Walter,

Thanks very much for the person reply to:
http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D&artnum=135959


Not sure what you mean by more complex than Java. The order of imports >in D is
not important. If I separated a single module into multiple different file, the compilation process seems to give me a lot of issue. I read from other reply and also within the dmd/src directory, D seems to only allow one interfaces are centralized within a single file. That might give issue to IDE and other tool developers to write code generator, refactoring? might be dead wrong. I tried to upload attachment, but it failed to be shown on the web site. Hence, I email them over. Just in case that too is lost. Here are the strange(to me) error. Sorry that seems to be rude. BTW, were you involved with turbo C development in dos days in the past. You seems to be old school. Matthew Ong ------------------------------------------------------------------------------------
 (4:50:21 PM) Compile D:\JDKs\D\devel\CornerCube\CornerCube\Exceptions.d
 (4:50:21 PM) dmd.exe -c "D:\JDKs\D\devel\CornerCube\CornerCube\Exceptions.d"
-of"D:\JDKs\D\devel\CornerCube\CornerCube\obj\Exceptions.obj" -I"D:\JDKs\D\dmd2\src\phobos" -I"D:\JDKs\D\dmd2\src\druntime\import" -gc -debug
 (4:50:21 PM) Process ended with code 0
 (4:50:21 PM) Compile D:\JDKs\D\devel\CornerCube\CornerCube\Collections.d
 (4:50:21 PM) dmd.exe -c "D:\JDKs\D\devel\CornerCube\CornerCube\Collections.d"
-of"D:\JDKs\D\devel\CornerCube\CornerCube\obj\Collections.obj" -I"D:\JDKs\D\dmd2\src\phobos" -I"D:\JDKs\D\dmd2\src\druntime\import" -gc -debug
 (4:50:22 PM) Process ended with code 0
 (4:50:22 PM) Compile D:\JDKs\D\devel\CornerCube\CornerCube\IO.d
 (4:50:22 PM) dmd.exe -c "D:\JDKs\D\devel\CornerCube\CornerCube\IO.d"
-of"D:\JDKs\D\devel\CornerCube\CornerCube\obj\IO.obj" -I"D:\JDKs\D\dmd2\src\phobos" -I"D:\JDKs\D\dmd2\src\druntime\import" -gc -debug
 (4:50:22 PM) Process ended with code 0
 (4:50:22 PM) Compile D:\JDKs\D\devel\CornerCube\CornerCube\Lang.d
 (4:50:22 PM) dmd.exe -c "D:\JDKs\D\devel\CornerCube\CornerCube\Lang.d"
-of"D:\JDKs\D\devel\CornerCube\CornerCube\obj\Lang.obj" -I"D:\JDKs\D\dmd2\src\phobos" -I"D:\JDKs\D\dmd2\src\druntime\import" -gc -debug
 (4:50:22 PM) Process ended with code 0
 (4:50:22 PM) Compile D:\JDKs\D\devel\CornerCube\CornerCube\Interfaces.d
 (4:50:22 PM) dmd.exe -c "D:\JDKs\D\devel\CornerCube\CornerCube\Interfaces.d"
-of"D:\JDKs\D\devel\CornerCube\CornerCube\obj\Interfaces.obj" -I"D:\JDKs\D\dmd2\src\phobos" -I"D:\JDKs\D\dmd2\src\druntime\import" -gc -debug
 (4:50:22 PM) Process ended with code 0
 (4:50:22 PM) Link files to
D:\JDKs\D\devel\CornerCube\CornerCube\bin\CornerCube.exe
 (4:50:22 PM) dmd.exe "obj\Exceptions.obj" "obj\Collections.obj" "obj\IO.obj"
"obj\Lang.obj" "obj\Interfaces.obj" -of"D:\JDKs\D\devel\CornerCube\CornerCube\bin\CornerCube.exe" -gc -debug
 (4:50:23 PM) Process ended with code 31
OPTLINK (R) for Win32 Release 8.00.8 Copyright (C) Digital Mars 1989-2010 All rights reserved. http://www.digitalmars.com/ctg/optlink.html OPTLINK : Warning 23: No Stack obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D18TypeInfo_Interface6__vtblZ obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D6object9Exception6__ctorMFAyaAyakC6object9ThrowableZC9Exception obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D9invariant12_d_invariantFC6ObjectZv obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D3std6string6formatFYAya obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined __d_throwc obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined __d_newclass obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined __d_dynamic_cast obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D15TypeInfo_Struct6__vtblZ obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D14TypeInfo_Tuple6__vtblZ obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D3std5stdio12__ModuleInfoZ obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D3std6string12__ModuleInfoZ obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D10TypeInfo_k6__initZ obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D12TypeInfo_Aya6__initZ obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D6object6Object8opEqualsMFC6ObjectC6ObjectZb obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D6object6Object8opEqualsMFC6ObjectZb obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D6object6Object5opCmpMFC6ObjectZi obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D6object6Object6toHashMFZk obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D6object9Throwable8toStringMFZAya obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D14TypeInfo_Class6__vtblZ obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D9Exception7__ClassZ obj\Collections.obj(Collections) Error 42: Symbol Undefined _D6Object7__ClassZ obj\Collections.obj(Collections) Error 42: Symbol Undefined _D6object6Object8toStringMFZAya obj\IO.obj(IO) Error 42: Symbol Undefined __d_array_bounds obj\IO.obj(IO) Error 42: Symbol Undefined __fltused obj\IO.obj(IO) Error 42: Symbol Undefined _D11TypeInfo_Aa6__initZ obj\IO.obj(IO) Error 42: Symbol Undefined __d_arrayliteralT obj\IO.obj(IO) Error 42: Symbol Undefined _D11TypeInfo_Au6__initZ obj\IO.obj(IO) Error 42: Symbol Undefined _D3std6stream12__ModuleInfoZ obj\IO.obj(IO) Error 42: Symbol Undefined _D3std6stream11InputStream11__InterfaceZ obj\IO.obj(IO) Error 42: Symbol Undefined _D3std6stream12OutputStream11__InterfaceZ obj\Interfaces.obj(Interfaces) Error 42: Symbol Undefined _D3std9container12__ModuleInfoZ OPTLINK : Warning 134: No Start Address --- errorlevel 31
May 12 2011
next sibling parent reply Mafi <mafi example.org> writes:
Am 12.05.2011 12:52, schrieb Matthew Ong:
 Hi Walter,

 Thanks very much for the person reply to:
 http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D&artnum=135959


 Not sure what you mean by more complex than Java. The order of imports>in D is
not important. If I separated a single module into multiple different file, the compilation process seems to give me a lot of issue. I read from other reply and also within the dmd/src directory, D seems to only allow one interfaces are centralized within a single file. That might give issue to IDE and other tool developers to write code generator, refactoring? might be dead wrong. I tried to upload attachment, but it failed to be shown on the web site. Hence, I email them over. Just in case that too is lost. Here are the strange(to me) error. Sorry that seems to be rude. BTW, were you involved with turbo C development in dos days in the past. You seems to be old school. Matthew Ong ------------------------------------------------------------------------------------
 (4:50:21 PM) Compile D:\JDKs\D\devel\CornerCube\CornerCube\Exceptions.d
 (4:50:21 PM) dmd.exe -c "D:\JDKs\D\devel\CornerCube\CornerCube\Exceptions.d"
-of"D:\JDKs\D\devel\CornerCube\CornerCube\obj\Exceptions.obj" -I"D:\JDKs\D\dmd2\src\phobos" -I"D:\JDKs\D\dmd2\src\druntime\import" -gc -debug
 (4:50:21 PM) Process ended with code 0
 (4:50:21 PM) Compile D:\JDKs\D\devel\CornerCube\CornerCube\Collections.d
 (4:50:21 PM) dmd.exe -c "D:\JDKs\D\devel\CornerCube\CornerCube\Collections.d"
-of"D:\JDKs\D\devel\CornerCube\CornerCube\obj\Collections.obj" -I"D:\JDKs\D\dmd2\src\phobos" -I"D:\JDKs\D\dmd2\src\druntime\import" -gc -debug
 (4:50:22 PM) Process ended with code 0
 (4:50:22 PM) Compile D:\JDKs\D\devel\CornerCube\CornerCube\IO.d
 (4:50:22 PM) dmd.exe -c "D:\JDKs\D\devel\CornerCube\CornerCube\IO.d"
-of"D:\JDKs\D\devel\CornerCube\CornerCube\obj\IO.obj" -I"D:\JDKs\D\dmd2\src\phobos" -I"D:\JDKs\D\dmd2\src\druntime\import" -gc -debug
 (4:50:22 PM) Process ended with code 0
 (4:50:22 PM) Compile D:\JDKs\D\devel\CornerCube\CornerCube\Lang.d
 (4:50:22 PM) dmd.exe -c "D:\JDKs\D\devel\CornerCube\CornerCube\Lang.d"
-of"D:\JDKs\D\devel\CornerCube\CornerCube\obj\Lang.obj" -I"D:\JDKs\D\dmd2\src\phobos" -I"D:\JDKs\D\dmd2\src\druntime\import" -gc -debug
 (4:50:22 PM) Process ended with code 0
 (4:50:22 PM) Compile D:\JDKs\D\devel\CornerCube\CornerCube\Interfaces.d
 (4:50:22 PM) dmd.exe -c "D:\JDKs\D\devel\CornerCube\CornerCube\Interfaces.d"
-of"D:\JDKs\D\devel\CornerCube\CornerCube\obj\Interfaces.obj" -I"D:\JDKs\D\dmd2\src\phobos" -I"D:\JDKs\D\dmd2\src\druntime\import" -gc -debug
 (4:50:22 PM) Process ended with code 0
 (4:50:22 PM) Link files to
D:\JDKs\D\devel\CornerCube\CornerCube\bin\CornerCube.exe
 (4:50:22 PM) dmd.exe "obj\Exceptions.obj" "obj\Collections.obj" "obj\IO.obj"
"obj\Lang.obj" "obj\Interfaces.obj" -of"D:\JDKs\D\devel\CornerCube\CornerCube\bin\CornerCube.exe" -gc -debug
 (4:50:23 PM) Process ended with code 31
OPTLINK (R) for Win32 Release 8.00.8
......
   Error 42: Symbol Undefined _D3std9container12__ModuleInfoZ
 OPTLINK : Warning 134: No Start Address
 --- errorlevel 31
Look at the last error. It means you have no main(){} and there can't be an .exe without a main. Maybe you wanted to link them without making an executable. Then you need to pass the '-lib' switch. Mafi
May 12 2011
parent reply Matthew Ong <ongbp yahoo.com> writes:
Hi Mafi,

Thanks again.

-of"D:\JDKs\D\devel\CornerCube\CornerCube\bin\CornerCube.exe"

Not too sure why this problem keep hopping on within the D-IDE.
In my other post. Within the IDE properties,.. I choosen DLL and
DMD for version 2.


Because the web in news group. I will tries to use another client.

I will look into the Eclipse IDE plugin link u sent.

---------------------------------------------------------------------
 (10:43:30 PM) Compile D:\JDKs\D\devel\CornerCube\CornerCube\Exceptions.d
 (10:43:30 PM) dmd.exe -c "D:\JDKs\D\devel\CornerCube\CornerCube\Exceptions.d"
-of"D:\JDKs\D\devel\CornerCube\CornerCube\obj\Exceptions.obj" -I"D:\JDKs\D\dmd2\src\phobos" -I"D:\JDKs\D\dmd2\src\druntime\import" -gc -debug
 (10:43:30 PM) Process ended with code 0
 (10:43:30 PM) Compile D:\JDKs\D\devel\CornerCube\CornerCube\Collections.d
 (10:43:30 PM) dmd.exe -c "D:\JDKs\D\devel\CornerCube\CornerCube\Collections.d"
-of"D:\JDKs\D\devel\CornerCube\CornerCube\obj\Collections.obj" -I"D:\JDKs\D\dmd2\src\phobos" -I"D:\JDKs\D\dmd2\src\druntime\import" -gc -debug
 (10:43:31 PM) Process ended with code 0
 (10:43:31 PM) Compile D:\JDKs\D\devel\CornerCube\CornerCube\IO.d
 (10:43:31 PM) dmd.exe -c "D:\JDKs\D\devel\CornerCube\CornerCube\IO.d"
-of"D:\JDKs\D\devel\CornerCube\CornerCube\obj\IO.obj" -I"D:\JDKs\D\dmd2\src\phobos" -I"D:\JDKs\D\dmd2\src\druntime\import" -gc -debug
 (10:43:31 PM) Process ended with code 0
 (10:43:31 PM) Compile D:\JDKs\D\devel\CornerCube\CornerCube\Lang.d
 (10:43:31 PM) dmd.exe -c "D:\JDKs\D\devel\CornerCube\CornerCube\Lang.d"
-of"D:\JDKs\D\devel\CornerCube\CornerCube\obj\Lang.obj" -I"D:\JDKs\D\dmd2\src\phobos" -I"D:\JDKs\D\dmd2\src\druntime\import" -gc -debug
 (10:43:31 PM) Process ended with code 0
 (10:43:31 PM) Compile D:\JDKs\D\devel\CornerCube\CornerCube\Interfaces.d
 (10:43:31 PM) dmd.exe -c "D:\JDKs\D\devel\CornerCube\CornerCube\Interfaces.d"
-of"D:\JDKs\D\devel\CornerCube\CornerCube\obj\Interfaces.obj" -I"D:\JDKs\D\dmd2\src\phobos" -I"D:\JDKs\D\dmd2\src\druntime\import" -gc -debug
 (10:43:31 PM) Process ended with code 0
 (10:43:31 PM) Link files to
D:\JDKs\D\devel\CornerCube\CornerCube\bin\CornerCube.exe
 (10:43:31 PM) dmd.exe "obj\Exceptions.obj" "obj\Collections.obj" "obj\IO.obj"
"obj\Lang.obj" "obj\Interfaces.obj" -L/IMPLIB:"D:\JDKs\D\devel\CornerCube\CornerCube\bin\CornerCube.lib" -of"D:\JDKs\D\devel\CornerCube\CornerCube\bin\CornerCube.dll" -gc -debug
 (10:43:32 PM) Process ended with code 31
OPTLINK (R) for Win32 Release 8.00.8 Copyright (C) Digital Mars 1989-2010 All rights reserved. http://www.digitalmars.com/ctg/optlink.html obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D18TypeInfo_Interface6__vtblZ obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D6object9Exception6__ctorMFAyaAyakC6object9ThrowableZC9Exception obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D9invariant12_d_invariantFC6ObjectZv obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D3std6string6formatFYAya obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined __d_throwc obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined __d_newclass obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined __d_dynamic_cast obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D15TypeInfo_Struct6__vtblZ obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D14TypeInfo_Tuple6__vtblZ obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D3std5stdio12__ModuleInfoZ obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D3std6string12__ModuleInfoZ obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D10TypeInfo_k6__initZ obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D12TypeInfo_Aya6__initZ obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D6object6Object8opEqualsMFC6ObjectC6ObjectZb obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D6object6Object8opEqualsMFC6ObjectZb obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D6object6Object5opCmpMFC6ObjectZi obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D6object6Object6toHashMFZk obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D6object9Throwable8toStringMFZAya obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D14TypeInfo_Class6__vtblZ obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D9Exception7__ClassZ obj\Collections.obj(Collections) Error 42: Symbol Undefined _D6Object7__ClassZ obj\Collections.obj(Collections) Error 42: Symbol Undefined _D6object6Object8toStringMFZAya obj\IO.obj(IO) Error 42: Symbol Undefined __d_array_bounds obj\IO.obj(IO) Error 42: Symbol Undefined __fltused obj\IO.obj(IO) Error 42: Symbol Undefined _D11TypeInfo_Aa6__initZ obj\IO.obj(IO) Error 42: Symbol Undefined __d_arrayliteralT obj\IO.obj(IO) Error 42: Symbol Undefined _D11TypeInfo_Au6__initZ obj\IO.obj(IO) Error 42: Symbol Undefined _D3std6stream12__ModuleInfoZ obj\IO.obj(IO) Error 42: Symbol Undefined _D3std6stream11InputStream11__InterfaceZ obj\IO.obj(IO) Error 42: Symbol Undefined _D3std6stream12OutputStream11__InterfaceZ obj\Interfaces.obj(Interfaces) Error 42: Symbol Undefined _D3std9container12__ModuleInfoZ --- errorlevel 31
May 12 2011
parent reply Jesse Phillips <jessekphillips+D gmail.com> writes:
It looks like your build environment is wrong. The linker doesn't know where to
find Phobos and Druntime. I wouldn't expect a simple hello world program to
compile with this.

Matthew Ong Wrote:

 Hi Mafi,
 
 Thanks again.
 
 -of"D:\JDKs\D\devel\CornerCube\CornerCube\bin\CornerCube.exe"
 
 Not too sure why this problem keep hopping on within the D-IDE.
 In my other post. Within the IDE properties,.. I choosen DLL and
 DMD for version 2.
 
 
 Because the web in news group. I will tries to use another client.
 
 I will look into the Eclipse IDE plugin link u sent.
 
 ---------------------------------------------------------------------
 (10:43:30 PM) Compile D:\JDKs\D\devel\CornerCube\CornerCube\Exceptions.d
 (10:43:30 PM) dmd.exe -c "D:\JDKs\D\devel\CornerCube\CornerCube\Exceptions.d"
-of"D:\JDKs\D\devel\CornerCube\CornerCube\obj\Exceptions.obj" -I"D:\JDKs\D\dmd2\src\phobos" -I"D:\JDKs\D\dmd2\src\druntime\import" -gc -debug
 (10:43:30 PM) Process ended with code 0
 (10:43:30 PM) Compile D:\JDKs\D\devel\CornerCube\CornerCube\Collections.d
 (10:43:30 PM) dmd.exe -c "D:\JDKs\D\devel\CornerCube\CornerCube\Collections.d"
-of"D:\JDKs\D\devel\CornerCube\CornerCube\obj\Collections.obj" -I"D:\JDKs\D\dmd2\src\phobos" -I"D:\JDKs\D\dmd2\src\druntime\import" -gc -debug
 (10:43:31 PM) Process ended with code 0
 (10:43:31 PM) Compile D:\JDKs\D\devel\CornerCube\CornerCube\IO.d
 (10:43:31 PM) dmd.exe -c "D:\JDKs\D\devel\CornerCube\CornerCube\IO.d"
-of"D:\JDKs\D\devel\CornerCube\CornerCube\obj\IO.obj" -I"D:\JDKs\D\dmd2\src\phobos" -I"D:\JDKs\D\dmd2\src\druntime\import" -gc -debug
 (10:43:31 PM) Process ended with code 0
 (10:43:31 PM) Compile D:\JDKs\D\devel\CornerCube\CornerCube\Lang.d
 (10:43:31 PM) dmd.exe -c "D:\JDKs\D\devel\CornerCube\CornerCube\Lang.d"
-of"D:\JDKs\D\devel\CornerCube\CornerCube\obj\Lang.obj" -I"D:\JDKs\D\dmd2\src\phobos" -I"D:\JDKs\D\dmd2\src\druntime\import" -gc -debug
 (10:43:31 PM) Process ended with code 0
 (10:43:31 PM) Compile D:\JDKs\D\devel\CornerCube\CornerCube\Interfaces.d
 (10:43:31 PM) dmd.exe -c "D:\JDKs\D\devel\CornerCube\CornerCube\Interfaces.d"
-of"D:\JDKs\D\devel\CornerCube\CornerCube\obj\Interfaces.obj" -I"D:\JDKs\D\dmd2\src\phobos" -I"D:\JDKs\D\dmd2\src\druntime\import" -gc -debug
 (10:43:31 PM) Process ended with code 0
 (10:43:31 PM) Link files to
D:\JDKs\D\devel\CornerCube\CornerCube\bin\CornerCube.exe
 (10:43:31 PM) dmd.exe "obj\Exceptions.obj" "obj\Collections.obj" "obj\IO.obj"
"obj\Lang.obj" "obj\Interfaces.obj" -L/IMPLIB:"D:\JDKs\D\devel\CornerCube\CornerCube\bin\CornerCube.lib" -of"D:\JDKs\D\devel\CornerCube\CornerCube\bin\CornerCube.dll" -gc -debug
 (10:43:32 PM) Process ended with code 31
OPTLINK (R) for Win32 Release 8.00.8 Copyright (C) Digital Mars 1989-2010 All rights reserved. http://www.digitalmars.com/ctg/optlink.html obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D18TypeInfo_Interface6__vtblZ obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D6object9Exception6__ctorMFAyaAyakC6object9ThrowableZC9Exception obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D9invariant12_d_invariantFC6ObjectZv obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D3std6string6formatFYAya obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined __d_throwc obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined __d_newclass obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined __d_dynamic_cast obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D15TypeInfo_Struct6__vtblZ obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D14TypeInfo_Tuple6__vtblZ obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D3std5stdio12__ModuleInfoZ obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D3std6string12__ModuleInfoZ obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D10TypeInfo_k6__initZ obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D12TypeInfo_Aya6__initZ obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D6object6Object8opEqualsMFC6ObjectC6ObjectZb obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D6object6Object8opEqualsMFC6ObjectZb obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D6object6Object5opCmpMFC6ObjectZi obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D6object6Object6toHashMFZk obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D6object9Throwable8toStringMFZAya obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D14TypeInfo_Class6__vtblZ obj\Exceptions.obj(Exceptions) Error 42: Symbol Undefined _D9Exception7__ClassZ obj\Collections.obj(Collections) Error 42: Symbol Undefined _D6Object7__ClassZ obj\Collections.obj(Collections) Error 42: Symbol Undefined _D6object6Object8toStringMFZAya obj\IO.obj(IO) Error 42: Symbol Undefined __d_array_bounds obj\IO.obj(IO) Error 42: Symbol Undefined __fltused obj\IO.obj(IO) Error 42: Symbol Undefined _D11TypeInfo_Aa6__initZ obj\IO.obj(IO) Error 42: Symbol Undefined __d_arrayliteralT obj\IO.obj(IO) Error 42: Symbol Undefined _D11TypeInfo_Au6__initZ obj\IO.obj(IO) Error 42: Symbol Undefined _D3std6stream12__ModuleInfoZ obj\IO.obj(IO) Error 42: Symbol Undefined _D3std6stream11InputStream11__InterfaceZ obj\IO.obj(IO) Error 42: Symbol Undefined _D3std6stream12OutputStream11__InterfaceZ obj\Interfaces.obj(Interfaces) Error 42: Symbol Undefined _D3std9container12__ModuleInfoZ --- errorlevel 31
May 12 2011
parent reply Matthew Ong <ongbp yahoo.com> writes:
Hi All that help and provided good working instructions,

The ugly build trail is due to the D-IDE setting problem in windows
vista. The eclipse version that Mafi shown is working fine now and
able to allow me to specify -lib option.

The importing issue is due to the manner that D can only allow single
file for single module. :( (Moving from Java) multiple file per
package(module) is allowed and easy for handling large projects.
May 15 2011
parent Jonathan M Davis <jmdavisProg gmx.com> writes:
On 2011-05-15 08:13, Matthew Ong wrote:
 Hi All that help and provided good working instructions,
 
 The ugly build trail is due to the D-IDE setting problem in windows
 vista. The eclipse version that Mafi shown is working fine now and
 able to allow me to specify -lib option.
 
 The importing issue is due to the manner that D can only allow single
 file for single module. :( (Moving from Java) multiple file per
 package(module) is allowed and easy for handling large projects.
A package and a module are completely different. D has packages _exactly_ like Java does, and they both do them the same. All of the modules in a folder are part of the same package. Java also does only one module per file. The difference is that Java enforces that every public class be in its own module. So, you end up with a situation where every module represents a public class - so much so that a compiled module in Java results in a .class file. Now, Java doesn't use the term module, but the way their package system is very similar to D - including packages - except that they are far more restrictive about what goes in an individual module / source file. The result is a proliferation of modules / source files. Thinking of a Java package and a D module as the same thing is going to get you into trouble if you ever have to do anything with package-level access. A Java package is essentially a D package, and a Java source file is essentially a D source file / module. It's just that Java has greater restrictions on what goes in a source file, forcing you to create a lot of them. So, porting Java code to D either means that you either have a lot of extraneous modules with a single class in each, or you merge source files to reduce the number of files / modules that you have. - Jonathan M Davis
May 15 2011
prev sibling parent Walter Bright <newshound2 digitalmars.com> writes:
On 5/12/2011 3:52 AM, Matthew Ong wrote:
 BTW, were you involved with turbo C development in dos days in the past. You
seems
 to be old school.
No. See the products I worked on: http://www.walterbright.com
May 12 2011
prev sibling parent reply Matthew Ong <ongbp yahoo.com> writes:
On 5/12/2011 2:23 AM, Walter Bright wrote:
Hi Walter,
 Not sure what you mean by more complex than Java. The order of imports
 in D is not important.
Hmm... Someone more experience in Java and also D might want to update this URL and help some new Java To D developer to figure out the import subtle differences http://prowiki.org/wiki4d/wiki.cgi?JavaToD
 But it is quite common in Java to import >only
exactly what you use, though I think that that's at least partially to 
avoid
symbol clashes, and D doesn't work quite the same way in that regard.
Yes. I agrees with Jonathan. Please take a look at these 2 blocks bellow. In Java, import java.util.*; // for LinkedList / HashMap import java.sql.*; // for JDBC API class MyTable{ void read(){ ... // Obtain ResultSet Date date=rs.getDate(1); // this line will always cause compilation error because both java.util & java.sql package has Date class. } void readFixed(){ ... // Obtain ResultSet java.util.Date date=rs.getDate(1); // this will fixed the compilation error while still keep both the imports. } } http://www.digitalmars.com/d/2.0/module.html module A; void foo(); void bar(); ------------------------ module B; void foo(); void bar(); ------------------------ module C; import A; void foo(); // .... Due to the fact that there is only one D source file per module, and from what I can see, there are normally many functions/classes/others... in between here. The user of that function might have forgotten about the foo defined above. void test() { // the line below is really >dangerous< and might have been missed out because it is NOT flagged. Such things are always flag within Java and also google Go and maybe c/c++. Hopefully this will be flag as compilation erro to others kind of syntax. foo(); // C.foo() is called, it is found before imports are searched bar(); // A.bar() is called, since imports are searched } -- Matthew Ong email: ongbp yahoo.com
May 16 2011
parent bearophile <bearophileHUGS lycos.com> writes:
Matthew Ong:

    // the line below is really >dangerous< and might have been missed 
 out because it is NOT flagged. Such things are always flag within Java 
 and also google Go and maybe c/c++. Hopefully this will be flag as 
 compilation erro to others kind of syntax.
    foo(); // C.foo() is called, it is found before imports are searched
    bar(); // A.bar() is called, since imports are searched
It's almost four years that I yell against this shit. But they like this. The design of D module system is broken still (and its implementation is even worse). Bye, bearophile
May 16 2011
prev sibling next sibling parent bearophile <bearophileHUGS lycos.com> writes:
Matthew Ong:

 4) Is there also a Code formatting tool like:
    gofmt Gofmt formats Go programs. // That save me a lot to time.
    The Netbeans and eclipse has this build in feature.
I think no one has written this little tool for Phobos. On the other hand, so far D community seems to value some wrong forms of freedom, like formatting freedom, common in C/C++. Bye, bearophile
May 11 2011
prev sibling parent reply Jesse Phililps <jessekphillips+D gmail.com> writes:
Your points have been covered by others, but in general they are a little
confusing. You're making statements about things that just aren't true or
shouldn't be true for D. I'm going to request you try and elaborate what you
mean. And recap some information.

Matthew Ong Wrote:

...
 I also downloaded the http://d-ide.sourceforge.net/.
 This IDE is small foot print and tries to be like visual studio.
 Why not someone in D consider porting this to a more mature IDE like:
 
 SharpDevelop
 http://sharpdevelop.net/OpenSource/SD/Default.aspx
 Or
 NetBeans or Eclipse
 Instead of re-inventing the wheel?
Writing something from scratch is a lot of fun and can be easier, especially when you think everyone else is doing it wrong. There are integration projects for Eclipse and Visual Studio too.
 2) D Supports Interface and Class inheritance. (Nice!!)
    However I seems to have problem to model something like this in D:
...
    I tried:
    class MyException : Exception, SomeInterface{ // << That cause
 compilation error. Why??? How to work around or solution?
    }
 
This should work with the exception that you will have to implement the interface functions. What compiler error are you getting? ...
 4) Is there also a Code formatting tool like:
    gofmt Gofmt formats Go programs. // That save me a lot to time.
    The Netbeans and eclipse has this build in feature.
Nope. D is very close to C so you can probably use ident, it has enough options it should be able to do whatever you want it to. http://linux.die.net/man/1/indent
 5) import std.stdio; // The imports seems to be more complex to use
 than java's import. There should be a tool to help resolved this and
 also makes the order of importing of not important like in java.
What do you mean order matters? On the compilation side of things D is more complicated in that dmd must be told where ever file being compiled is located and won't go looking for it. rdmd however does come with dmd and will do this search for you.
 6) Is there some build in source code checking command like:
  govet
 http://golang.org/cmd/
Nope.
 
 7) How about unit test, is there a library like junit or cppunit
    is there something similar that can allow code to be profile,
 tested and validated?
As others/Walter mentioned. unttest blocks are part of the language, along with contracts. dmd has profile and coverage switches.
 May I also ask, does the compiler and linker highlight the unused
 import to the user so that they can be removed from source code.
No. Though the linker should not compile unused code into the executable. A common view is this should be handled by your IDE.
 The have experienced with C++ and C since back in the turbo c dos day
 and Java. D seems to be promising. Overall nice and good. But can be
 improved more to simplified coding cycle.
D needs much better tool support, especially for the Application developers. But in some places it is just different.
May 11 2011
parent reply Matthew Ong <ongbp yahoo.com> writes:
 Jesse Phililps,

Your points have been covered by others, but in general they are a little
confusing. You're making >statements about things that just aren't true or shouldn't be true for D.
I'm going to request you try and elaborate what you mean. And recap some
information.
That might be for some of the cases. Yes. This thread deserved to have some point cleared. The post may have mix up the task of the ide and sdk tool/compiler tool. What I am looking at is the entire development process of a developer day by day. Library importing/creation, formatting code, documenting, Re-factoring, Resource+memory+...etc I did specified in my first post I narrowed down into D/Go compare to pure java or pure C/C++.
Writing something from scratch is a lot of fun and can be easier,
especially when you think everyone else is doing it wrong.
 No. Though the linker should not compile unused code into the executable.
 A common view is this should be handled by your IDE.
Yes. I agrees for some portion of that. I am also faced with recursive importing error with either compiler or linker phase of the dmd process. Some how the web newsgroup interface does not allow me to attached images either that or the site update is slow.
May 12 2011
parent Matthew Ong <ongbp yahoo.com> writes:
!!!! AH!!!! The past few post that I updated with png file is not shown.
I suspected the web news group is not working that smooth.
May 12 2011