Board index » delphi » Re: Myths of our time...

Re: Myths of our time...


2003-10-12 03:06:45 AM
delphi253
Rudy Velthuis (TeamB) writes:
Quote
Hmmm... I usually do exactly the opposite. I only use interfaces with
reference counting, and don't destroy objects myself. That way I
can't make mistakes in thinking I can destroy an object.
Ditto.
--
Ingvar Nilsen
 
 

Re: Myths of our time...

Hi,
Quote
Not really. Like I said, doing a loop like that should always perform
badly in every language. Just *how* badly depends on the language, and on
the platform.
Any type of dynamic operation performs worse than any static known outcome operation.
Thus preallocating space and stuffing things into it ofcourse always performs better than having to dynamically
reallocate and copy data. This is not what the discussion is about IMO.
The purpose of creating new generation of languages must be to abstract whats going on under the hood more and make
things easier for developers. Thats anyway what everybody is trying to sell garbage collection on.
People dont have to worry anymore about loose pointers and memory leaks.
But what have been created in both Java and C# (and perhaps the underlying dotNet, although I'd think that a smart
compiler should be able to solve the problem) with regards to string handling is not an abstraction that makes things
easier and less errorprone. On the contrary.
Many people responding on this thread have been very fast in pointing out the 'problem' in Eric's sample code, but only
few seem to understand the essential, basic problem.
I believe Eric is not a newbie in the world of programming, and ofcourse know how to make it perform good, also under
dotNet.
I have been around for many years, and know most of the inner reasons for why a compiler does what it does, how things
operate etc. Thus I can also optimize stuff to run as fast as possible.
But in real life, most programmers will not write super structured, super hand optimized code. Thats not what they are
paid to do. They will write business code. In business code strings are used just as often as numbers, and when a
programmer adds two strings, the programmer expects the compiler/framework to do just that without any severe hidden
sideeffects. They have been able to do so in Cobol, Fortran, VB, Delphi, C++ and just about any other major development
language for years, but suddenly now they cant without risking severe problems.
--
best regards
Kim Madsen
XXXX@XXXXX.COM
www.components4developers.com
The best components for the best developers
kbmMW - kbmMemTable - kbmWABD - kbmX10
 

Re: Myths of our time...

C4D - Kim Madsen writes:
Quote
I believe Eric is not a newbie in the world of programming
Definitely not :)
Quote
But in real life, most programmers will not write super structured,
super hand optimized code. Thats not what they are paid to do. They
will write business code. In business code strings are used just as
often as numbers, and when a programmer adds two strings, the
programmer expects the compiler/framework to do just that without any
severe hidden sideeffects. They have been able to do so in Cobol,
Fortran, VB, Delphi, C++ and just about any other major development
language for years, but suddenly now they cant without risking severe
problems.
Well said!
I approached .Net with this attitude. And I am not the most eager to
defend this. I just have to accept it is like it is, no matter.
--
Ingvar Nilsen
 

Re: Myths of our time...

"Luigi D. Sandon" writes:
Quote
It is a much bigger overhead. Only it is hidden. I never found memory
management an issue.
The overhead I was speaking of was in terms of programmer time. All
the boilerplate you don't have to write, and all the Mandelbugs you
don't have to track down.
If you claim you never ever spent days tracking down an "intermittent"
bug that turned out to be a miscast, or a tombstoned pointer, or
something of the sort, then ... I will say you're lying.
--
programmer, author www.midnightbeach.com
and father www.midnightbeach.com/hs
 

Re: Myths of our time...

Ingvar Nilsen writes:
Quote
Michael D. writes:
>replacement for GC. in fact, GC makes interfaces even more useful and
>
What is GC again?
garbage collector
 

Re: Myths of our time...

Ingvar Nilsen writes:
Quote
Rudy Velthuis (TeamB) writes:
>Hmmm... I usually do exactly the opposite. I only use interfaces with
>reference counting, and don't destroy objects myself. That way I
>can't make mistakes in thinking I can destroy an object.

Ditto.
is it that "good design" mentioned a couple of posts earlier? to me it
looks more like a workaround. to avoid troubles you simply limit when
and how you use the interfaces
 

Re: Myths of our time...

"Rudy Velthuis (TeamB)" <XXXX@XXXXX.COM>writes
Quote
Luigi D. Sandon writes:

>>What would be a "programmer's paradise"? A langauge where a programmer
>could
>>just write any old code without researching and learning the langauge
>>and still get good results? Every tool must be used correctly to get
>>best
>
>A tool that can be used in a "natural way" without having to learn some
>more complex way to accomplish simple tasks?

This looks "natural" as well:

for I := 1 to 100000 do
S := 'NewText' + S;

But now try it. It is so slow that you will be forced to think about
something more efficient.
--
Rudy Velthuis (TeamB)
And if the only way of solving the problem, implementing the feature,
providing the service, etc., etc. is concatenating strings, how would you
solve the problem more efficiently?
I think this discussion has been held in the vacuum of language centric
thought patterns, not real world requirements.
-----Jon-----
 

Re: Myths of our time...

Then how would you build the string? Especially if the contents of the
string are delivered to you one piece at a time?
-----Jon-----
"Rudy Velthuis (TeamB)" <XXXX@XXXXX.COM>writes
Quote
Colin Wilson writes:

>Martin Waldenburg writes:
>
>>>s:='';
>>>for i:=0 to 100000 do s:=s+'toto';
>>
>>tells more about your skills as a programmer ...
>
>I'm with Eric on this. 'Joe Programmer' shouldn't have to know about
>implementation details of the memory management system, etc. and the
>for-loop way is the intuitive way.

But the wrong way, IMO. Even in Delphi, I'd never build a string like
that.
--
Rudy Velthuis (TeamB)

"Friends applaud, the Comedy is over." - Ludwig von Beethoven, dying words
 

Re: Myths of our time...

"Jon Springs" <jspringsATjontandsheDOTorg>writes news:3f88b998$XXXX@XXXXX.COM...
Quote
Then how would you build the string? Especially if the contents of the
string are delivered to you one piece at a time?
Use a P-Tree (Patricia tree ;-)
 

Re: Myths of our time...

"Jon Springs" <jspringsATjontandsheDOTorg>writes
Quote
"Rudy Velthuis (TeamB)" <XXXX@XXXXX.COM>writes
news:3f885264$XXXX@XXXXX.COM...
>
>This looks "natural" as well:
>
>for I := 1 to 100000 do
>S := 'NewText' + S;
>
>But now try it. It is so slow that you will be forced to think about
>something more efficient.

And if the only way of solving the problem, implementing the feature,
providing the service, etc., etc. is concatenating strings, how would you
solve the problem more efficiently?

I think this discussion has been held in the vacuum of language centric
thought patterns, not real world requirements.

Correct. This is a basic flaw in the original proposition that started this
whole discussion - a coding example (a proposed solution) was given in
isolation with no indication of the requirements of the problem that was to
be solved. Some of the possible technical requirements include portability,
memory efficiency, time efficiency, maintainability, reliability etc. etc.
However, Rudy's response is a good example to demonstrate that amateur
programmers don't need a .NET language to help them to write inefficient
code. Every practical real world programming task has more than one possible
solution. It is a programmer's responsibility and duty to choose the optimum
solution to satisfy all of the requirements.
Chris Burrows
CFB Software
www.cfbsoftware.com
 

Re: Myths of our time...

C4D - Kim Madsen writes:
Quote
Hi,

>Not really. Like I said, doing a loop like that should always perform
>badly in every language. Just how badly depends on the language, and
>on the platform.

Any type of dynamic operation performs worse than any static known
outcome operation. Thus preallocating space and stuffing things into
it ofcourse always performs better than having to dynamically
reallocate and copy data. This is not what the discussion is about IMO.
I thought it was?
Quote
But in real life, most programmers will not write super structured,
super hand optimized code.
Sure.
Quote
Thats not what they are paid to do. They will write business code.
And StringBuilder helps them a lot. No need for any "optimization" beyond
that.
--
Rudy Velthuis (TeamB)
"Deliver yesterday, code today, think tomorrow." -- unknown
 

Re: Myths of our time...

Michael D. writes:
Quote
is it that "good design" mentioned a couple of posts earlier? to me
it looks more like a workaround. to avoid troubles you simply limit
when and how you use the interfaces
Ok. Interfaces who have class scope will first be freed when that class
is freed. Simple and reliable.
Interfaces who have function scope will be freed as soon as they are not
needed anymore in that function. Also simple and reliable.
Sometimes you however need to create interfaces at runtime, interfaces
that have no reference at design time. These need to be maintained
somewhere, since the compiler is not aware of them. There is a special
list, TInterfaceList or something like that that can hold them. I tend
to use TList (my all time favorite) and call _Addref and then _Release
until the actual interface returns zero.
With a new design, I always insert debug code in the constructor and the
destructor of the class implementing the interface. This is not
breakpoints, instead it is a utility I wrote ages ago that posts
messages to a listener application that stores all calls.
I can then check that the interfaces really are freed, and that the
number of destructor calls equals the number of constructor calls.
I haven't stumbled into any problems whatsoever with interfaces, maybe I
don't use them to the full extent.
--
Ingvar Nilsen
 

Re: Myths of our time...

Quote
If you claim you never ever spent days tracking down an "intermittent"
bug that turned out to be a miscast, or a tombstoned pointer, or
something of the sort, then ... I will say you're lying.
Days never. Sometimes an hour maybe. But my code is designed and written to
minimize such a problem. As .net programmers know string are not performant,
I know pointers are "dangerous" and use them properly. And I check code for
memory leaks. In a OO program is much easier to track pointer usage than was
in plain procedural programs.
I am spending much more time with VCL bugs, for the matter.
--
Luigi D. Sandon
XXXX@XXXXX.COM
 

Re: Myths of our time...

Jon Springs writes:
Quote
And if the only way of solving the problem, implementing the feature,
providing the service, etc., etc. is concatenating strings, how would
you solve the problem more efficiently?
But it is not the only way of solving the problem, not in Delphi, and not
in C#.
Quote
I think this discussion has been held in the vacuum of language centric
thought patterns, not real world requirements.
I don't think that is true. If someone complains that string building
using concatenation (in C#) is slow, pointing one to a convenient class
like StringBuilder is not "in a vaccum of language centric thought
patterns" at all.
These thought patterns are quite language independent, and simply
constitute basic programming practice. Ignoring them is creating real
world problems.
--
Rudy Velthuis (TeamB)
"I'm not a member of any organized political party, I am a Democrat!"
-- Will Rogers (1879-1935)
 

Re: Myths of our time...

Michael D. writes:
Quote
is it that "good design" mentioned a couple of posts earlier? to me it
looks more like a workaround. to avoid troubles you simply limit when
and how you use the interfaces
No, to me, interfaces represent the only interface the user of a class
should be interested in.
--
Rudy Velthuis (TeamB)
"I still live." - Daniel Webster, dying words