What I like most about C++

J

JohnQ

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
 
M

Me

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<string> stack_of_strings;
vector<float> some_floats;
class my_class;
map<int, my_class> my_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. :^)
 
I

Ian Collins

JohnQ said:
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.
 
S

Salt_Peter

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.
 
J

JohnQ

Me said:
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.



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.



Vanilla, as they should be...



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<string> stack_of_strings;
vector<float> some_floats;
class my_class;
map<int, my_class> my_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
 
J

JohnQ

Salt_Peter said:
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
 
M

MathStuf

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
 
J

James Kanze

"Me" <[email protected]> wrote 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.
 
L

Lionel B

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.
 
J

JohnQ

MathStuf said:
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
 
J

JohnQ

Lionel B said:
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
 
C

Clark Cox

Lionel B said:
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"
 
J

JohnQ

Clark Cox said:
Lionel B said:
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
 
S

Salt_Peter

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.
 
J

JohnQ

Salt_Peter said:
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
 
J

Jon Harrop

Salt_Peter said:
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...
 
V

Victor Bazarov

Jon said:
[..]
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top