www.digitalmars.com         C & C++   DMDScript  

D - D Questions

reply "Andres Rodriguez" <rodriguez ai.sri.com> writes:
I am a java guy trying to understand D, and I have a couple
of questions/comments:

1) Why keep pointers around?  Doesn't the combination of
lightweight (stack) objects and heap objects accounts for
everything you might want to do with pointers?  Is it to be
able to call C functions?

2) I think the C syntax for function pointers is one of the ugliest
things that ome from C.  Why allow that syntax for function
delegates?

3) What is this .map file I get after compiling something?

4) A nice thing about java is that it allows me to refer to files
using a forward slash (/) instead of a backward slash (/).  This
way my makefiles are completely unchanged from Windows to
Unix (without using an ugly variable to separate directories).
Is this something that is planned for D?

5) I read something about SWT being ported over.  I ported
SWT to use AWT for my company, and would be interested
in contributing.

Cheers,

Andres
Jan 31 2004
next sibling parent reply "Matthew" <matthew.hat stlsoft.dot.org> writes:
 I am a java guy trying to understand D, and I have a couple
 of questions/comments:

 1) Why keep pointers around?  Doesn't the combination of
 lightweight (stack) objects and heap objects accounts for
 everything you might want to do with pointers?  Is it to be
 able to call C functions?

 2) I think the C syntax for function pointers is one of the ugliest
 things that ome from C.  Why allow that syntax for function
 delegates?

The answer to both these questions is that pointers are a very powerful and efficient mechanism, and is one of the reasons that C and C++ remain the foremost general purpose languages, despite having been around for 30 and 20 years, respectively. The whole idea is that experienced people should have access to whatever level of power they need. This is the Spirit of C (http://www.comeaucomputing.com/faqs/genfaq.html#betterCgeneral) You can have languages, and, with respect, pretty poor ones at that, such as Java, if you're prepared to constrain the programmer in significant ways. This can lead to all kinds of problems, such as bloat, lack of ability to express one's desires, lack of reuse, lack of robustness, but it most usually manifests itself, as it does with Java, in poor performance. Essentially software engineering is a craft, and the *only* way to do it well is to understand the principles, understand the tools (i.e. the language(s) you are using), and to have experience. D facilitates this, as does C++, by providing access to the lowest as well as the highest levels of abstraction. Languages such as Java and .NET tend to limit themselves to, say, the 50-75% level of abstraction.
 3) What is this .map file I get after compiling something?

That's a file describing the symbols contained in your executable file.
 4) A nice thing about java is that it allows me to refer to files
 using a forward slash (/) instead of a backward slash (/).  This
 way my makefiles are completely unchanged from Windows to
 Unix (without using an ugly variable to separate directories).
 Is this something that is planned for D?

The / vs \ is entirely an artifact of the operating system, and nothing to do with the D and Java languages. If you use Java on Win32, you will be manipulating paths with backslashes. Some languages/libraries do "compensate" for programmers/users passing the wrong type, for the operating system, to functions, but this behaviour is a deemed an extension, rather than a standard aspect of a given language. Cheers Matthew
Jan 31 2004
next sibling parent reply "Andres Rodriguez" <rodriguez ai.sri.com> writes:
See answers/more questions below.

 I am a java guy trying to understand D, and I have a couple
 of questions/comments:

 1) Why keep pointers around?  Doesn't the combination of
 lightweight (stack) objects and heap objects accounts for
 everything you might want to do with pointers?  Is it to be
 able to call C functions?

 2) I think the C syntax for function pointers is one of the ugliest
 things that ome from C.  Why allow that syntax for function
 delegates?

The answer to both these questions is that pointers are a very powerful

 efficient mechanism, and is one of the reasons that C and C++ remain the
 foremost general purpose languages, despite having been around for 30 and

 years, respectively.

 The whole idea is that experienced people should have access to whatever
 level of power they need. This is the Spirit of C
 (http://www.comeaucomputing.com/faqs/genfaq.html#betterCgeneral)

 You can have languages, and, with respect, pretty poor ones at that, such

 Java, if you're prepared to constrain the programmer in significant ways.
 This can lead to all kinds of problems, such as bloat, lack of ability to
 express one's desires, lack of reuse, lack of robustness, but it most
 usually manifests itself, as it does with Java, in poor performance.

 Essentially software engineering is a craft, and the *only* way to do it
 well is to understand the principles, understand the tools (i.e. the
 language(s) you are using), and to have experience.

 D facilitates this, as does C++, by providing access to the lowest as well
 as the highest levels of abstraction. Languages such as Java and .NET tend
 to limit themselves to, say, the 50-75% level of abstraction.

I completely agree with you in everything you sais, nevertheless you did not answer my question. When you explicitly have both stack and heap objects, heap objects basically serve as pointers with a nicer syntax. I coded in C++ for many years, using very few pointers, and my code was cleaner and more readable. I have nothing against a complete and general language, but the more ways you have to write something, the more harder a language is to read (I code in lisp for my work, and it takes me much longer to understand other people code, even if writing my own is a joy). Everything is a compromise and a language should have reasons for being whatever it is. Otherwise, following your line of thought (exaggerating a bit to make my point :-) just throw every possible feature at D, and you'll have your ideal language.
 4) A nice thing about java is that it allows me to refer to files
 using a forward slash (/) instead of a backward slash (/).  This
 way my makefiles are completely unchanged from Windows to
 Unix (without using an ugly variable to separate directories).
 Is this something that is planned for D?

The / vs \ is entirely an artifact of the operating system, and nothing to do with the D and Java languages. If you use Java on Win32, you will be manipulating paths with backslashes. Some languages/libraries do "compensate" for programmers/users passing the wrong type, for the operating system, to functions, but this behaviour is

 deemed an extension, rather than a standard aspect of a given language.

Again agreed, forgive my lack of precision. I rephrase my question: "Is the *extension* above planned? It's specifically useful for the compiler more tha the language itself. Cheers, Andres
Jan 31 2004
next sibling parent Andy Friesen <andy ikagames.com> writes:
Andres Rodriguez wrote:
 
 [..]   When you explicitly have both stack and heap
 objects, heap objects basically serve as pointers with a nicer syntax.  I
 coded in C++ for many years, using very few pointers, and my code was
 cleaner and more readable.

You can't do pointer arithmetic with references. Or convert them to ints, or other such sacrelige. :) D aims to provide a better way to do most everything C coders use pointers and the like for, but does nothing to prevent their use in the case that a programmer really can't do it any other way without excessive hackery or performance impact. -- andy
Jan 31 2004
prev sibling next sibling parent Juan C <Juan_member pathlink.com> writes:
 4) A nice thing about java is that it allows me to refer to files
 using a forward slash (/) instead of a backward slash (/).  This
 way my makefiles are completely unchanged from Windows to
 Unix (without using an ugly variable to separate directories).
 Is this something that is planned for D?

The / vs \ is entirely an artifact of the operating system, and nothing to do with the D and Java languages. If you use Java on Win32, you will be manipulating paths with backslashes. Some languages/libraries do "compensate" for programmers/users passing the wrong type, for the operating system, to functions, but this behaviour is

 deemed an extension, rather than a standard aspect of a given language.

Again agreed, forgive my lack of precision. I rephrase my question: "Is the *extension* above planned? It's specifically useful for the compiler more tha the language itself.

It seems to me that that would be better in some kind of front end that you provide for the OS you happen to use. If I compile the D compiler on VMS for others to use would you expect me to alter the code to allow non-VMS file specifications? That would be silly.
Jan 31 2004
prev sibling parent reply "Walter" <walter digitalmars.com> writes:
"Andres Rodriguez" <rodriguez ai.sri.com> wrote in message
news:bvhi7j$92v$1 digitaldaemon.com...
 I completely agree with you in everything you sais, nevertheless you did
 not answer my question.  When you explicitly have both stack and heap
 objects, heap objects basically serve as pointers with a nicer syntax.  I
 coded in C++ for many years, using very few pointers, and my code was
 cleaner and more readable.

Consider, for example, implementing a garbage collector. Without language support for pointers, a garbage collector could not be implemented in D. (And yes, ABI compatibility with C is also a reason for supporting pointers.)
 I have nothing against a complete and general language, but the more
 ways you have to write something, the more harder a language is to
 read (I code in lisp for my work, and it takes me much longer to

 other people code, even if writing my own is a joy).  Everything is
 a compromise and a language should have reasons for being
 whatever it is.  Otherwise, following your line of thought (exaggerating
 a bit to make my point :-) just throw every possible feature at D,
 and you'll have your ideal language.

You're right. And D has been criticized (ironically by some C++ experts) as being a grab bag of features, despite my having said no to a very long list of feature requests <g>. The trick is to decide which features to include and which to exclude, based on their cost in terms of language complexity versus their benefit in terms of simplifying things for the user.
 Again agreed, forgive my lack of precision.  I rephrase my question: "Is
 the *extension* above planned?  It's specifically useful for the compiler
 more tha the language itself.

I think it already does that.
Feb 01 2004
parent reply "Andres Rodriguez" <rodriguez ai.sri.com> writes:
 You're right. And D has been criticized (ironically by some C++ experts)

 being a grab bag of features, despite my having said no to a very long

 of feature requests <g>. The trick is to decide which features to include
 and which to exclude, based on their cost in terms of language complexity
 versus their benefit in terms of simplifying things for the user.

I actually disagree, I think you have achieved a lot, with an economy of syntax that is comendable. I am going to keep exploring the language but I hope to send you my comments at the end. I already have a long list of pros and cons, but overall I am amazed at the simplicity and power of D.
Feb 01 2004
parent "Walter" <walter digitalmars.com> writes:
"Andres Rodriguez" <rodriguez ai.sri.com> wrote in message
news:bvjvh2$1790$1 digitaldaemon.com...
 You're right. And D has been criticized (ironically by some C++ experts)

 being a grab bag of features, despite my having said no to a very long

 of feature requests <g>. The trick is to decide which features to


 and which to exclude, based on their cost in terms of language


 versus their benefit in terms of simplifying things for the user.

of syntax that is comendable. I am going to keep exploring the language but I hope to send you my comments at the end. I already have a long list of pros and cons, but overall I am amazed at the simplicity and power of D.

Thanks! And when you are ready, post the pros and cons here, and maybe even on your web site if you have one.
Feb 01 2004
prev sibling parent reply JanC <usenet_spam janc.invalid> writes:
"Matthew" <matthew.hat stlsoft.dot.org> schreef:

 The / vs \ is entirely an artifact of the operating system, and
 nothing to do with the D and Java languages. If you use Java on Win32,
 you will be manipulating paths with backslashes.

AFAIK DOS & Windows support both "\" and "/" at the API level; only at the command line you have to use "\". -- JanC "Be strict when sending and tolerant when receiving." RFC 1958 - Architectural Principles of the Internet - section 3.9
Jan 31 2004
parent reply "Matthew" <matthew.hat stlsoft.dot.org> writes:
"JanC" <usenet_spam janc.invalid> wrote in message
news:Xns94821A5C079E7JanC 213.119.4.35...
 "Matthew" <matthew.hat stlsoft.dot.org> schreef:

 The / vs \ is entirely an artifact of the operating system, and
 nothing to do with the D and Java languages. If you use Java on Win32,
 you will be manipulating paths with backslashes.

AFAIK DOS & Windows support both "\" and "/" at the API level; only at the command line you have to use "\".

I'd very surprised if this was the case. I'm pretty sure I've been bitten by this by several Win32 APIs. Haven't programmed to DOS for over five years, so I cannot comment on that.
 -- 
 JanC

 "Be strict when sending and tolerant when receiving."
 RFC 1958 - Architectural Principles of the Internet - section 3.9

Jan 31 2004
parent reply "C" <dont respond.com> writes:
Yea, you can get away with using / as a directory seperator in Win2K , but
not in Win98.  This is the only time ive run into this.

C

"Matthew" <matthew.hat stlsoft.dot.org> wrote in message
news:bvhq5t$omm$1 digitaldaemon.com...
 "JanC" <usenet_spam janc.invalid> wrote in message
 news:Xns94821A5C079E7JanC 213.119.4.35...
 "Matthew" <matthew.hat stlsoft.dot.org> schreef:

 The / vs \ is entirely an artifact of the operating system, and
 nothing to do with the D and Java languages. If you use Java on Win32,
 you will be manipulating paths with backslashes.

AFAIK DOS & Windows support both "\" and "/" at the API level; only at


 command line you have to use "\".

I'd very surprised if this was the case. I'm pretty sure I've been bitten

 this by several Win32 APIs.

 Haven't programmed to DOS for over five years, so I cannot comment on

 -- 
 JanC

 "Be strict when sending and tolerant when receiving."
 RFC 1958 - Architectural Principles of the Internet - section 3.9


Feb 01 2004
parent "Walter" <walter digitalmars.com> writes:
"C" <dont respond.com> wrote in message
news:bvjvuj$18ke$1 digitaldaemon.com...
 Yea, you can get away with using / as a directory seperator in Win2K , but
 not in Win98.  This is the only time ive run into this.

The trouble with using / as a separator in win32 is that sometimes it works, and sometimes it doesn't. It isn't always predictable when it won't work. I just bit the bullet and did different makefiles.
Feb 01 2004
prev sibling next sibling parent Cloud9 Virtual <cloud9virtual yahoo.com> writes:
Andres Rodriguez wrote:
 I am a java guy trying to understand D, and I have a couple
 of questions/comments:
 
 1) Why keep pointers around?  Doesn't the combination of
 lightweight (stack) objects and heap objects accounts for
 everything you might want to do with pointers?  Is it to be
 able to call C functions?
 

I think the shortest reasonable answer is that D is a systems language, like C and C++, and unlike Java. One could write an operating system in D, and access hardware directly from within the language. That requires pointers and asm statements, which D has both.
Jan 31 2004
prev sibling parent Mark T <Mark_member pathlink.com> writes:
In article <bvhffl$47n$1 digitaldaemon.com>, Andres Rodriguez says...
I am a java guy trying to understand D, 

5) I read something about SWT being ported over.  I ported
SWT to use AWT for my company, and would be interested
in contributing.

it appears that Brad Anderson <brad sankaty.dot.com> ( I think that email needs a human tweak) see: D/22162 for the start of the thread is kicking this off. An experienced Java guy would be a great asset. The D community is quite friendly and open. Welcome.
Feb 01 2004