www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: Signed word lengths and indexes

reply bearophile <bearophileHUGS lycos.com> writes:
Don:

Indeed, only a subset of D is useful for low-level development.<

A problem is that some of those D features (that are often useful in application code) are actively negative for that kind of development.
But D has more close-to-the-metal features than C does.<

I don't know if those extra D features are enough. And the C dialect used for example by Linux is not standard C, it uses many other tricks. I think D doesn't have some of them (I will try to answer this better to a Walter's post). A recent nice post by Linus linked here by Walter has partially answered a question I have asked here, that is what language features a kernel developer can enjoy that both C and C++ lack. That answer has shown that close-to-the-metal features are useful but they are not enough. I presume it's not even easy to express what those more important things are, Linus writes:
So I agree that describing the data is important, but at the same time, the
things that really need the most description are how the data hangs together,
what the consistency requirements are, what the locking rules are (and not for
a single data object either), etc etc. And my suspicion is that you can't
easily really describe those to a compiler. So you end up having to write that
code yourself regardless. And hey, maybe it's because I do just low-level
programming that I think so. As mentioned, most of the code I work with really
deeply cares about the kinds of things that most software projects probably
never even think about: stack depth, memory access ordering, fine-grained
locking, and direct hardware access.<

D gives few more ways to give complex semantics to the compiler, but probably other better languages need to be invented for this. I think it is possible to invent such languages, but maybe they will be hard to use (maybe as Coq http://en.wikipedia.org/wiki/Coq ), so they will be niche languages. Such niche can be so small that maybe the work to invent and implement and keep updated and debugged such language is not worth it. Bye, bearophile
Jun 15 2010
parent reply Walter Bright <newshound1 digitalmars.com> writes:
bearophile wrote:
 Don:
 
 Indeed, only a subset of D is useful for low-level development.<

A problem is that some of those D features (that are often useful in application code) are actively negative for that kind of development.
 But D has more close-to-the-metal features than C does.<

I don't know if those extra D features are enough.

Since it has more than C does, and C is used for kernel dev, then it must be enough.
 And the C dialect used for
 example by Linux is not standard C, it uses many other tricks. I think D
 doesn't have some of them (I will try to answer this better to a Walter's
 post).

I'll await your reply there.
 So I agree that describing the data is important, but at the same time, the
 things that really need the most description are how the data hangs
 together, what the consistency requirements are, what the locking rules are
 (and not for a single data object either), etc etc. And my suspicion is
 that you can't easily really describe those to a compiler. So you end up
 having to write that code yourself regardless. And hey, maybe it's because
 I do just low-level programming that I think so. As mentioned, most of the
 code I work with really deeply cares about the kinds of things that most
 software projects probably never even think about: stack depth, memory
 access ordering, fine-grained locking, and direct hardware access.<

D gives few more ways to give complex semantics to the compiler, but probably other better languages need to be invented for this. I think it is possible to invent such languages, but maybe they will be hard to use (maybe as Coq http://en.wikipedia.org/wiki/Coq ), so they will be niche languages. Such niche can be so small that maybe the work to invent and implement and keep updated and debugged such language is not worth it.

With all due respect to Linus, in 30 years of professionally writing software, I've found that if you solely base improvements on what customers ask for, all you have are incremental improvements. No quantum leaps, no paradigm shifts, no game changers. To get those, you have to look quite a bit beyond what the customer asks for. It also requires understanding that if a customer asks for feature X, it really means he is having problem Y, and there may be a far better solution to X than Y. One example of this is transitive immutability. Nobody asked for it. A lot of people question the need for it. I happen to believe that it offers a quantum improvement in the ability of a programmer to manage the complexity of a large program, which is why I (and Andrei) have invested so much effort in it, and are willing to endure flak over it. The payoff won't be clear for years, but I think it'll be large. Scope guard statements are another example. So are shared types.
Jun 15 2010
next sibling parent reply "Simen kjaeraas" <simen.kjaras gmail.com> writes:
Walter Bright <newshound1 digitalmars.com> wrote:
 bearophile wrote:
 Don:

 Indeed, only a subset of D is useful for low-level development.<

application code) are actively negative for that kind of development.
 But D has more close-to-the-metal features than C does.<


Since it has more than C does, and C is used for kernel dev, then it must be enough.

I believe the point of Linus (and probably bearophile) was not that C++ lacked features, but rather it lets programmers confuse one another by having features that are not as straight-forward as C. D also has these.
 One example of this is transitive immutability. Nobody asked for it. A  
 lot of people question the need for it. I happen to believe that it  
 offers a quantum improvement in the ability of a programmer to manage  
 the complexity of a large program, which is why I (and Andrei) have  
 invested so much effort in it, and are willing to endure flak over it.  
 The payoff won't be clear for years, but I think it'll be large.

I still have problems understanding how someone could come up with the idea of non-transitive const. I remember the reaction when I read about it being such a great thing on this newsgroup, and going "wtf? Why on earth would it not be transitive? That would be useless!" (yes, I was not a very experienced programmer). -- Simen
Jun 15 2010
parent Walter Bright <newshound1 digitalmars.com> writes:
Simen kjaeraas wrote:
 Walter Bright <newshound1 digitalmars.com> wrote:
 bearophile wrote:
 Don:

 Indeed, only a subset of D is useful for low-level development.<

application code) are actively negative for that kind of development.
 But D has more close-to-the-metal features than C does.<


Since it has more than C does, and C is used for kernel dev, then it must be enough.

I believe the point of Linus (and probably bearophile) was not that C++ lacked features, but rather it lets programmers confuse one another by having features that are not as straight-forward as C. D also has these.

To some extent, yes. My point was that C++ doesn't have a whole lot beyond that to offer, while D does.
 One example of this is transitive immutability. Nobody asked for it. A 
 lot of people question the need for it. I happen to believe that it 
 offers a quantum improvement in the ability of a programmer to manage 
 the complexity of a large program, which is why I (and Andrei) have 
 invested so much effort in it, and are willing to endure flak over it. 
 The payoff won't be clear for years, but I think it'll be large.

I still have problems understanding how someone could come up with the idea of non-transitive const. I remember the reaction when I read about it being such a great thing on this newsgroup, and going "wtf? Why on earth would it not be transitive? That would be useless!" (yes, I was not a very experienced programmer).

I don't think the non-transitive const is very useful either, and I think that C++ demonstrates that.
Jun 15 2010
prev sibling parent reply Jeff Nowakowski <jeff dilacero.org> writes:
On 06/15/2010 05:43 PM, Walter Bright wrote:
 One example of this is transitive immutability. Nobody asked for it.

I find this hard to believe. I seem to recall that you were personally against const for a very long time. Did none of the people advocating for const suggest a deep const? Should I dig through the archives?
Jun 16 2010
parent reply Walter Bright <newshound1 digitalmars.com> writes:
Jeff Nowakowski wrote:
 On 06/15/2010 05:43 PM, Walter Bright wrote:
 One example of this is transitive immutability. Nobody asked for it.

I find this hard to believe. I seem to recall that you were personally against const for a very long time. Did none of the people advocating for const suggest a deep const? Should I dig through the archives?

Andrei explained transitivity to me and convinced me of its utility.
Jun 16 2010
parent reply Jeff Nowakowski <jeff dilacero.org> writes:
On 06/16/2010 12:33 PM, Walter Bright wrote:
 Jeff Nowakowski wrote:
 On 06/15/2010 05:43 PM, Walter Bright wrote:
 One example of this is transitive immutability. Nobody asked for it.

I find this hard to believe. I seem to recall that you were personally against const for a very long time. Did none of the people advocating for const suggest a deep const? Should I dig through the archives?

Andrei explained transitivity to me and convinced me of its utility.

Ok, but lots of people have been talking about const correctness for years (including yourself), stemming from the known C++ problems, and I don't see how "transitive immutability" (a deep const) is a new idea that nobody asked for. The only thing new here is that you guys came up with an implementation for D, and lots of people were glad to have it, even if many were also against it.
Jun 16 2010
parent reply Walter Bright <newshound1 digitalmars.com> writes:
Jeff Nowakowski wrote:
 On 06/16/2010 12:33 PM, Walter Bright wrote:
 Jeff Nowakowski wrote:
 On 06/15/2010 05:43 PM, Walter Bright wrote:
 One example of this is transitive immutability. Nobody asked for it.

I find this hard to believe. I seem to recall that you were personally against const for a very long time. Did none of the people advocating for const suggest a deep const? Should I dig through the archives?

Andrei explained transitivity to me and convinced me of its utility.

Ok, but lots of people have been talking about const correctness for years (including yourself), stemming from the known C++ problems, and I don't see how "transitive immutability" (a deep const) is a new idea that nobody asked for. The only thing new here is that you guys came up with an implementation for D, and lots of people were glad to have it, even if many were also against it.

I've talked with C++ experts for years about const. Not one of them ever mentioned transitivity, let alone asked for it or thought it was a desirable property. After we designed transitive const for D, I presented it to several C++ experts. My first job was to explain what transitive meant - none of them were familiar with the idea. Next, it took a lot of convincing of them that this was a good idea. They all insisted that a const pointer to mutable data was terribly important. While it is true that C++ people have talked about const-correctness since const was introduced to C++, it does not at all imply any concept or understanding of transitivity. Transitivity is an orthogonal idea. The people who do understand transitive const and need no convincing are the functional programming crowd. What's interesting are the languages which claim to offer FP features, as that's the latest bandwagon, but totally miss transitive const.
Jun 16 2010
parent reply Walter Bright <newshound1 digitalmars.com> writes:
Walter Bright wrote:
 The people who do understand transitive const and need no convincing are 
 the functional programming crowd. What's interesting are the languages 
 which claim to offer FP features, as that's the latest bandwagon, but 
 totally miss transitive const.

I wish to add that I've not heard any proposal or discussion of adding transitive const to C++0x, Java, or C#.
Jun 16 2010
parent Jeff Nowakowski <jeff dilacero.org> writes:
On 06/16/2010 04:48 PM, Walter Bright wrote:
 Walter Bright wrote:
 The people who do understand transitive const and need no convincing
 are the functional programming crowd. What's interesting are the
 languages which claim to offer FP features, as that's the latest
 bandwagon, but totally miss transitive const.

I wish to add that I've not heard any proposal or discussion of adding transitive const to C++0x, Java, or C#.

I know the Javari paper was mentioned here by Bruno. Also, the idea of deep immutability just isn't rocket science and has occurred to many people, and is why many people have started looking into Haskell given the new focus on concurrency. However, you're right in that as far as I know D is the only language to take the ball and run with it.
Jun 16 2010