View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# What makes C++ so powerful?

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

148 replies to this topic

### #141snk_kid  Members

Posted 14 May 2006 - 11:12 PM

Somebody mentioned operator overloading, there is nothing wrong with it infact it can be one of the vital ingredients for the recipe of domain-specific embedded language (DSEL). The problem with C++'s operator overloading model is it's quite limited and functions are not first class so one must resort to hackery and expression templates to achieve DSEL combinator libraries in C++.

### #142Eelco  Members

Posted 14 May 2006 - 11:31 PM

Quote:
Original post by Cold_Steel
Quote:
 Original post by RagharC++ like operator overloading decreases source code predictability. Imagine situation when you can see. vector3D a = new vector3D(3D, 5D, 3D);c = a * b;And now tell me what is "c"? And what is the result of a * b?
That's not really fair. Bad code can be written in any language.

vector3D a = new vector3d(3D, 5D, 3D);
c = a.Multiply(b);

Is that any clearer? Of course not. I'd assume b is either another 3d vector or a matrix of the correct dimensions. C could be the cross product. Maybe the dot product. Maybe b is a magnitude, and c is the scaled vector. Maybe the result of a matrix transformation. Regardless, poorly written code is poorly written code.

Vector3d unitVec = new Vector3d(x,y,z);
scaledVec = unitVec * scale.

The source code is only as readable as the programmer is willing to make it.

fully agreed. code is as readable as you make it.

personally, i would like a language where defining functions is much more flexible: you should be able to give it any name, be it "+" or whatever, and you should be able to specify if it only takes arguments on its right hand side, or that it accepts arguments from both sides, or is used as an unary operator.

something like function := [arglist] = [arglist] "functionname" [arglist].

i believe python does something like that?

### #143snk_kid  Members

Posted 14 May 2006 - 11:51 PM

Quote:
 Original post by Eelcopersonally, i would like a language where defining functions is much more flexible: you should be able to give it any name, be it "+" or whatever, and you should be able to specify if it only takes arguments on its right hand side, or that it accepts arguments from both sides, or is used as an unary operator.something like function := [arglist] = [arglist] "functionname" [arglist].i believe python does something like that?

In haskell one can overload virtually any symbol with any number together (like +++ for instance) one can state the artery, associativity and precedence levels. Named functions can be made infix using quasi-quotes i.e 1 plus 2 is the same as plus 1 2, operators can be sectioned, all functions (including operators) are first-class so they can be passed/returned/stored. These are the reasons why haskell is so good for writing domain specific embedded languages (DSELs).

### #144CTar  Members

Posted 15 May 2006 - 01:17 AM

Quote:
 Original post by JustOwninDaFINALBOSSA programming language can be used to do anything.

No, not if it doesn't have support for it. For example C# 2.0 doesn't have much support for systems programming, and no Singularity (the OS you talked about) is not coded in C#, it's coded in Sing#, which is a superset of the Spec#, which is an extension of C#. Also 2 % of the kernel is written in asm and 3 % is written in C++. The system used by Sing# is called Bartok.

Quote:
 C++ is a balanced language and can be considered the best simply because of the legacy it is build. No other programming language is as documented, as source happy, and as analyzed as it.

Does this make C++ a good language? No, legacy is a reason to why one might choose C++, it doesn't make the language itself more powerful.

Quote:
 The fact of the matter is that it is the most widely used language out there, and it's one of the oldest. There is power in numbers. There is power in knowledge. Because of how programming works the most popular language becomes The most powerful language.

Yes, because your program suddenly gets much better when 10000 other programmers starts to program in the same language.

### #145CoffeeMug  Members

Posted 15 May 2006 - 02:11 AM

Quote:
 Original post by snk_kidPopularity is a pathetic heuristic to determine whether a programming language is any good/powerful/elegant/etc/etc. Java being a prime example of it (time to put on the old flame, bullet, and bomb proof vest).

Popularity is a pathetic heuristic to determine whether anything is good/powerful/elegant/etc/etc. Just turn on FM radio or pick up one of the romantic novels from the bestsellers section.

### #146CoffeeMug  Members

Posted 15 May 2006 - 02:16 AM

Quote:
 Original post by CTarDoes this make C++ a good language? No, legacy is a reason to why one might choose C++, it doesn't make the language itself more powerful.

There is certainly some value in popularity. Ability to hire reasonably proficient programmers for less than astronomic salaries. Large body of available libraries and documentation. Ability to get some support from public forums.

I'm playing a devil's advocate. I'd hire four Lisp programmers rather than ten Java programmers for the same total price any day.

### #147rohde  Members

Posted 15 May 2006 - 02:22 AM

Quote:
Original post by CTar
Quote:
 Original post by JustOwninDaFINALBOSSA programming language can be used to do anything.

No, not if it doesn't have support for it. For example C# 2.0 doesn't have much support for systems programming, and no Singularity (the OS you talked about) is not coded in C#, it's coded in Sing#, which is a superset of the Spec#, which is an extension of C#. Also 2 % of the kernel is written in asm and 3 % is written in C++. The system used by Sing# is called Bartok.

Quote:
 C++ is a balanced language and can be considered the best simply because of the legacy it is build. No other programming language is as documented, as source happy, and as analyzed as it.

Does this make C++ a good language? No, legacy is a reason to why one might choose C++, it doesn't make the language itself more powerful.

Quote:
 The fact of the matter is that it is the most widely used language out there, and it's one of the oldest. There is power in numbers. There is power in knowledge. Because of how programming works the most popular language becomes The most powerful language.

Yes, because your program suddenly gets much better when 10000 other programmers starts to program in the same language.

No the langueage itself does not get better. But the language as a tool gets better. Much better.

C++ is not in itself a superior language - actually some may consider it a horrible language considering all its bagage. But the fact that it's so widely used, documented, and so many third-party components exist for use with C++, makes C++ as a tool vastly better than it would've been without all those accesories.

So in a way C++ does improve (as a tool) simply on the account of the number of people using it.
"We confess our little faults to persuade people that we have no large ones." -Francois de La Rochefoucauld (1613 - 1680). | My blog

### #148CTar  Members

Posted 15 May 2006 - 02:29 AM

Quote:
 Original post by CoffeeMugThere is certainly some value in popularity. Ability to hire reasonably proficient programmers for less than astronomic salaries. Large body of available libraries and documentation. Ability to get some support from public forums.

Yes, good reasons to choose the language, but the language won't get any better because of it. The person I was quoting said that C++ could be considered the best simply because of legacy.

rohde: I agree

### #149CoffeeMug  Members

Posted 15 May 2006 - 02:29 AM

Quote:
 Original post by rohdeSo in a way C++ does improve (as a tool) simply on the account of the number of people using it.

The question is whether availability of cheap developers, documentation, and a huge number of libraries outweighs the baggage. Many people claim that it does not (add me to that list).

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.