www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - What is Invariant Good For?

reply Walter Bright <walter nospamm-digitalmars.com> writes:
http://www.reddit.com/r/programming/comments/6ui1q/d_what_is_invariant_good_for/
Aug 01 2008
next sibling parent reply "Bruce Adams" <tortoise_74 yeah.who.co.uk> writes:
On Fri, 01 Aug 2008 20:52:26 +0100, Walter Bright  
<walter nospamm-digitalmars.com> wrote:

 http://www.reddit.com/r/programming/comments/6ui1q/d_what_is_invariant_good_for/

I disagree with the suggestion that immutable is a better choice than invariant. To me, perhaps still wrongly in a C++ mindset, mutable and immutable are in terms of the clients ability to modify the data whereas invariant data is invariant in the normal sense because it implies a contract. Namely that X(t+n) == X(t=0) for at least the duration of any function using X. It strikes me that 'dibblego' is some kind of troll or an extreme pedant from a parallel experience. I'm not sure how much communicating with it is educational. I understand all the terms he's using but none of the meanings he is ascribing to them. And calling you a pseudo intellectual for no obvious reason strikes me as very troll-like not to mention rude. Regards, Bruce.
Aug 02 2008
parent reply Walter Bright <newshound1 digitalmars.com> writes:
Bruce Adams wrote:
 It strikes me that 'dibblego' is some kind of troll or an extreme pedant 
 from a parallel experience.
 I'm not sure how much communicating with it is educational. I understand 
 all the terms he's using but none of the meanings he
 is ascribing to them. And calling you a pseudo intellectual for no 
 obvious reason strikes me as very troll-like not to mention
 rude.

His post missed the point of the article by focusing on the definition of a word. At some point, who cares what the word is, it's the concept that matters.
Aug 02 2008
parent reply Sean Kelly <sean invisibleduck.org> writes:
== Quote from Walter Bright (newshound1 digitalmars.com)'s article
 Bruce Adams wrote:
 It strikes me that 'dibblego' is some kind of troll or an extreme pedant
 from a parallel experience.
 I'm not sure how much communicating with it is educational. I understand
 all the terms he's using but none of the meanings he
 is ascribing to them. And calling you a pseudo intellectual for no
 obvious reason strikes me as very troll-like not to mention
 rude.

of a word. At some point, who cares what the word is, it's the concept that matters.

But words represent concepts... generally very specific ones. It's why writing poetry is so darn hard. But more to the point, what if this D program: void main() { void fn( int x ) { writefln( x ); } const int x = 5; void delegate() d = &fn; fn(); } Were this instead: blue main() { blue fn( fast x ) { writefln( x ); } querulous skinflint x = V; blue refrigerator() d = &fn; fn(); } Same concepts, same syntax, but could you convince anyone to use the language? Sean
Aug 02 2008
next sibling parent reply Walter Bright <newshound1 digitalmars.com> writes:
Sean Kelly wrote:
 Same concepts, same syntax, but could you convince anyone to use
 the language?

It's hard to find 3 people to agree on any one word for constant. I might as well have used "refrigerator" to mean invariant.
Aug 02 2008
next sibling parent reply Derek Parnell <derek psych.ward> writes:
On Sat, 02 Aug 2008 19:00:41 -0700, Walter Bright wrote:

 Sean Kelly wrote:
 Same concepts, same syntax, but could you convince anyone to use
 the language?

It's hard to find 3 people to agree on any one word for constant. I might as well have used "refrigerator" to mean invariant.

Isn't this also because we are trying to use simple words to express subtly different concepts. One concept is of something that, once it has been given a value, can *never* have that value changed during the life of the program, and another is that of something that cannot have its value changed in certain circumstances, such as by a specific function or during a specific period of time, etc ... Simple words will never suffice, so we may as well use words which are approximately right and just learn to associated them with their exact meaning. Arguing over 'const' 'immutable', 'invariant', 'constant', 'constrained', 'fixed', 'final', 'hard', 'shell-encrusted-soft-core', ... is pretty much a waste of precious time. It really does not matter; just pick something, define it, and go with it. -- Derek Parnell Melbourne, Australia skype: derek.j.parnell
Aug 02 2008
parent Walter Bright <newshound1 digitalmars.com> writes:
Derek Parnell wrote:
 Simple words will never suffice, so we may as well use words which are
 approximately right and just learn to associated them with their exact
 meaning. Arguing over 'const' 'immutable', 'invariant', 'constant',
 'constrained', 'fixed', 'final', 'hard', 'shell-encrusted-soft-core', ...
 is pretty much a waste of precious time. It really does not matter; just
 pick something, define it, and go with it.

Exactly. The rest is arguing about the color of the bicycle shed.
Aug 02 2008
prev sibling parent reply "Manfred_Nowak" <svv1999 hotmail.com> writes:
Walter Bright wrote:

 I might as well have used [...]

A problem is, that your article refers to "existing terminology confusion"---then more of the same should be avoided. -manfred -- Maybe some knowledge of some types of disagreeing and their relation can turn out to be useful: http://blog.createdebate.com/2008/04/07/writing-strong-arguments/
Aug 03 2008
parent reply Walter Bright <newshound1 digitalmars.com> writes:
Manfred_Nowak wrote:
 Walter Bright wrote:
 
 I might as well have used [...]

A problem is, that your article refers to "existing terminology confusion"---then more of the same should be avoided.

The thing is, nobody has actually been confused about the meaning of invariant as applied to data, as opposed to class invariants. In contrast, what 'const' means when applied to data has plenty of existing confusion.
Aug 03 2008
parent Sean Kelly <sean invisibleduck.org> writes:
== Quote from Walter Bright (newshound1 digitalmars.com)'s article
 Manfred_Nowak wrote:
 Walter Bright wrote:

 I might as well have used [...]

A problem is, that your article refers to "existing terminology confusion"---then more of the same should be avoided.

invariant as applied to data, as opposed to class invariants. In contrast, what 'const' means when applied to data has plenty of existing confusion.

I disagree. The meaning of 'const' is quite clear in D 1.0. At least for me :p And while I understand the redefinition of 'const' in D 2.0, it's not intuitive given its use in D 1.0. Sean
Aug 03 2008
prev sibling parent reply Paul D. Anderson <paul.d.removethis.anderson comcast.andthis.net> writes:
Bruce Adams Wrote:

 On Sun, 03 Aug 2008 02:52:10 +0100, Sean Kelly <sean invisibleduck.org>  
 wrote:
 
 == Quote from Walter Bright (newshound1 digitalmars.com)'s article
 Bruce Adams wrote:
 It strikes me that 'dibblego' is some kind of troll or an extreme  

 from a parallel experience.
 I'm not sure how much communicating with it is educational. I  

 all the terms he's using but none of the meanings he
 is ascribing to them. And calling you a pseudo intellectual for no
 obvious reason strikes me as very troll-like not to mention
 rude.

of a word. At some point, who cares what the word is, it's the concept that matters.

But words represent concepts... generally very specific ones. It's why writing poetry is so darn hard.

Actually its quite the reverse. In normal usage (insert your definition of normal here) words have several grey, slightly overlapping and fuzzy meanings. And that's ignoring the synonyms and sounds-a-likes. Its only when you try to write in a so called technical English that meanings get narrowed down and eve then it doesn't take much to find a confusing alternate meaning for them. As programmers we are uniquely blessed/cursed with 'words' that mean precisely one thing when passed to a specific compiler in a certain context. :-) Regards, Bruce.

All true, but the keywords that are most controversial are ones that are overloaded to mean different things in different contexts. The best example is "enum". Walter correctly observes that, from a compiler designer's point of view, a list of enumerated values is the same as a "manifest constant", so he re-uses the keyword. To a programmer (or at least this progammer) the two things are conceptually different, used for different reasons. I find the usage confusing. This sort of thing is common when you put engineers in charge of the user interface. The aspects of the problem that are important to the implementation are paramount to the implementer and it's easy to lose sight of the fact that the user doesn't care. What's intuitive to the user is not what's intuitive to the designer. "Invariant" has a specific meaning to programmers with respect to contracts. "Invariant" as Walter uses it is the same, but different. It is illuminating that those who commented on Walter's article focussed on the keyword and not on the concept. It's the intuition of the designer not matching the intuition of the user again. I know we went round and round regarding this keyword and Walter's right -- at some point you just have to make a decision and go with it. But when there's so much complaint about the decision it may be time to reconsider. Paul
Aug 03 2008
next sibling parent reply Walter Bright <newshound1 digitalmars.com> writes:
Paul D. Anderson wrote:
 I know we went round and round regarding this keyword and Walter's
 right -- at some point you just have to make a decision and go with
 it. But when there's so much complaint about the decision it may be
 time to reconsider.

I guarantee it that if "invariant" is changed to something else, an alternate set of people will rise and say it's now screwed up :-) because, in reality, there is no right answer.
Aug 03 2008
parent reply JMNorris <nospam nospam.com> writes:
Walter Bright <newshound1 digitalmars.com> wrote in news:g75lsg$1j2o$1
 digitalmars.com:

 Paul D. Anderson wrote:
 I know we went round and round regarding this keyword and Walter's
 right -- at some point you just have to make a decision and go with
 it. But when there's so much complaint about the decision it may be
 time to reconsider.

I guarantee it that if "invariant" is changed to something else, an alternate set of people will rise and say it's now screwed up :-) because, in reality, there is no right answer.

I like "invariant". The expression "invariant variable" has a satisfyingly oxymoronic ring to it. :-) -- JMNorris
Aug 04 2008
parent Russell Lewis <webmaster villagersonline.com> writes:
JMNorris wrote:
 I like "invariant".  The expression "invariant variable" has a satisfyingly 
 oxymoronic ring to it.  :-)

I've thought about "invariable" from time to time. :)
Aug 04 2008
prev sibling parent Bruno Medeiros <brunodomedeiros+spam com.gmail> writes:
Paul D. Anderson wrote:
 Bruce Adams Wrote:
 
 On Sun, 03 Aug 2008 02:52:10 +0100, Sean Kelly <sean invisibleduck.org>  
 wrote:

 == Quote from Walter Bright (newshound1 digitalmars.com)'s article
 Bruce Adams wrote:
 It strikes me that 'dibblego' is some kind of troll or an extreme  

 from a parallel experience.
 I'm not sure how much communicating with it is educational. I  

 all the terms he's using but none of the meanings he
 is ascribing to them. And calling you a pseudo intellectual for no
 obvious reason strikes me as very troll-like not to mention
 rude.

of a word. At some point, who cares what the word is, it's the concept that matters.

writing poetry is so darn hard.

of normal here) words have several grey, slightly overlapping and fuzzy meanings. And that's ignoring the synonyms and sounds-a-likes. Its only when you try to write in a so called technical English that meanings get narrowed down and eve then it doesn't take much to find a confusing alternate meaning for them. As programmers we are uniquely blessed/cursed with 'words' that mean precisely one thing when passed to a specific compiler in a certain context. :-) Regards, Bruce.

All true, but the keywords that are most controversial are ones that are overloaded to mean different things in different contexts. The best example is "enum". Walter correctly observes that, from a compiler designer's point of view, a list of enumerated values is the same as a "manifest constant", so he re-uses the keyword. To a programmer (or at least this progammer) the two things are conceptually different, used for different reasons. I find the usage confusing. This sort of thing is common when you put engineers in charge of the user interface. The aspects of the problem that are important to the implementation are paramount to the implementer and it's easy to lose sight of the fact that the user doesn't care. What's intuitive to the user is not what's intuitive to the designer. "Invariant" has a specific meaning to programmers with respect to contracts. "Invariant" as Walter uses it is the same, but different. It is illuminating that those who commented on Walter's article focussed on the keyword and not on the concept. It's the intuition of the designer not matching the intuition of the user again. I know we went round and round regarding this keyword and Walter's right -- at some point you just have to make a decision and go with it. But when there's so much complaint about the decision it may be time to reconsider. Paul

Although I think 'immutable' is preferable over 'invariant', I only think it's *slightly* preferable, and don't have much of a beef with 'invariant'. I would reckon much of the rest of the community also doesn't mind 'invariant'. The real beef was 'const', that a lot of people (myself included) thought it wasn't very adequate and other alternatives such as 'readonly' were preferred. But frankly, I cant' say this is an issue on the top list of things that I find troublesome in D. -- Bruno Medeiros - Software Developer, MSc. in CS/E graduate http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
Aug 11 2008
prev sibling next sibling parent Jesse Phillips <jessekphillips gmail.com> writes:
On Sat, 02 Aug 2008 11:42:32 +0100, Bruce Adams wrote:

 On Fri, 01 Aug 2008 20:52:26 +0100, Walter Bright
 <walter nospamm-digitalmars.com> wrote:
 
 http://www.reddit.com/r/programming/comments/6ui1q/


 
 I disagree with the suggestion that immutable is a better choice than
 invariant. To me, perhaps still wrongly in a C++ mindset, mutable and
 immutable are in terms of the clients ability to modify the data whereas
 invariant data is invariant in the normal sense because it implies a
 contract. Namely that X(t+n) == X(t=0) for at least the duration of any
 function using X.
 
 It strikes me that 'dibblego' is some kind of troll or an extreme pedant
  from a parallel experience.
 I'm not sure how much communicating with it is educational. I understand
 all the terms he's using but none of the meanings he is ascribing to
 them. And calling you a pseudo intellectual for no obvious reason
 strikes me as very troll-like not to mention rude.
 
 Regards,
 
 Bruce.

I would like to agree with you here, on the mutable and 'dibblego' point. Everything 'dibblego' says is done in a way that he uses many big words that he understands the meaning for, but fits them together in a way that is incorrect but sounds like it is an undeniable truth. I have only come across this such graceful tactic once before, the true trolls, Jerry Lee Cooper http://jerryleecooper.com/ a fan blog of his great work.
Aug 02 2008
prev sibling next sibling parent reply "Peter C. Chapin" <pcc482719 gmail.com> writes:
Walter Bright wrote:

 http://www.reddit.com/r/programming/comments/6ui1q/d_what_is_invariant_good_for/

For what it's worth, I agree with some of the posts on the article itself that "immutable" would be a better word to describe this concept than "invariant." I've done some functional programming and I immediately understand what immutable means (and why it is good). With invariant I had to read about it first. The word invariant makes me think of class invariants and loop invariants... a somewhat different concept. Peter
Aug 02 2008
parent reply Knud Soerensen <4tuu4k002 sneakemail.com> writes:
Peter C. Chapin wrote:
 Walter Bright wrote:
 
 http://www.reddit.com/r/programming/comments/6ui1q/d_what_is_invariant_good_for/

For what it's worth, I agree with some of the posts on the article itself that "immutable" would be a better word to describe this concept than "invariant." I've done some functional programming and I immediately understand what immutable means (and why it is good). With invariant I had to read about it first. The word invariant makes me think of class invariants and loop invariants... a somewhat different concept. Peter

I agree invariant also leads my thoughts into other things. Walter says in a comments that there is alot of momentum behind invariant. To verify that I have made a poll, please vote and let us see http://jyte.com/cl/immutable-would-be-better-than-invariant-in-the-d-programming-language -- http://crowdnews.eu - Promote yourself and your friends!
Aug 03 2008
parent reply "Koroskin Denis" <2korden gmail.com> writes:
On Sun, 03 Aug 2008 14:33:55 +0400, Knud Soerensen  
<4tuu4k002 sneakemail.com> wrote:

 Peter C. Chapin wrote:
 Walter Bright wrote:

 http://www.reddit.com/r/programming/comments/6ui1q/d_what_is_invariant_good_for/

For what it's worth, I agree with some of the posts on the article itself that "immutable" would be a better word to describe this concept than "invariant." I've done some functional programming and I immediately understand what immutable means (and why it is good). With invariant I had to read about it first. The word invariant makes me think of class invariants and loop invariants... a somewhat different concept. Peter

I agree invariant also leads my thoughts into other things. Walter says in a comments that there is alot of momentum behind invariant. To verify that I have made a poll, please vote and let us see http://jyte.com/cl/immutable-would-be-better-than-invariant-in-the-d-programming-language

Nice idea but... I wouldn't sign up for the site just for a vote. Sorry.
Aug 03 2008
parent reply Knud Soerensen <4tuu4k002 sneakemail.com> writes:
Koroskin Denis wrote:
 On Sun, 03 Aug 2008 14:33:55 +0400, Knud Soerensen
 <4tuu4k002 sneakemail.com> wrote:
 
 Peter C. Chapin wrote:
 Walter Bright wrote:

 http://www.reddit.com/r/programming/comments/6ui1q/d_what_is_invariant_good_for/

For what it's worth, I agree with some of the posts on the article itself that "immutable" would be a better word to describe this concept than "invariant." I've done some functional programming and I immediately understand what immutable means (and why it is good). With invariant I had to read about it first. The word invariant makes me think of class invariants and loop invariants... a somewhat different concept. Peter

I agree invariant also leads my thoughts into other things. Walter says in a comments that there is alot of momentum behind invariant. To verify that I have made a poll, please vote and let us see http://jyte.com/cl/immutable-would-be-better-than-invariant-in-the-d-programming-language

Nice idea but... I wouldn't sign up for the site just for a vote. Sorry.

The site uses openid, so if you already have a openid you can just login. A lot of big sites provide openids, so you might already have one see here http://openid.net/get/ -- Crowdnews.eu - a social news site based on sharing instead of voting.
Aug 03 2008
parent "Nick Sabalausky" <a a.a> writes:
"Knud Soerensen" <4tuu4k002 sneakemail.com> wrote in message 
news:g746ne$2468$1 digitalmars.com...
 Koroskin Denis wrote:
 On Sun, 03 Aug 2008 14:33:55 +0400, Knud Soerensen
 <4tuu4k002 sneakemail.com> wrote:

 Peter C. Chapin wrote:
 Walter Bright wrote:

 http://www.reddit.com/r/programming/comments/6ui1q/d_what_is_invariant_good_for/

For what it's worth, I agree with some of the posts on the article itself that "immutable" would be a better word to describe this concept than "invariant." I've done some functional programming and I immediately understand what immutable means (and why it is good). With invariant I had to read about it first. The word invariant makes me think of class invariants and loop invariants... a somewhat different concept. Peter

I agree invariant also leads my thoughts into other things. Walter says in a comments that there is alot of momentum behind invariant. To verify that I have made a poll, please vote and let us see http://jyte.com/cl/immutable-would-be-better-than-invariant-in-the-d-programming-language

Nice idea but... I wouldn't sign up for the site just for a vote. Sorry.

The site uses openid, so if you already have a openid you can just login. A lot of big sites provide openids, so you might already have one see here http://openid.net/get/ -- Crowdnews.eu - a social news site based on sharing instead of voting.

I avoid openid.
Aug 05 2008
prev sibling next sibling parent "Bruce Adams" <tortoise_74 yeah.who.co.uk> writes:
On Sun, 03 Aug 2008 02:52:10 +0100, Sean Kelly <sean invisibleduck.org>  
wrote:

 == Quote from Walter Bright (newshound1 digitalmars.com)'s article
 Bruce Adams wrote:
 It strikes me that 'dibblego' is some kind of troll or an extreme  

 from a parallel experience.
 I'm not sure how much communicating with it is educational. I  

 all the terms he's using but none of the meanings he
 is ascribing to them. And calling you a pseudo intellectual for no
 obvious reason strikes me as very troll-like not to mention
 rude.

of a word. At some point, who cares what the word is, it's the concept that matters.

But words represent concepts... generally very specific ones. It's why writing poetry is so darn hard.

Actually its quite the reverse. In normal usage (insert your definition of normal here) words have several grey, slightly overlapping and fuzzy meanings. And that's ignoring the synonyms and sounds-a-likes. Its only when you try to write in a so called technical English that meanings get narrowed down and eve then it doesn't take much to find a confusing alternate meaning for them. As programmers we are uniquely blessed/cursed with 'words' that mean precisely one thing when passed to a specific compiler in a certain context. :-) Regards, Bruce.
Aug 03 2008
prev sibling parent Wyverex <wyverex.cypher gmail.com> writes:
Walter Bright wrote:
 http://www.reddit.com/r/programming/comments/6ui1q/d_what_is_invariant_good_for/

not here to fight the term or meaning but I think short words should be used, faster to type, shorter lines, less likely to miss type. Just like we used const in place of constant. Just my $.02 invar = invariant sync = synchronized -Wyv
Aug 04 2008