Click here to Skip to main content
15,891,837 members

The Insider News

   

The Insider News is for breaking IT and Software development news. Post your news, your alerts and your inside scoops. This is an IT news-only forum - all off-topic, non-news posts will be removed. If you wish to ask a programming question please post it here.

Get The Daily Insider direct to your mailbox every day. Subscribe now!

 
NewsEthiopian kids hack OLPCs in 5 months with zero instruction PinPopular
Terrence Dorsey31-Oct-12 8:18
sitebuilderTerrence Dorsey31-Oct-12 8:18 
GeneralRe: Ethiopian kids hack OLPCs in 5 months with zero instruction Pin
LloydA11131-Oct-12 8:27
LloydA11131-Oct-12 8:27 
GeneralRe: Ethiopian kids hack OLPCs in 5 months with zero instruction Pin
  Forogar  31-Oct-12 10:42
professional  Forogar  31-Oct-12 10:42 
GeneralRe: Ethiopian kids hack OLPCs in 5 months with zero instruction Pin
Vivi Chellappa31-Oct-12 14:34
professionalVivi Chellappa31-Oct-12 14:34 
NewsWhy Am I Excited about Windows Phone 8 SDK? Pin
Terrence Dorsey31-Oct-12 8:17
sitebuilderTerrence Dorsey31-Oct-12 8:17 
NewsBeware the String PinPopular
Dave Kreskowiak31-Oct-12 4:01
mveDave Kreskowiak31-Oct-12 4:01 
GeneralRe: Beware the String Pin
Clifford Nelson31-Oct-12 6:21
Clifford Nelson31-Oct-12 6:21 
GeneralRe: Beware the String Pin
Judah Gabriel Himango31-Oct-12 10:31
sponsorJudah Gabriel Himango31-Oct-12 10:31 
Excellent article. Unfortunate he turned off comments; a blog without comments isn't a blog.

But a great article nonetheless. He argues convincingly that because System.String is so easy to use, people end up building new strings all the time, allocating memory and increasing pressure on the garbage collector, and, contrary to popular belief, this is not free.

I'm reminded of this recent article: Why I Program in Erlang[^]. The author makes the case that Erlang's non-obvious implementation of strings is the right one:

Or take string concatenation. If you pop open the implementation of string concatenation in Perl, Ruby, or JavaScript, you are certain to find an if statement, a realloc, and a memcpy. That is, when you concatenate two strings, the first string is grown to make room for the second, and then the second is copied into the first. This approach has worked for decades and is the “obvious” thing to do. Erlang's approach is non-obvious, and, I believe, correct. In the usual case, Erlang does not use a contiguous chunk of memory to represent a sequence of bytes. Instead, it something called an “I/O list” — a nested list of non-contiguous chunks of memory. The result is that concatenating two strings (I/O lists) takes O(1) time in Erlang, compared O(N) time in other languages. This is why template rendering in Ruby, Python, etc. is slow, but very fast in Erlang.


Duffy's .NET strings article got me thinking about more efficient ways to represent a string. Obviously we have StringBuilder. Would passing around lazy IEnumerable<char> be any different?
Or some amplified type from there?

Interesting thought exercise. But in my day-to-day work, I'm happy just using System.String.


My Messianic Jewish blog: Kineti L'Tziyon
My software blog: Debugger.Break()
Judah Himango


GeneralRe: Beware the String Pin
AspDotNetDev31-Oct-12 10:54
protectorAspDotNetDev31-Oct-12 10:54 
GeneralRe: Beware the String Pin
harold aptroot1-Nov-12 3:27
harold aptroot1-Nov-12 3:27 
GeneralRe: Beware the String Pin
Ravi Bhavnani31-Oct-12 11:45
professionalRavi Bhavnani31-Oct-12 11:45 
GeneralRe: Beware the String Pin
Richard Deeming1-Nov-12 8:16
mveRichard Deeming1-Nov-12 8:16 
GeneralRe: Beware the String Pin
Dave Kreskowiak1-Nov-12 9:05
mveDave Kreskowiak1-Nov-12 9:05 
GeneralRe: Beware the String Pin
Richard Deeming1-Nov-12 9:42
mveRichard Deeming1-Nov-12 9:42 
NewsCalifornia issues notices to app developers for non-compliance with privacy law PinPopular
atbennett31-Oct-12 3:16
atbennett31-Oct-12 3:16 
GeneralRe: California issues notices to app developers for non-compliance with privacy law Pin
Clifford Nelson31-Oct-12 6:17
Clifford Nelson31-Oct-12 6:17 
NewsIntel working on 48-core chip for smartphones, tablets Pin
Terrence Dorsey30-Oct-12 12:24
sitebuilderTerrence Dorsey30-Oct-12 12:24 
GeneralAnd the problem is Pin
Clifford Nelson30-Oct-12 12:48
Clifford Nelson30-Oct-12 12:48 
GeneralRe: And the problem is Pin
devvvy30-Oct-12 15:47
devvvy30-Oct-12 15:47 
GeneralRe: And the problem is Pin
Clifford Nelson31-Oct-12 6:28
Clifford Nelson31-Oct-12 6:28 
GeneralRe: And the problem is Pin
devvvy31-Oct-12 15:14
devvvy31-Oct-12 15:14 
GeneralRe: And the problem is Pin
bitterskittles30-Oct-12 23:00
bitterskittles30-Oct-12 23:00 
GeneralRe: And the problem is PinPopular
harold aptroot30-Oct-12 23:45
harold aptroot30-Oct-12 23:45 
GeneralRe: And the problem is Pin
bitterskittles31-Oct-12 0:15
bitterskittles31-Oct-12 0:15 
GeneralRe: And the problem is Pin
devvvy31-Oct-12 15:17
devvvy31-Oct-12 15:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.