Re: Fuzzy Union in C++
- From: Seweryn Habdank-Wojewódzki <habdank@xxxxxxxxx>
- Date: Fri, 16 Feb 2007 12:46:16 +0100
Hi
Dmitry A. Kazakov wrote:
[ One of big design faults of C++, which prevents many good optimization,
is messing up with the issues of aliasing. ]
I do not observe that. But this is maybe the choice of targets. Ada and
similar are generally not working on many platforms. The same as with
number representation and Undefined Behavior (UB) and Implementation
Specific (IS) in C++ standard. Some people are shouting about UB and the
rest, but they forget that C++ and C are not designed only for PC, and only
for huge machines. They forgen that on DSP float and double are other than
on AMD Opteron 64bit. They do not understand that Java, Ada and D and C#
are not running on DSP, so great features of that languages are useless.
Especially GC what is a problem for many programmers - they are making mess
in code and they want that language will clean this mess - I know one
theoretical situation when GC is needed, but personaly I have never such a
problem.
I just want to say that there are many languages and they are designed for
some purposes. I do not want to say that C++ and C are the best.
Even if they have fails, I will use them until I will be sure that there are
better ones for my a purpose. For my computational software Java is not
good because there are too much troubles with its VM. Even if I will use
Ada I will not force third parties to learn Ada and I have problems that
Ada is not designed to work on DSP and similar. D and the rest are ... you
know they are on the margin. Interesting for me are:
Python - this is very powerful scripting language; C# is good for GUI on PC;
Some odd but useful languages: Haskel is very good functional language, and
many problems which are existed in Ada and C++ are easy there. R language,
is a very good computational an functional language, however it is not very
fast - faster then Matlab and Mathematica. Last two languages (programs)
are also good.
So I prefer to choose dedicated language for certain purpose to show which
language is the best one. Such a symptom exists in Java community, until
they need to port a piece of software of library from PC to cell phone -
and all is finished by retyping library of software.
BTW: there are very interesting documents:
http://www.adacore.com/wp-content/files/attachments/Certification_OO_Ada_Answer.pdf
http://www.adacore.com/wp-content/files/attachments/Safety_Security_OOP.pdf
Read why sometimes class-wide programming can be a problematic.
It is a matter of view.
I don't see how it could be a matter of view. Either the object can be
allocated on the stack or not.
So work on references:
T & multiply ( T const & rhs, T const & lhs, T & result );
You can create an result object on stack and then work on.
The more important matter is - if it is a real trouble in the
language?
Sure. Firstly, is a huge performance hit. Secondly it is a great safety
problem, because it enforces the programmer to use pointers with all
consequent problems of.
I do not see the problems with pointers. Are they? Of course if we are
talking about good programmers, because if we are talking about low quality
programmers then the hit performace is sometimes before one line of the
program is written - design is awful and algorithms are not proper e.g. too
general or not proper (slow). Many projects that I saw was based on not
properly taken container. E.g. if someone need all time to add something to
container which have to be sorted, and he or she is working on vector
(array) and everytime sorts it - this is bigger hit performance then
difference between stack and heap allocations.
No, smart pointers are objects themselves. The problem well applies to
them, because in the case of a hierarchy of pointer types, you were unable
to return a pointer of an unknown specific pointer type on the stack.
And? What is a problem in using references?
But you have to know that in advance, before you write the first line of
code.
No. I need even less than in OO.
How so? Your example does not show it.
I have lost. I do not know what you mean. Which my example does not show
what?
Why should I? It is not a member of the class foo.
So you can observe what is a problem with virtuals. If you want to extend
interface you always need to extend all base class. Consider different
derided classes that you need to have different foo method. And as result
you will have very big base class to handle all foo-kind methods.
Consider more, what you have to do if you want to eliminate foo functions
and repalce them with one master_foo
void master_foo ( Argument_type & arg, Result_type & res );
references can be polymorphic. But look hat will be inside master foo. if
you want to do that properly. Show me the code in Ada if you need to
consider Argument_types := { int, double, complex, my_nth_dim_vector } and
similar for Result_type. For simplification assume that for one class
Argument_type is the same as Result_type. But one type is handled by only
one class and if tye type is missing you have to therow exception or use
other error generation functionality.
No, this is ad-hockery. Software analysis and design presumes up-front
consideration of what should be classes and which primitive operations
they have. This is exactly same for both static classes of generic
template parameters and dynamic classes of types. In both cases the
programmer's responsibility is to identify the class and to consider its
behavior.
Yes and if they do not consider functionality, just classes they can not do
what is old but now is again old -> Aspect Oriented Programming. This is
just that if some classes have the same FUNCTIONALITY, then you can
separate this interface and functional class - in C++ called functor class.
If you will not separate it you will have the same ugly desing what is in
Java classes - ton of useless methods in one class.
Yes. But similar level of abstraction you could reach by static
polymorphism - of course with respect to compile time.
The level of abstraction is irrelevant to the point of early design
decision making. Further, the purpose of any higher abstraction is to
postpone, if not eliminate, the need in making such premature [and
low-level] decisions. Templates clearly fail here. They impose a design
constraint.
Show them. Design constraints are if you can not use doubles and int because
you have to use heavy wprapper classes like in Java Double, Integer and so
on. Even if you do not need it. Or if you need to use have vector and
matrices functions that need to be derived from the same class which are
inherited Double and Integer.
Except programming computing languages I really do not know where you really
need to start design with:
Basic_argument_type;
Basic_functional_type;
Basic_class_type;
And all is derived.
Regards.
--
|\/\/| Seweryn Habdank-Wojewódzki
`\/\/'
.
- Follow-Ups:
- Re: Fuzzy Union in C++
- From: Dmitry A. Kazakov
- Re: Fuzzy Union in C++
- References:
- Re: Fuzzy Union in C++
- From: Seweryn Habdank-Wojewódzki
- Re: Fuzzy Union in C++
- From: Dmitry A. Kazakov
- Re: Fuzzy Union in C++
- From: Seweryn Habdank-Wojewódzki
- Re: Fuzzy Union in C++
- From: Dmitry A. Kazakov
- Re: Fuzzy Union in C++
- From: Seweryn Habdank-Wojewódzki
- Re: Fuzzy Union in C++
- From: Dmitry A. Kazakov
- Re: Fuzzy Union in C++
- From: Seweryn Habdank-Wojewódzki
- Re: Fuzzy Union in C++
- From: Dmitry A. Kazakov
- Re: Fuzzy Union in C++
- From: Seweryn Habdank-Wojewódzki
- Re: Fuzzy Union in C++
- From: Dmitry A. Kazakov
- Re: Fuzzy Union in C++
- From: Seweryn Habdank-Wojewódzki
- Re: Fuzzy Union in C++
- From: Dmitry A. Kazakov
- Re: Fuzzy Union in C++
- From: Seweryn Habdank-Wojewódzki
- Re: Fuzzy Union in C++
- From: Dmitry A. Kazakov
- Re: Fuzzy Union in C++
- Prev by Date: Re: Fuzzy Union in C++
- Next by Date: Re: Fuzzy Union in C++
- Previous by thread: Re: Fuzzy Union in C++
- Next by thread: Re: Fuzzy Union in C++
- Index(es):