 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Harald Nowak Guest
|
Posted: Wed Apr 07, 2004 7:41 pm Post subject: C++ Templates - feelings honestly expressed |
|
|
As a long term C++ user (and aficionado) the feeling starts to creep
upon me, that the usage of templates in C++ seems to go totally
overboard. Many programmers I talked to pointed out to me, that they
are not willing to invest any further in that language, since the
template mechanisms, especially the more and more widespread meta
programming techniques, do obfuscate the code in a way that makes it
nearly impossible to read and understand for the average coder. Don't
get me wrong on that: templates are senseful! Even Java has finally
found its way to a sensible (and senseful) use of templates to ensure
typesafe programming. But, as I said: even I, a seasoned C++
programmer, start having trouble to decipher and understand C++
template code - there are times when I am reading C++ Library docs and
have to read them over and over again, until I get a slight grasp of
how I have to use them, ALL because of the usage of template
mechanisms they make. Many former die-hard C++ programmers have
already left the C++ train and jumped upon the Java train because of
that very reason.
What do you say - isn't there a real danger of loosing steam (and
market shares) for C++ because of that template (mis)use?! Any
opinions welcome!
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Thomas A. Horsley Guest
|
Posted: Thu Apr 08, 2004 10:48 am Post subject: Re: C++ Templates - feelings honestly expressed |
|
|
| Quote: | What do you say - isn't there a real danger of loosing steam (and
market shares) for C++ because of that template (mis)use?! Any
opinions welcome!
|
I know nothing about market share, but I do know I've learned how
to make template code readable (for me anyway):
I happen to think Ada's concept of "instantiating" generics makes a lot of
sense, so I do something similar with C++ templates. Whenever I need to use
something like a template class, I make a typedef with a sensible name I can
use in place of something that looks like <<ba><r>::<!>>>$#@!
(C++ template syntax is still more readable than common lisp macros
though .
Of course that doesn't solve my biggest objection to lack of explicit
instantiation: You can accidentally pass the wrong argument to a function,
and "shazam!" behind your back some template function you didn't even
realize existed gets instantiated, the program compiles with no errors and
just does some totally weird and unexpected thing, and it is weeks before
you figure out what is going on.
| Quote: | there are times when I am reading C++ Library docs and
have to read them over and over again, until I get a slight grasp of
how I have to use them, ALL because of the usage of template
mechanisms they make.
|
I think the problem here is more the manuals than the templates. Has anyone
yet published a good modern C++ book that utterly ignores the existance of
all the old variations of C++ libraries and non-standard pre-release
template libraries? I keep wanting a good book I can use to make sure I
write standard conforming programs, but everywhere I look all the books
continue to document all sorts of backward compatible versions of streams
libraries, and template classes that aren't in the STL but might be someday,
etc. I don't want this stuff in the book - I want a book that no matter
where I look, I'll only see standard conforming information .
--
| Quote: | ==>> The *Best* political site <URL:http://www.vote-smart.org/> >>==+
email: [email]Tom.Horsley (AT) worldnet (DOT) att.net[/email] icbm: Delray Beach, FL | |
<URL:http://home.att.net/~Tom.Horsley> Free Software and Politics <<==+
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Andreas Huber Guest
|
Posted: Thu Apr 08, 2004 10:50 am Post subject: Re: C++ Templates - feelings honestly expressed |
|
|
Harald Nowak wrote:
| Quote: | As a long term C++ user (and aficionado) the feeling starts to creep
upon me, that the usage of templates in C++ seems to go totally
overboard. Many programmers I talked to pointed out to me, that they
are not willing to invest any further in that language, since the
template mechanisms, especially the more and more widespread meta
programming techniques, do obfuscate the code in a way that makes it
nearly impossible to read and understand for the average coder.
|
You seem to suggest that an average coder should be able to understand all
code written in a particular language. Moreover, if that is no longer the
case, you seem to suggest, the language is broken in some sense and should
be abandoned. I've heard that logic for several times now and I really don't
see why programmers think this way.
For non-templated libraries in any language, programmers readily accept that
they often cannot even get hold of the implementation source code. Even if
they can, I very much doubt that the average programmer would be able to
readily understand complex libraries like e.g. for regular expressions.
Sure, everyone *can* read such code and, on a very low level, explain what's
happening (add x to this variable, take this substring and add it to that
string, etc.). However, it's an altogether different matter to explain
what's happening on a much higher level. Code has been like this for decades
and programmers have been accepting that they cannot understand everything.
Note that it's exactly the same situation for template metaprogramming code,
many programmers can explain what's happening on a very low level
(specialize this template for the case when the type is equal to that type,
etc.) but most fail to explain what a complex metaprogramming construct is
good for on a much higher level.
The only thing what an average programmer should be able to grok is how to
*use* a templated *interface* but I fail to see why people think they must
also be able understand all the metaprogramming wizardry hidden behind that
interface.
| Quote: | Don't
get me wrong on that: templates are senseful! Even Java has finally
found its way to a sensible (and senseful) use of templates to ensure
typesafe programming. But, as I said: even I, a seasoned C++
programmer, start having trouble to decipher and understand C++
template code - there are times when I am reading C++ Library docs and
have to read them over and over again, until I get a slight grasp of
how I have to use them, ALL because of the usage of template
mechanisms they make.
|
I'd say that the library is probably badly designed and/or documented.
Please provide an example.
[snip]
Regards,
Andreas
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
David Abrahams Guest
|
Posted: Thu Apr 08, 2004 10:52 am Post subject: Re: C++ Templates - feelings honestly expressed |
|
|
[email]Harald.Nowak (AT) web (DOT) de[/email] (Harald Nowak) writes:
| Quote: | As a long term C++ user (and aficionado) the feeling starts to creep
upon me, that the usage of templates in C++ seems to go totally
overboard. Many programmers I talked to pointed out to me, that they
are not willing to invest any further in that language, since the
template mechanisms, especially the more and more widespread meta
programming techniques, do obfuscate the code in a way that makes it
nearly impossible to read and understand for the average coder. Don't
get me wrong on that: templates are senseful! Even Java has finally
found its way to a sensible (and senseful) use of templates to ensure
typesafe programming. But, as I said: even I, a seasoned C++
programmer, start having trouble to decipher and understand C++
template code - there are times when I am reading C++ Library docs and
have to read them over and over again, until I get a slight grasp of
how I have to use them, ALL because of the usage of template
mechanisms they make. Many former die-hard C++ programmers have
already left the C++ train and jumped upon the Java train because of
that very reason.
What do you say - isn't there a real danger of loosing steam (and
market shares) for C++ because of that template (mis)use?! Any
opinions welcome!
|
Templates can be used for good or evil. With power comes
responsibility. Some of the heaviest template code in libraries is
used to make efficient programs far _more_ readable. See for example
the two Finite State Machine examples attached to
http://article.gmane.org/gmane.comp.lib.boost.devel/35273, and
consider everything preceding the declaration of class player to be
part of the FSM library framework. The language used for describing
the player FSM to the library is almost a direct transcription of the
state transition table you might write when building it by hand.
There are numerous other examples of such domain-specific embedded
languages, c.f. Boost.Lambda, which allows:
// print each element of a multiplied by pi
std::for_each(a.begin(), a.end(), std::cout << (_1 * 3.14159));
or Boost.Spirit ([url]http://spirit.sf.net)[/url], which allows one to easily
write parsers directly in C++ code.
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Marco Oman Guest
|
Posted: Thu Apr 08, 2004 6:02 pm Post subject: Re: C++ Templates - feelings honestly expressed |
|
|
| Quote: | As a long term C++ user (and aficionado) the feeling starts to creep
upon me, that the usage of templates in C++ seems to go totally
overboard. Many programmers I talked to pointed out to me, that they
are not willing to invest any further in that language, since the
template mechanisms, especially the more and more widespread meta
programming techniques, do obfuscate the code in a way that makes it
nearly impossible to read and understand for the average coder. Don't
get me wrong on that: templates are senseful!
|
I agree on the first part: things like Boost' MPL are
very hard to read and understand. But I do not see here a reason
to change the language I use to solve my problems. After all
templates obeys the rule "you do not pay for what you not use",
and so I can go on doing my work with the rest of the stuff as usual.
What may hurt me is that now I get a growing feel
of being unable to master a section of the language
(or perhaps is more correct to say a new family of patterns
supported by trhe language). This has (among the others)
two implications: one is simply self estimation, the
other is "quotation" on the job market. And could be
reduced to: shall I change language because it is easier
for me to be a 100% Java programmer rather than a 100% C++ one?
Okay, the question is put rather hard, the mood
culd rise flame wars, anyway I think hard-code template
programming is an area worth to be explored.
Even if I can't (because I do not have the time or
the functional programming background) to do it.
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Uwe Schnitker Guest
|
Posted: Thu Apr 08, 2004 6:11 pm Post subject: Re: C++ Templates - feelings honestly expressed |
|
|
[email]Harald.Nowak (AT) web (DOT) de[/email] (Harald Nowak) wrote in message news:<ceb032e9.0404070730.4130a66e (AT) posting (DOT) google.com>...
| Quote: | As a long term C++ user (and aficionado) the feeling starts to creep
upon me, that the usage of templates in C++ seems to go totally
overboard. Many programmers I talked to pointed out to me, that they
are not willing to invest any further in that language, since the
template mechanisms, especially the more and more widespread meta
programming techniques, do obfuscate the code in a way that makes it
nearly impossible to read and understand for the average coder.
|
Well, Stroustrup used to answer such claims with "When I introduced
classes into C++ (rsp. C with Classes), people complained about how
useless, complicated and difficult to use they were". I think he's
right on that, and something like "nearly impossible to read and
understand for the average coder" might have been written then, too.
Ok, it is a bit worse wrt. templates, since they are a bit more
difficult to read - not because they were designed badly, and not
just because of overuse, but because the syntax design space for
them was more limited.
| Quote: | Don't
get me wrong on that: templates are senseful! Even Java has finally
found its way to a sensible (and senseful) use of templates to ensure
typesafe programming. But, as I said: even I, a seasoned C++
programmer, start having trouble to decipher and understand C++
template code - there are times when I am reading C++ Library docs and
have to read them over and over again, until I get a slight grasp of
how I have to use them, ALL because of the usage of template
mechanisms they make.
|
Well, many seasoned C programmers had the same problem when switching
to classic C++.
People who learned C++ in the last few years - and were not spoiled
by to much Java exposure before - have considerably fewer such
problems.
Modern C++ is a different, and IMHO far better, language than
classic C++.
| Quote: | Many former die-hard C++ programmers have
already left the C++ train and jumped upon the Java train because of
that very reason.
|
Many former C++ -> Java switchers are coming back to C++ because
it has evolved into such a wonderful language.
| Quote: | What do you say - isn't there a real danger of loosing steam (and
market shares) for C++ because of that template (mis)use?! Any
opinions welcome!
|
IMHO, the biggest problem is the lacklustre support for modern C++
programming styles offered by todays tools. Debugging tools get
better, but leave much to be desired. "Class Browsers", as their
name already implies, don't get along well with free functions -
a must with templates - and code completion is weak with them, and
refactoring tools which are template-savvy - e.g. allowing
almost-common code to be refactored into template functions - are
not even on the radar screen yet.
Today, tools have far more problems with templates code than
programmers. Don't get me wrong, todays tools can process template
code quite well, but they fail to present it to programmers in
a really enabling way. Since for todays projects the scope often
is very large, so that tool support for programmer insight is
crucial, this is the real bottleneck.
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
kanze@gabi-soft.fr Guest
|
Posted: Thu Apr 08, 2004 6:16 pm Post subject: Re: C++ Templates - feelings honestly expressed |
|
|
[email]Harald.Nowak (AT) web (DOT) de[/email] (Harald Nowak) wrote in message
news:<ceb032e9.0404070730.4130a66e (AT) posting (DOT) google.com>...
| Quote: | As a long term C++ user (and aficionado) the feeling starts to creep
upon me, that the usage of templates in C++ seems to go totally
overboard.
|
It's the current "in" thing. When I first started C++, OO was the
current "in" thing, and the usage of virtual functions and derivation
went totally overboard.
Both templates and virtual functions are useful tools. I'd hate to be
without them. That doesn't mean that the are the solution to
everything, or that they should be used everywhere. People being what
they are, however, whatever happens to be "in" will be abused and
overused. It's not a C++ problem, and there's not much C++ can do about
it.
| Quote: | Many programmers I talked to pointed out to me, that they are not
willing to invest any further in that language, since the template
mechanisms, especially the more and more widespread meta programming
techniques, do obfuscate the code in a way that makes it nearly
impossible to read and understand for the average coder.
|
It's certain that experimental coding techniques will not be understood
by those unfamiliar with them. And that before introducing them in a
project, you really do need to do a costs-benefits analysis --
retraining programmers to be familiar with them may be a lot of cost for
relatively little gain. Or a big gain, if you happen to need the new
techniques -- it all depends.
Long term, you have to program some sort of evolution, or you'll be left
behind. OO had similar problems 10 or 15 years ago, and any number of
programmers refused to consider it because it obfuscated code. (When
you write p->f(), who knows what function actually gets called. It's
worse than generic programming, really, because the answer can't be
determined by any amount of static analysis.)
IMHO, we are right at the beginning of the learning curve with regards
to generic programming. Something like where we were 25 or 30 years ago
with OO. Which means that intensive generic programming probably isn't
appropriate for most mainline applications. Yet. (Which doesn't mean
that you can't use third party libraries which use extensive generic
progrramming in their implementation.)
| Quote: | Don't get me wrong on that: templates are senseful! Even Java has
finally found its way to a sensible (and senseful) use of templates to
ensure typesafe programming. But, as I said: even I, a seasoned C++
programmer, start having trouble to decipher and understand C++
template code - there are times when I am reading C++ Library docs and
have to read them over and over again, until I get a slight grasp of
how I have to use them, ALL because of the usage of template
mechanisms they make.
|
That sounds like a problem with the library documentation. I, and my
collegues, don't do much generic programming ourselves, but we have no
trouble using std::vector.
| Quote: | Many former die-hard C++ programmers have already left the C++ train
and jumped upon the Java train because of that very reason.
|
And many former C programmers still stick with C. New technologies
introduce new challenges. One of the real advantages of C++ is its
backwards compatibility -- you can move into the new technologies
gradually. If you don't want to abord intensive generic programming
just yet, you don't have to. But you can play around with it in some
non-critical parts of the code without changing languages.
(And I have a great deal of problems understanding the move to Java. I
gave Java a try, and have pretty much left it because it doesn't support
any real OO.)
| Quote: | What do you say - isn't there a real danger of loosing steam (and
market shares) for C++ because of that template (mis)use?! Any
opinions welcome!
|
I often think that C++ is moving to quickly. I think that there is room
for discussion concerning the speed. But move it must, or it will die.
Personally, I think that after a short hiatus due to the Java mode, C++
is back in the driver's seat. It isn't gaining users at the rate it
initially did, simply because there aren't that many users left to gain;
I can't imagine a professional programmer today not being competent in
C++. Not necessarily mastering all of the subtilities, perhaps, but
capable of writing robust, working programs without too much problem.
IMHO, most of the problems with C++ are due to the past, and not the
future. If I don't like meta-programming, I can use C++ without it. If
I find the rules of operator overloading too complex (I do), then I just
avoid overloading functions which have different semantics, so the
results of overload resolution cannot affect the correctness of the
program. On the other hand, don't get me started about the
preprocessor or the declaration syntax.
--
James Kanze GABI Software mailto:kanze (AT) gabi-soft (DOT) fr
Conseils en informatique orientée objet/ http://www.gabi-soft.fr
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Ben Hutchings Guest
|
Posted: Fri Apr 09, 2004 12:12 am Post subject: Re: C++ Templates - feelings honestly expressed |
|
|
Thomas A. Horsley wrote:
<snip>
| Quote: | I think the problem here is more the manuals than the templates. Has anyone
yet published a good modern C++ book that utterly ignores the existance of
all the old variations of C++ libraries and non-standard pre-release
template libraries?
snip |
I think that's exactly what Josuttis's book does:
<http://www.josuttis.com/libbook/>. I haven't read it but it is
highly recommended by others.
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Walt Karas Guest
|
Posted: Fri Apr 09, 2004 12:31 am Post subject: Re: C++ Templates - feelings honestly expressed |
|
|
The vast majority of the hard-to-follow code I've seen was the result
of apathy or poor impulse control: the author just didn't want to
spend the time thinking about strategies/approaches to make the code
more compact, organized and comprehensible. I've worked in several
progamming languages, but have yet to see one that prevents the
writing of hard-to-follow code. When code is hard to follow because
the author uses different strategies/approaches than those you are
familiar with, at least you get the mental stimulation of learing
something new, whether you adopt it or not.
My reaction to most extreme preprocessor/template metaprogramming is
that I'd rather use a more powerful macro processor (like m4), or
a script or C++ program that generates C++ code. But alot of people
feel macros are inherently evil, and that code that generates code
is even more weird and objectionable than metaprogramming. They'd
rather just open their editor and dive into the multi-hour cut-and-
paste frenzy.
Ultimately, you just have to learn to tolerate it that what's being
done in the next cubicle may be different that what's being done in
yours. Any cure I know of for this would be far, far worse than the
disease.
When using the STL, I prefer to refer to C++PL or some other tutorial.
I only look at the standard as a last resort. You seem to feel this
is very undesirable, but I don't see why.
I also do not find the way the Standard specifies the contraints on
STL type parameters to be very intuitive. In a template I wrote for
the public domain (
http://www.geocities.com/wkaras/gen_cpp/avl_tree.html ), I used
"references classes" to specify the contraints, which doesn't force
the reader to learn alot of new notation.
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Nicholas Salerno Guest
|
Posted: Fri Apr 09, 2004 1:01 am Post subject: Re: C++ Templates - feelings honestly expressed |
|
|
[email]Harald.Nowak (AT) web (DOT) de[/email] (Harald Nowak) wrote in message news:<ceb032e9.0404070730.4130a66e (AT) posting (DOT) google.com>...
| Quote: | As a long term C++ user (and aficionado) the feeling starts to creep
upon me, that the usage of templates in C++ seems to go totally
overboard. Many programmers I talked to pointed out to me, that they
are not willing to invest any further in that language, since the
template mechanisms, especially the more and more widespread meta
programming techniques, do obfuscate the code in a way that makes it
nearly impossible to read and understand for the average coder. Don't
get me wrong on that: templates are senseful! Even Java has finally
found its way to a sensible (and senseful) use of templates to ensure
typesafe programming. But, as I said: even I, a seasoned C++
programmer, start having trouble to decipher and understand C++
template code - there are times when I am reading C++ Library docs and
have to read them over and over again, until I get a slight grasp of
how I have to use them, ALL because of the usage of template
mechanisms they make. Many former die-hard C++ programmers have
already left the C++ train and jumped upon the Java train because of
that very reason.
What do you say - isn't there a real danger of loosing steam (and
market shares) for C++ because of that template (mis)use?! Any
opinions welcome!
|
I have similiar feelings too. I like the metaprogramming (or
parametric programming to other) paradigm. It is interesting. I
thought that it would be great for numerical processing applications.
I did not want to be academic about it, I actually tried to use it at
work on real projects. For image procesing algorithms it showed some
promise. I started using it for some computer vision applications.
However, as you have stated, others do not want to invest into
something they did't know. Also, they did not want code that they
would have to maintain in the event I am no longer employed. It
didn't matter that the code worked and was efficient, they just didn't
know C++ templates. We are talking about C and/or C++ via MFC
programmers so I understood their concern.
However, as soon as I started to take C++ metaprogramming beyond
scientific applications and into general purpose applications I, just
like you, found heavy use of templates complicating the project. This
is not because of templates in general. I am sure that a clean
template language would handle the complexity of templates with good
syntax and grammar. The complications arouse from C++'s
implementation of templates. For example, I read the example on using
type lists to add visitor pattern behavior to an existing object
hierarchy. While I was able to understand after reading the article
three times, I can definitely see myself not knowing what that code is
doing six months from now. Of course one forgets all code not worked
on in six months time. What I am saying is that it would take longer
than normal to refresh myself. Now I understood my co-workers fear of
C++ templates at a deeper level.
Lastly, the more I did general application stuff, especially GUI
development, the more I was moving away from templates. I just found
them to be limiting in certain situations. For example, take
Microsoft's WTL library (not officially supported, something they were
experimenting with). The WTL library employs some modern template
idioms. The problem I had was that with templates everything is set
into stone at compile time. Also, types were defined based on other
types at compile time. At runtime, how do I have a list of widgets?
Say a parent has a list of all the child widgets? vector<CWidget*>?
Perhaps, but there is no such thing as a CWidget, but there is
CWidget<typename T>, thus an example would be "class CMyButton :
public CWindowImpl<CMyButton>" (iirc) to establish compile-time
polymorphism.
In conclusion, I have found templates to be great for some domains and
bad for other domains. I know that the template brigade will disagree
with me on that but that is my feeling and perhaps the feeling of many
others as well.
Nicholas
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Roland Pibinger Guest
|
Posted: Fri Apr 09, 2004 1:06 am Post subject: Re: C++ Templates - feelings honestly expressed |
|
|
On 7 Apr 2004 15:41:27 -0400, [email]Harald.Nowak (AT) web (DOT) de[/email] (Harald Nowak)
wrote:
| Quote: | As a long term C++ user (and aficionado) the feeling starts to creep
upon me, that the usage of templates in C++ seems to go totally
overboard. Many programmers I talked to pointed out to me, that they
are not willing to invest any further in that language, since the
template mechanisms, especially the more and more widespread meta
programming techniques, do obfuscate the code in a way that makes it
nearly impossible to read and understand for the average coder. Don't
get me wrong on that: templates are senseful! Even Java has finally
found its way to a sensible (and senseful) use of templates to ensure
typesafe programming. But, as I said: even I, a seasoned C++
programmer, start having trouble to decipher and understand C++
template code - there are times when I am reading C++ Library docs and
have to read them over and over again, until I get a slight grasp of
how I have to use them, ALL because of the usage of template
mechanisms they make. Many former die-hard C++ programmers have
already left the C++ train and jumped upon the Java train because of
that very reason.
What do you say - isn't there a real danger of loosing steam (and
market shares) for C++ because of that template (mis)use?! Any
opinions welcome!
|
In general I agree with you. It is amazing that some people put so
much effort into this area. But you should distinguish between
real-world and experimental (b)leading-edge programming. One month ago
Scott Meyers wrote in this newsgroup:
"As a general rule, Boost has very little visibility, the Standard not
much more (many programmers make no distinction between the behavior
of their compiler and the behavior dictated by the Standard), and the
STL (which everybody has *heard* of) is still viewed as largely
foreign territory".
So, template "obfuscations" are not recognized by the average C++
programmer. Boost e.g. essentially produces libraries from specialists
for specialists. Mainstream programmers will not accept this amount of
complexity.
Best regards,
Roland Pibinger
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Hyman Rosen Guest
|
Posted: Fri Apr 09, 2004 1:21 am Post subject: Re: C++ Templates - feelings honestly expressed |
|
|
Marco Oman wrote:
| Quote: | shall I change language because it is easier
for me to be a 100% Java programmer rather than a 100% C++ one?
|
You won't be. If you had the capacity to be a 100% Java programmer
then you would have the capacity to be a 100% C++ programmer, and
vice versa.
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Le Chaud Lapin Guest
|
Posted: Fri Apr 09, 2004 1:30 am Post subject: Re: C++ Templates - feelings honestly expressed |
|
|
[email]Harald.Nowak (AT) web (DOT) de[/email] (Harald Nowak) wrote in message news:<ceb032e9.0404070730.4130a66e (AT) posting (DOT) google.com>...
| Quote: | As a long term C++ user (and aficionado) the feeling starts to creep
upon me, that the usage of templates in C++ seems to go totally
overboard. [snippage]
|
I agree. Mind you, I am not one to insist that everyone use handsaws
because some lumberjack accidentally cut his hand of with a chainsaw,
but I do see that there is great imbalance in writing template code.
I recently made a post in this group asking for a Monarchy<>
Polyarchy<> classes. Apparently, they do not exist in the STL.
That's odd, considering how fundamental tree structures are in
programming.
Far more important than exercising one's wizardry to make the most
masssive, all-encompassing, unintuitive templates possible; is first
finding balance in the *basic* set of template classes generally
offered.
But templates are not the only constructs that suffer from this
problem. These days, virtual functions too are abused to a sickening
degree, and often, the coder has no real reason other than lack of
forethought to make all 23 functions of a class virtual. S/he is
merely exercising his/her right to participate in the
"Hey-Dad-Watch-Me-Use-Virtual-Functions" club.
I think this behavior might be underlying some of the template abuse.
*Some* complexity is inevitable in templates, but I think a lot of it
is people just trying to express themselves through code.
-Chaud Lapin-
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Stefan Slapeta Guest
|
Posted: Fri Apr 09, 2004 11:28 am Post subject: Re: C++ Templates - feelings honestly expressed |
|
|
Harald Nowak wrote:
| Quote: | Even Java has finally
found its way to a sensible (and senseful) use of templates to ensure
typesafe programming.
|
What in particular makes you think the concept of templates in Java is
better than in C++?
| Quote: | But, as I said: even I, a seasoned C++
programmer, start having trouble to decipher and understand C++
template code - there are times when I am reading C++ Library docs and
have to read them over and over again, until I get a slight grasp of
how I have to use them, ALL because of the usage of template
mechanisms they make.
|
I think there are two reasons for your observance: First of all, the
documentation, which is far away from being perfect in many libraries
because they have been written in quite a short time where documentation
didn't have the priority it should.
Secondly: Generic programming is no easy concept and templates are just
the tool for it! I would say, it usually takes months and years to think
"generically", and I'm sure it takes longer than getting familiar with
OO. But it's always fascinating! (...except you try to learn all about
templates within one day.)
| Quote: | Many former die-hard C++ programmers have
already left the C++ train and jumped upon the Java train because of
that very reason.
|
Only a fool can change from C++ to Java because of templates. If you
have a look at industrial trends, the opposite is the case: many who had
proudly jumped on the Java train now come back to 'conventional'
languages for several reasons.
| Quote: | What do you say - isn't there a real danger of loosing steam (and
market shares) for C++ because of that template (mis)use?!
|
Why so? Who is forced to use templates if he doesn't want to?
<cynism>
There are still many people who write C++ code that differs from C just
in the ending of the source file, I don't think many of them are scared
because they don't know anything about templates, either :-O
</cynism>
S.
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Stefan Slapeta Guest
|
Posted: Fri Apr 09, 2004 11:38 am Post subject: Re: C++ Templates - feelings honestly expressed |
|
|
Thomas A. Horsley wrote:
| Quote: | I don't want this stuff in the book - I want a book that no matter
where I look, I'll only see standard conforming information .
|
It seems what you are looking for is a book named
"ISO/IEC 14882:2003 Programming Language C++", also known as
"The C++ Standard".
S.
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|