git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC] Convert builin-mailinfo.c to use The Better String Library.

From
Andreas Ericsson <ae@op5.se>
Date
Sep 9, 2007, 01:36 UTC
Message-ID
<46E34E19.8050402@op5.se>
In-Reply-To
<20070909003718.GE13385@artemis.corp>
Pierre Habouzit wrote:
Show 11 quoted lines
> On Sat, Sep 08, 2007 at 11:50:34PM +0000, Andreas Ericsson wrote:
> 
>>>> You can tell C compilers to
>>>> check all array accesses, but that is a performance issue.
>>> Runtime checking of arrays in D is a performance issue too, so it is 
>>> selectable via a command line switch.
>> Same as in C then.
> 
>   HAHAHAHAHAHA. Please, who do you try to convince here ? Except in the
> local scope, there is few differences between a foo* and a foo[] in C.
> 

"Runtime checking of arrays is a performance issue." It's true whether it's done manually by the coder or by the compiler. The difference is that in C, you get to choose where it should be done.

Show 15 quoted lines
>>> But more importantly,
>>> 2) For dynamically sized arrays, the dimension of the array is carried
>>> with the array, so loops automatically loop the correct number of times.
>>> No runtime check is necessary, and it's easier for the code reviewer to
>>> visually check the code for correctness.
>> But this introduces handy but, strictly speaking, unnecessary overhead
>> as well, meaning, in short; 'D is slower than C, but easier to write
>> code in'.
> 
>   That's BS. See the strbuf API I've been pushing recently ? It has
> simplified git's code a lot, because each time git had to deal with a
> growing string, it had to deal with at least three variables: the buffer
> pointer, the current occupied length, and its allocated size. That was
> three thing to have variable names for, and to pass to functions.
> 

Yup. I applaud your efforts, but it does come with a slight overhead, except where it replaces faulty code. In practice, it's probably better to use the api for all the string-handling, as none of it is performance- critical.

Show 8 quoted lines
>   Now instead, it's just one struct. D gives that gratis. There is no
> performance loss because you _need_ to do the same. How do you deal with
> dynamic arrays if you dont't store their lenght and size somewhere ? Or
> are you the kind of programmer that write:
> 
>   /* 640kb should be enough for everyone… */
>   some_type *array = malloc(640 << 10);
> 
No, but it would depend on what I am to do with it.
Show 17 quoted lines
> 
>> So in essence, it's a bit like Python, but a teensy bit faster and a
>> lot easier to shoot yourself in the foot with.
> 
>> What was the niche you were going for when you thought up D? It can't
>> have been systems programming, because *any* extra baggage is baggage
>> one would like to get rid of. If it was application programming I fail
>> to see how one more language would help, as there will be portability
>> problems galore and it's still considerably slower to develop in than
>> fe Python, while at the same time being considerably easier to mess up
>> in.
> 
>   Right now I'm just laughing. There is for sure overheads in some
> places of D, but the example you take, and what you try to attack in D
> is definitely not where you lose any kind of performance. You could have
> attacked the GC instead (which is after all an easy classical target).
> 

I was asking what role D was designed to fill. I didn't mean it as an attack, but re-reading what I wrote earlier I see it came off a bit harsh.

>   Just to evaluate the silliness of your arguments:
>   * http://www.digitalmars.com/d/comparison.html so that you can tell
>     what the D features really are,

You may notice that the feature-list is being provided by the creators and marketeers of the D language. Walter Bright certainly seems like a nice enough person, but it's possible it's a tad biased.

>   * http://shootout.alioth.debian.org/gp4/benchmark.php?test=all&lang=all
>     so that you can know what the D performance really is about. Of
>     course those are only micro benchmarks, but well, python is "just"
>     15 times slower than D, and D seems to be 10% slower.

I get it to 7.7xC and 1.2xC, respectively, but whatever. It still means performance-critical apps will be written in C, while insert-script-language-of-choice will still be used for prototyping and not-so performance-critical apps.

Show 5 quoted lines
> Well then I'm
>     okay with D, I'm ready to buy 10% faster CPUs and avoid a lot of
>     painful debugging time. In my world, 10% faster hardware is cheaper
>     by many orders of magnitude than skilled programmers, but YMMV.
> 

I'm curious as to how many fewer bugs D developers write compared to C programmers. I guess it's hard to do a fair test given the comparatively shallow pool of D gurus around, but it'd still be interesting to see a practical test. 20% increase in runtime is certainly acceptable for never having to see a bug again, but is it acceptable for 10% fewer bugs? Or 20% fewer?

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231
Previous: Pierre HabouzitNext: Wincent Colaiuta
Message 48 of 102 in “[RFC] Convert builin-mailinfo.c to use The Better String Library.”
  1. Lukas SandströmSep 4, 2007
  2. Alex RiesenSep 4, 2007
  3. Pierre HabouzitSep 4, 2007
  4. Kristian HøgsbergSep 5, 2007
  5. Matthieu MoySep 5, 2007
  6. Miles BaderSep 6, 2007
  7. Dmitry KakurinSep 6, 2007
  8. Shawn O. PearceSep 6, 2007
  9. Andreas EricssonSep 6, 2007
  10. Junio C HamanoSep 6, 2007
  11. Andreas EricssonSep 6, 2007
  12. David KastrupSep 6, 2007
  13. Miles BaderSep 6, 2007
  14. Johannes SchindelinSep 6, 2007
  15. Linus TorvaldsSep 6, 2007
  16. Dmitry KakurinSep 7, 2007
  17. Linus TorvaldsSep 7, 2007
  18. Dmitry KakurinSep 7, 2007
  19. Linus TorvaldsSep 7, 2007
  20. Dmitry KakurinSep 7, 2007
  21. David SymondsSep 7, 2007
  22. Theodore TsoSep 7, 2007
  23. Steven BurnsSep 20, 2007
  24. Andreas EricssonSep 20, 2007
  25. Andreas EricssonSep 7, 2007
  26. Dmitry KakurinSep 7, 2007
  27. David KastrupSep 7, 2007
  28. Dmitry KakurinSep 8, 2007
  29. David KastrupSep 8, 2007
  30. Andreas EricssonSep 9, 2007
  31. David KastrupSep 7, 2007
  32. Johannes SchindelinSep 7, 2007
  33. Johannes SchindelinSep 7, 2007
  34. David KastrupSep 7, 2007
  35. Linus TorvaldsSep 7, 2007
  36. alanSep 7, 2007
  37. Walter BrightSep 7, 2007
  38. David KastrupSep 7, 2007
  39. Walter BrightSep 7, 2007
  40. David KastrupSep 7, 2007
  41. Walter BrightSep 7, 2007
  42. David KastrupSep 7, 2007
  43. Walter BrightSep 7, 2007
  44. David KastrupSep 7, 2007
  45. Walter BrightSep 7, 2007
  46. Andreas EricssonSep 8, 2007
  47. Pierre HabouzitSep 9, 2007
  48. Andreas EricssonSep 9, 2007
  49. Wincent ColaiutaSep 7, 2007
  50. Pierre HabouzitSep 7, 2007
  51. Walter BrightSep 7, 2007
  52. David KastrupSep 7, 2007
  53. Walter BrightSep 7, 2007
  54. Pierre HabouzitSep 7, 2007
  55. David KastrupSep 7, 2007
  56. Pierre HabouzitSep 7, 2007
  57. Walter BrightSep 7, 2007
  58. Pierre HabouzitSep 7, 2007
  59. Walter BrightSep 7, 2007
  60. John 'Z-Bo' ZabroskiSep 8, 2007
  61. David KastrupSep 8, 2007
  62. Steven BurnsSep 19, 2007
  63. Wincent ColaiutaSep 7, 2007
  64. Paul WankadiaSep 7, 2007
  65. Nicolas PitreSep 7, 2007
  66. Wincent ColaiutaSep 7, 2007
  67. Andreas EricssonSep 7, 2007
  68. Johannes SchindelinSep 7, 2007
  69. Andreas EricssonSep 7, 2007
  70. Wincent ColaiutaSep 7, 2007
  71. Karl HasselströmSep 7, 2007
  72. Andreas EricssonSep 7, 2007
  73. Wincent ColaiutaSep 7, 2007
  74. Andreas EricssonSep 9, 2007
  75. David KastrupSep 7, 2007
  76. Wincent ColaiutaSep 7, 2007
  77. Walter BrightSep 7, 2007
  78. Andreas EricssonSep 7, 2007
  79. Walter BrightSep 7, 2007
  80. David KastrupSep 7, 2007
  81. Andreas EricssonSep 9, 2007
  82. Bernd JendrissekSep 17, 2009
  83. Wincent ColaiutaSep 7, 2007
  84. Walter BrightSep 7, 2007
  85. Steven BurnsSep 22, 2007
  86. David KastrupSep 7, 2007
  87. Andy ParkinsSep 7, 2007
  88. David KastrupSep 7, 2007
  89. Johannes SchindelinSep 7, 2007
  90. Dmitry KakurinSep 8, 2007
  91. David KastrupSep 8, 2007
  92. Alex RiesenSep 8, 2007
  93. figoSep 24, 2007
  94. David KastrupSep 24, 2007
  95. Steven BurnsSep 25, 2007
  96. David KastrupSep 25, 2007
  97. Syed M RaihanMay 22, 2012
  98. Ian MoltonJun 10, 2010
  99. Jakub NarebskiJun 11, 2010
  100. Dario RodriguezJun 11, 2010
  101. Kristian HøgsbergSep 5, 2007
  102. Lukas SandströmSep 7, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.