By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,904 Members | 1,302 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,904 IT Pros & Developers. It's quick & easy.

What I like most about C++

P: n/a
Is that I can approximate using my ideal of a language in it. On the flip
side, what I dislike most about it is all the
flak/protecting-the-golden-calf one gets when using it that way.

I think a lot of the template discussions are like talking about .net or
similar and that brain power is being wasted along with progress. For
instance, when I see examples given in solution of a problem and then I see
that the code is template-based, I ignore it.

I have a good analogy of how templates strike me (read, "the flavor of
templates"): Remember when Indy car racing was turbo charged? Yeah, all the
development was going into turbos instead of engines. I think templates are
having similar effect on C++. Give me well-designed naturally aspirated
instead of
exploding/heat-producing/back-pressure-producing/complexity-introducing
turbos any day!

John
May 24 '07 #1
Share this Question
Share on Google+
17 Replies


P: n/a
Me
On Thu, 24 May 2007 03:56:16 +0000, Noone wrote:
Is that I can approximate using my ideal of a language in it. On the
flip side, what I dislike most about it is all the
flak/protecting-the-golden-calf one gets when using it that way.
Use it whatever way works for YOU. Just keep in mind that modern
programming paradigms are suppose to encourage code being easily
supported by others and being reusable.

I think a lot of the template discussions are like talking about .net or
similar and that brain power is being wasted along with progress. For
instance, when I see examples given in solution of a problem and then I
see that the code is template-based, I ignore it.
Just my humble opinion, but if you ignore template based code out of hand
then you are not fully appreciating the strength of the language.

I have a good analogy of how templates strike me (read, "the flavor of
templates"):
Vanilla, as they should be...

Remember when Indy car racing was turbo charged? Yeah, all
the development was going into turbos instead of engines. I think
templates are having similar effect on C++. Give me well-designed
naturally aspirated instead of
exploding/heat-producing/back-pressure-producing/complexity-introducing
turbos any day!
If c++ didn't have template capabilities then my current project would be
six or seven times as large as it needs to be because of all the custom
operations I would have to reimplement for specific data types.

stack<stringstack_of_strings;
vector<floatsome_floats;
class my_class;
map<int, my_classmy_map;

Now think about all the code writing I saved instead of having to
implement each of the above for each specific data type I wanted to
collect. Not to mention, string is itself a template class. Are you
saying that you won't use the string class because it is implemented using
templates?

This is stuff that colleges should be giving students an appreciation
for. If they aren't then the schools are not doing their job.
My appologies to the regulars for not resisting feeding of the trolls. :^)
May 24 '07 #2

P: n/a
JohnQ wrote:
Is that I can approximate using my ideal of a language in it. On the flip
side, what I dislike most about it is all the
flak/protecting-the-golden-calf one gets when using it that way.
Your trolls are becoming tedious.

--
Ian Collins.
May 24 '07 #3

P: n/a
On May 23, 11:56 pm, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
Is that I can approximate using my ideal of a language in it. On the flip
side, what I dislike most about it is all the
flak/protecting-the-golden-calf one gets when using it that way.

I think a lot of the template discussions are like talking about .net or
similar and that brain power is being wasted along with progress. For
instance, when I see examples given in solution of a problem and then I see
that the code is template-based, I ignore it.

I have a good analogy of how templates strike me (read, "the flavor of
templates"): Remember when Indy car racing was turbo charged? Yeah, all the
development was going into turbos instead of engines. I think templates are
having similar effect on C++. Give me well-designed naturally aspirated
instead of
exploding/heat-producing/back-pressure-producing/complexity-introducing
turbos any day!

John
Nobody forces you to templatize anything or everything.
I fail to see what you find turbo-ish about templates. They are
relatively simple and a tiny effort affords you many, many dividends.
It just doesn't make sense to redesign a car from scratch just cause
you changed the fuel or the race has new specs. Thats folly.

A wheel is a wheel, whether aluminum or some other alloy is involved,
its still a wheel.
If the design changes, its still a wheel.
If its profile changes, its still a wheel.
Now lets suppose you have 100 materials, 10 profiles and 700
designs...

Is your arguement that the effort of writing 700,000 wheel structures
doesn't beg for a template?
How many more materials, profiles and designs will be added tommorrow?
After all, thats the ultimate goal of a template.
It works with anything, including what doesn't exist yet.

May 24 '07 #4

P: n/a

"Me" <no***@all.comwrote in message
news:pa*********************@all.com...
On Thu, 24 May 2007 03:56:16 +0000, Noone wrote:
>Is that I can approximate using my ideal of a language in it. On the
flip side, what I dislike most about it is all the
flak/protecting-the-golden-calf one gets when using it that way.

Use it whatever way works for YOU. Just keep in mind that modern
programming paradigms are suppose to encourage code being easily
supported by others and being reusable.

>I think a lot of the template discussions are like talking about .net or
similar and that brain power is being wasted along with progress. For
instance, when I see examples given in solution of a problem and then I
see that the code is template-based, I ignore it.

Just my humble opinion, but if you ignore template based code out of hand
then you are not fully appreciating the strength of the language.

>I have a good analogy of how templates strike me (read, "the flavor of
templates"):

Vanilla, as they should be...

>Remember when Indy car racing was turbo charged? Yeah, all
the development was going into turbos instead of engines. I think
templates are having similar effect on C++. Give me well-designed
naturally aspirated instead of
exploding/heat-producing/back-pressure-producing/complexity-introducing
turbos any day!

If c++ didn't have template capabilities then my current project would be
six or seven times as large as it needs to be because of all the custom
operations I would have to reimplement for specific data types.

stack<stringstack_of_strings;
vector<floatsome_floats;
class my_class;
map<int, my_classmy_map;

Now think about all the code writing I saved instead of having to
implement each of the above for each specific data type I wanted to
collect. Not to mention, string is itself a template class. Are you
saying that you won't use the string class because it is implemented using
templates?

This is stuff that colleges should be giving students an appreciation
for. If they aren't then the schools are not doing their job.
Templates are fine for containers and algorithms, but I like to keep them
for that only.

John
May 25 '07 #5

P: n/a

"Salt_Peter" <pj*****@yahoo.comwrote in message
news:11*********************@o5g2000hsb.googlegrou ps.com...
On May 23, 11:56 pm, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
>Is that I can approximate using my ideal of a language in it. On the flip
side, what I dislike most about it is all the
flak/protecting-the-golden-calf one gets when using it that way.

I think a lot of the template discussions are like talking about .net or
similar and that brain power is being wasted along with progress. For
instance, when I see examples given in solution of a problem and then I
see
that the code is template-based, I ignore it.

I have a good analogy of how templates strike me (read, "the flavor of
templates"): Remember when Indy car racing was turbo charged? Yeah, all
the
development was going into turbos instead of engines. I think templates
are
having similar effect on C++. Give me well-designed naturally aspirated
instead of
exploding/heat-producing/back-pressure-producing/complexity-introducing
turbos any day!

John

Nobody forces you to templatize anything or everything.
I fail to see what you find turbo-ish about templates.
Too much emphasis on them.

John
May 25 '07 #6

P: n/a

"Ian Collins" <ia******@hotmail.comwrote in message
news:5b*************@mid.individual.net...
JohnQ wrote:
>Is that I can approximate using my ideal of a language in it. On the flip
side, what I dislike most about it is all the
flak/protecting-the-golden-calf one gets when using it that way.
Your trolls are becoming tedious.
If you don't like out-of-the-box thinking, don't read my posts

John
May 25 '07 #7

P: n/a
On May 24, 10:21 pm, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
"Salt_Peter" <pj_h...@yahoo.comwrote in message

news:11*********************@o5g2000hsb.googlegrou ps.com...
On May 23, 11:56 pm, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
Is that I can approximate using my ideal of a language in it. On the flip
side, what I dislike most about it is all the
flak/protecting-the-golden-calf one gets when using it that way.
I think a lot of the template discussions are like talking about .net or
similar and that brain power is being wasted along with progress. For
instance, when I see examples given in solution of a problem and then I
see
that the code is template-based, I ignore it.
I have a good analogy of how templates strike me (read, "the flavor of
templates"): Remember when Indy car racing was turbo charged? Yeah, all
the
development was going into turbos instead of engines. I think templates
are
having similar effect on C++. Give me well-designed naturally aspirated
instead of
exploding/heat-producing/back-pressure-producing/complexity-introducing
turbos any day!
John
Nobody forces you to templatize anything or everything.
I fail to see what you find turbo-ish about templates.

Too much emphasis on them.

John
So ignore it. If someone wants to write their own code using
templates, let them, but don't think that because YOU don't like/use a
feature of a language, that it should be banished from the language.

--MathStuf

May 25 '07 #8

P: n/a
On May 25, 4:21 am, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
"Me" <n...@all.comwrote in message
Templates are fine for containers and algorithms, but I like
to keep them for that only.
And smart pointers, and any number of other things.

They're a tool. Use them when they make the code more readable
and easier to maintain. I avoid them when they make the code
less readable and harder to maintain. Having used C++ before
templates (and having written containers and smart pointers
using <generic.h>), I certainly don't want to go back.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

May 25 '07 #9

P: n/a
On Thu, 24 May 2007 03:56:16 +0000, JohnQ wrote:
Is that I can approximate using my ideal of a language in it. On the
flip side, what I dislike most about it is all the
flak/protecting-the-golden-calf one gets when using it that way.
[snip JohnQ stock anti-template rant]

Ok, you have issues with templates in C++. Here's what to do:

(1) Don't use templates.

(2) Stop trolling c.l.c++ with tedious anti-template rants.

--
Lionel B
May 25 '07 #10

P: n/a

"MathStuf" <Ma******@gmail.comwrote in message
news:11**********************@w5g2000hsg.googlegro ups.com...
On May 24, 10:21 pm, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
>"Salt_Peter" <pj_h...@yahoo.comwrote in message

news:11*********************@o5g2000hsb.googlegro ups.com...
On May 23, 11:56 pm, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
Nobody forces you to templatize anything or everything.
I fail to see what you find turbo-ish about templates.

Too much emphasis on them.

John

So ignore it. If someone wants to write their own code using
templates, let them, but don't think that because YOU don't like/use a
feature of a language, that it should be banished from the language.
I wasn't suggesting that.

John
May 25 '07 #11

P: n/a

"Lionel B" <me@privacy.netwrote in message
news:f3**********@south.jnrs.ja.net...
On Thu, 24 May 2007 03:56:16 +0000, JohnQ wrote:
>Is that I can approximate using my ideal of a language in it. On the
flip side, what I dislike most about it is all the
flak/protecting-the-golden-calf one gets when using it that way.

[snip JohnQ stock anti-template rant]

Ok, you have issues with templates in C++. Here's what to do:

(1) Don't use templates.

(2) Stop trolling c.l.c++ with tedious anti-template rants.
The original post included the templates thoughts as an aside.

John
May 25 '07 #12

P: n/a
On 2007-05-25 15:23:40 -0700, "JohnQ"
<jo***********************@yahoo.comsaid:
>
"Lionel B" <me@privacy.netwrote in message
news:f3**********@south.jnrs.ja.net...
>On Thu, 24 May 2007 03:56:16 +0000, JohnQ wrote:
>>Is that I can approximate using my ideal of a language in it. On the
flip side, what I dislike most about it is all the
flak/protecting-the-golden-calf one gets when using it that way.

[snip JohnQ stock anti-template rant]

Ok, you have issues with templates in C++. Here's what to do:

(1) Don't use templates.

(2) Stop trolling c.l.c++ with tedious anti-template rants.

The original post included the templates thoughts as an aside.
11 of the 14 lines in the original post were about templates and your
dislike of them. I'd hardly call that "an aside"

--
Clark S. Cox III
cl*******@gmail.com

May 26 '07 #13

P: n/a

"Clark Cox" <cl*******@gmail.comwrote in message
news:200705251709338930-clarkcox3@gmailcom...
On 2007-05-25 15:23:40 -0700, "JohnQ"
<jo***********************@yahoo.comsaid:
>>
"Lionel B" <me@privacy.netwrote in message
news:f3**********@south.jnrs.ja.net...
>>On Thu, 24 May 2007 03:56:16 +0000, JohnQ wrote:

Is that I can approximate using my ideal of a language in it. On the
flip side, what I dislike most about it is all the
flak/protecting-the-golden-calf one gets when using it that way.

[snip JohnQ stock anti-template rant]

Ok, you have issues with templates in C++. Here's what to do:

(1) Don't use templates.

(2) Stop trolling c.l.c++ with tedious anti-template rants.

The original post included the templates thoughts as an aside.

11 of the 14 lines in the original post were about templates and your
dislike of them. I'd hardly call that "an aside"
It was an aside because I said it was. That the primary point drifted
tangented toward templates makes sense because that's where one can get a
lot of the "flak" mentioned. I think the turbo analogy was one of the better
fitting ones put forth, though.

John
May 26 '07 #14

P: n/a
On May 24, 10:21 pm, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
"Salt_Peter" <pj_h...@yahoo.comwrote in message

news:11*********************@o5g2000hsb.googlegrou ps.com...
On May 23, 11:56 pm, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
Is that I can approximate using my ideal of a language in it. On the flip
side, what I dislike most about it is all the
flak/protecting-the-golden-calf one gets when using it that way.
I think a lot of the template discussions are like talking about .net or
similar and that brain power is being wasted along with progress. For
instance, when I see examples given in solution of a problem and then I
see
that the code is template-based, I ignore it.
I have a good analogy of how templates strike me (read, "the flavor of
templates"): Remember when Indy car racing was turbo charged? Yeah, all
the
development was going into turbos instead of engines. I think templates
are
having similar effect on C++. Give me well-designed naturally aspirated
instead of
exploding/heat-producing/back-pressure-producing/complexity-introducing
turbos any day!
John
Nobody forces you to templatize anything or everything.
I fail to see what you find turbo-ish about templates.

Too much emphasis on them.
I wonder why?
Try writing a void foo( /*parameter&*/ ) where parameter is any type
conceivable. You'ld still be at your computer writing them by the time
you retire (and that function would by then become useless due to any
new user-types introduced). Yet the templated version of the function
would work fine with any type/user-type including those that are
written *after* the template was designed (templates induce the
creator of the class to correctly design the user-types to match the
system).

Now what? templates make code simpler, manageable, expandeable,
reuseable, flexible, etc.

You need not agree with it, but that is reality. Suggesting otherwise
is folly. And suggesting that C++ should banish templates because
*you* prefer it that way is quite self-centered. Specially since you
need not use them.
Is your problem the fact that the template coder writes a piece of
code in 40 lines when it takes you 400? Only to find that any new type
needs another 400 lines? Is it *unfair* that the template coder gets
to focus on expanding his system/code while you continue to use cattle
to turn over the soil? Yes, it is unfair: the template coder is
earning the bucks that are required for you to continue coding
innefficiently.


May 26 '07 #15

P: n/a

"Salt_Peter" <pj*****@yahoo.comwrote in message
news:11**********************@w5g2000hsg.googlegro ups.com...
On May 24, 10:21 pm, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
>"Salt_Peter" <pj_h...@yahoo.comwrote in message

news:11*********************@o5g2000hsb.googlegro ups.com...
On May 23, 11:56 pm, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
Is that I can approximate using my ideal of a language in it. On the
flip
side, what I dislike most about it is all the
flak/protecting-the-golden-calf one gets when using it that way.
>I think a lot of the template discussions are like talking about .net
or
similar and that brain power is being wasted along with progress. For
instance, when I see examples given in solution of a problem and then
I
see
that the code is template-based, I ignore it.
>I have a good analogy of how templates strike me (read, "the flavor of
templates"): Remember when Indy car racing was turbo charged? Yeah,
all
the
development was going into turbos instead of engines. I think
templates
are
having similar effect on C++. Give me well-designed naturally
aspirated
instead of
exploding/heat-producing/back-pressure-producing/complexity-introducing
turbos any day!
>John
Nobody forces you to templatize anything or everything.
I fail to see what you find turbo-ish about templates.

Too much emphasis on them.

I wonder why?
Try writing a void foo( /*parameter&*/ ) where parameter is any type
conceivable. You'ld still be at your computer writing them by the time
you retire (and that function would by then become useless due to any
new user-types introduced). Yet the templated version of the function
would work fine with any type/user-type including those that are
written *after* the template was designed (templates induce the
creator of the class to correctly design the user-types to match the
system).

Now what? templates make code simpler, manageable, expandeable,
reuseable, flexible, etc.
When not overused, I agree.
You need not agree with it, but that is reality. Suggesting otherwise
is folly. And suggesting that C++ should banish templates because
*you* prefer it that way is quite self-centered.
I never suggested such.

John
May 27 '07 #16

P: n/a
Salt_Peter wrote:
Now what? templates make code simpler, manageable, expandeable,
reuseable, flexible, etc.
Here is a simple function in OCaml that nests "n" applications of "f"
around "x", with "n" defaulting to "n=2":

let rec nest ?(n=2) f x = if n=0 then x else nest ~n:(n-1) f (f x)

For example, "nest f x" gives "f(f(x))" and "nest ~n:3 f x"
gives "f(f(f(x)))".

The function is inferred to be generic. Write that in C++ using templates
such that it is any of "simpler, manageable, expandeable, reuseable,
flexible". I'll even add "faster" given that C++ lacks tail calls and
imposes unnecessarily-large stack frames.

The fact is, other languages have had better solutions to generics for
decades. Type inferred parametric polymorphism is a clear win. Statically-
resolved type classes are even better. Why anyone would continue fumbling
with templates is beyond me...

--
Dr Jon D Harrop, Flying Frog Consultancy
OCaml for Scientists
http://www.ffconsultancy.com/product...ntists/?usenet
May 30 '07 #17

P: n/a
Jon Harrop wrote:
[..]
The fact is, other languages have had better solutions to generics for
decades. Type inferred parametric polymorphism is a clear win.
Statically- resolved type classes are even better. Why anyone would
continue fumbling with templates is beyond me...
You're off-topic. Please go away.
May 30 '07 #18

This discussion thread is closed

Replies have been disabled for this discussion.