www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - Invariant strings on Dr. Dobb's

reply Walter Bright <newshound1 digitalmars.com> writes:
Dr. Dobb's has invited me to write a blog for them, so here's my first 
installment on invariant strings:

http://www.dobbscodetalk.com/index.php?option=com_myblog&show=Invariant-Strings.html&Itemid=29
Mar 13 2008
next sibling parent reply BCS <ao pathlink.com> writes:
Reply to Walter,

 Dr. Dobb's has invited me to write a blog for them, so here's my first
 installment on invariant strings:
 
 http://www.dobbscodetalk.com/index.php?option=com_myblog&show=Invarian
 t-Strings.html&Itemid=29
 
wow, a publicly available picture of Walter! And on the content; you mention concatenation as working on invariant strings. I assume this is because you generally can't concatenate in place anyway?
Mar 13 2008
next sibling parent reply Walter Bright <newshound1 digitalmars.com> writes:
BCS wrote:
 And on the content; you mention concatenation as working on invariant 
 strings. I assume this is because you generally can't concatenate in 
 place anyway?
I'm not sure what you mean.
Mar 13 2008
parent reply BCS <ao pathlink.com> writes:
Reply to Walter,

 BCS wrote:
 
 And on the content; you mention concatenation as working on invariant
 strings. I assume this is because you generally can't concatenate in
 place anyway?
 
I'm not sure what you mean.
You say that the common ops generally don't mutate the data and then list "moving references around, slicing, and concatenating". I guess my thought is that the first two are a bit more self explanatory than the last. Clearly 1 & 2 are non mutating but, a guy who is a few Lattes behind might not notice that because you, in general, don't known what comes after a string, if you want to extend a string (for concatenating), you need to allocate new ram for it, thus leaving the first blocks untouched. (I'm not thinking specific to D here).
Mar 13 2008
parent Walter Bright <newshound1 digitalmars.com> writes:
BCS wrote:
 You say that the common ops generally don't mutate the data and then 
 list "moving references around, slicing, and concatenating". I guess my 
 thought is that the first two are a bit more self explanatory than the 
 last. Clearly 1 & 2 are non mutating but, a guy who is a few Lattes 
 behind might not notice that because you, in general, don't known what 
 comes after a string, if you want to extend a string (for 
 concatenating), you need to allocate new ram for it, thus leaving the 
 first blocks untouched. (I'm not thinking specific to D here).
All I meant was that a common operation is concatenating - an operation that in C is usually done by allocating a mutable buffer, then copying the strings into it.
Mar 13 2008
prev sibling next sibling parent reply Bill Baxter <dnewsgroup billbaxter.com> writes:
BCS wrote:
 Reply to Walter,
 
 Dr. Dobb's has invited me to write a blog for them, so here's my first
 installment on invariant strings:

 http://www.dobbscodetalk.com/index.php?option=com_myblog&show=Invarian
 t-Strings.html&Itemid=29
wow, a publicly available picture of Walter!
You can actually see him move, and talk, too, if you go here! http://video.google.com/videoplay?docid=-7073020265668105471 :-)
Mar 13 2008
next sibling parent Walter Bright <newshound1 digitalmars.com> writes:
Bill Baxter wrote:
 You can actually see him move, and talk, too, if you go here!
   http://video.google.com/videoplay?docid=-7073020265668105471
That's just a very clever animation. Those google fellows are good!
Mar 13 2008
prev sibling parent reply BCS <ao pathlink.com> writes:
Reply to Bill,

 BCS wrote:
 
 Reply to Walter,
 
 Dr. Dobb's has invited me to write a blog for them, so here's my
 first installment on invariant strings:
 
 http://www.dobbscodetalk.com/index.php?option=com_myblog&show=Invari
 an t-Strings.html&Itemid=29
 
wow, a publicly available picture of Walter!
You can actually see him move, and talk, too, if you go here! http://video.google.com/videoplay?docid=-7073020265668105471 :-)
I think the thumbnail pix on the /blog/ has better resolution!
Mar 13 2008
parent reply Brad Roberts <braddr puremagic.com> writes:
On Fri, 14 Mar 2008, BCS wrote:

 Reply to Bill,
 
 BCS wrote:
 
 Reply to Walter,
 
 Dr. Dobb's has invited me to write a blog for them, so here's my
 first installment on invariant strings:
 
 http://www.dobbscodetalk.com/index.php?option=com_myblog&show=Invari
 an t-Strings.html&Itemid=29
 
wow, a publicly available picture of Walter!
You can actually see him move, and talk, too, if you go here! http://video.google.com/videoplay?docid=-7073020265668105471 :-)
I think the thumbnail pix on the /blog/ has better resolution!
A better picture.. http://d.puremagic.com/conference2007/DConference_2007_group_0.html Walter is the guy font and center in the purple shirt. Later, Brad
Mar 14 2008
next sibling parent reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"Brad Roberts" <braddr puremagic.com> wrote in message 
news:Pine.LNX.4.64.0803141239090.4104 bellevue.puremagic.com...

 A better picture..

 http://d.puremagic.com/conference2007/DConference_2007_group_0.html
What a bunch of nerds!
Mar 14 2008
parent Walter Bright <newshound1 digitalmars.com> writes:
Jarrett Billingsley wrote:
 What a bunch of nerds! 
Wierd Al did a song about our family, Bright & Nerdy: http://www.youtube.com/watch?v=-xEzGIuY7kw
Mar 14 2008
prev sibling parent BCS <ao pathlink.com> writes:
Reply to Brad,

 A better picture..
 
 http://d.puremagic.com/conference2007/DConference_2007_group_0.html
 
 Walter is the guy font and center in the purple shirt.
 
 Later,
 Brad
<grin size=huge> And that's me, in the back, and to the right a bit (between Don C. and Gregor R.) </grin>
Mar 14 2008
prev sibling parent Sean Kelly <sean invisibleduck.org> writes:
== Quote from BCS (ao pathlink.com)'s article
 Reply to Walter,
 Dr. Dobb's has invited me to write a blog for them, so here's my first
 installment on invariant strings:

 http://www.dobbscodetalk.com/index.php?option=com_myblog&show=Invarian
 t-Strings.html&Itemid=29
wow, a publicly available picture of Walter! And on the content; you mention concatenation as working on invariant strings. I assume this is because you generally can't concatenate in place anyway?
Regarding D specifically, I think it is generally quite possible to append to a string in place, but doing so can be problematic for the inattentive programmer: char[] refA = "abc".dup; char[] refB = refA; refA ~= "def"; refB ~= "ghi"; With mutable strings, the above will likely result (depending on the runtime and GC implementation) in both refA and refB still pointing to the same location, which contains"abcghi". Invariant strings address this issue by providing predictable semantics, making strings behave very much like a value type. This is achieved through always reallocating and copying when a mutation occurs however, which I feel makes it not suitable for all situations. It's a great default for everyday programming, but must be used much more carefully in performance-critical applications. So in short, I'm not convinced that invariant strings will save the world--at least not until we have zero-cost garbage collection--but they are certainly quite easy and safe to use. Sean
Mar 14 2008
prev sibling next sibling parent reply Moritz Warning <moritzwarning _nospam_web.de> writes:
On Thu, 13 Mar 2008 14:25:00 -0700, Walter Bright wrote:

 Dr. Dobb's has invited me to write a blog for them, so here's my first
 installment on invariant strings:
 
 http://www.dobbscodetalk.com/index.php?option=com_myblog&show=Invariant-
Strings.html&Itemid=29 There is a poll in the right corner: "What programming language do you PREFER to work in?" Would be nice if they would have a "D" option.
Mar 13 2008
parent Walter Bright <newshound1 digitalmars.com> writes:
Moritz Warning wrote:
 There is a poll in the right corner:
 "What programming language do you PREFER to work in?"
 Would be nice if they would have a "D" option.
I sent an email to the editor asking them to fix that.
Mar 13 2008
prev sibling next sibling parent reply Bill Baxter <dnewsgroup billbaxter.com> writes:
Walter Bright wrote:
 Dr. Dobb's has invited me to write a blog for them, so here's my first 
 installment on invariant strings:
 
 http://www.dobbscodetalk.com/index.php?option=com_myblog&show=Invariant-St
ings.html&Itemid=29 
 
Weird. Somebody edited the comments I posted. They basically did the edits I wanted to make but couldn't, but it still leaves me with a creepy feeling. --bb
Mar 13 2008
parent Walter Bright <newshound1 digitalmars.com> writes:
Bill Baxter wrote:
 Weird.  Somebody edited the comments I posted.  They basically did the 
 edits I wanted to make but couldn't, but it still leaves me with a 
 creepy feeling.
Mine too. Must be the elves at DDJ. Either that or Skynet.
Mar 13 2008
prev sibling parent Walter Bright <newshound1 digitalmars.com> writes:
Some more comments on reddit:

http://reddit.com/r/programming/info/6c0ys/comments/
Mar 14 2008