What makes C++ so powerful?

Started by
147 comments, last by CoffeeMug 17 years, 11 months ago
Quote:Just give'em a header from one of boost libraries that generates code from a mix of macro & template metaprogramming and they lay a brick in their paints....


snipped for brevity
#ifndef BOOST_ASSIGN_MAX_PARAMS // use user's value#define BOOST_ASSIGN_MAX_PARAMS 5#endif        #define BOOST_ASSIGN_MAX_PARAMETERS (BOOST_ASSIGN_MAX_PARAMS - 1) #define BOOST_ASSIGN_PARAMS1(n) BOOST_PP_ENUM_PARAMS(n, class U)#define BOOST_ASSIGN_PARAMS2(n) BOOST_PP_ENUM_BINARY_PARAMS(n, U, const& u)#define BOOST_ASSIGN_PARAMS3(n) BOOST_PP_ENUM_PARAMS(n, u)#define BOOST_PP_LOCAL_LIMITS (1, BOOST_ASSIGN_MAX_PARAMETERS)#define BOOST_PP_LOCAL_MACRO(n)     template< class U, BOOST_ASSIGN_PARAMS1(n) >     generic_ptr_list& operator()(U const& u, BOOST_ASSIGN_PARAMS2(n) )     {         this->push_back( new T(u, BOOST_ASSIGN_PARAMS3(n)));         return *this;     }     /**/        #include BOOST_PP_LOCAL_ITERATE()    }; // class 'generic_ptr_list'} // namespace 'assign_detail'namespace assign{    template< class T >    inline assign_detail::generic_ptr_list<T>    ptr_list_of()    {        return assign_detail::generic_ptr_list<T>()();    }        template< class T, class U >    inline assign_detail::generic_ptr_list<T>     ptr_list_of( const U& t )    {        return assign_detail::generic_ptr_list<T>()( t );    }#define BOOST_PP_LOCAL_LIMITS (1, BOOST_ASSIGN_MAX_PARAMETERS)#define BOOST_PP_LOCAL_MACRO(n)     template< class T, class U, BOOST_ASSIGN_PARAMS1(n) >     inline assign_detail::generic_ptr_list<T>     ptr_list_of(U const& u, BOOST_ASSIGN_PARAMS2(n) )     {         return assign_detail::generic_ptr_list<T>()(u, BOOST_ASSIGN_PARAMS3(n));     }     /**/    #include BOOST_PP_LOCAL_ITERATE()
Advertisement
Quote:Original post by Anonymous Poster
Quote:Original post by Anonymous Poster
What about changing variables in hand directly from memory?
What a terrible thing to do. A Java programmer does not think in terms of memory addresses ;)

What about making visual effect by changing memory. Some tricks known well from many years.


Java primitives are in fact something like virtual registers, and arrays are an abstraction of direct memory access. So expericenced programmer is able to think in terms of CPU registers, if he want, without worrying about any manual register allocation.

While Java prgrammer (not scrip kiddies) could do index arithmetic on array, in most situation they are using OpenGL, because of simplicity.


//
C++ 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?
Quote:Original post by Raghar
C++ 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?
The way I see it, the fundamental difference is as such. C++ functions under the (often incorrect) assumption that the programmer is competent. In contrast, Java assumes (sometimes correctly) the programmer is a dumbass who will make every mistake he can possibly make, turning his code base into a mess. As a result, C++ gives you all sorts of powerful tools, some very dangerous. Java takes away anything which the Java designers perceived as having any potential for abuse.

It's probably clear which side I favor.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Quote:Original post by Talroth
Quote:Original post by nmi
And you should remember that Java also needed a second start (the first version was called 'Oak' if I remember correctly).

I'm fairly sure I read somewhere that Java was first called OAK, but changed to java due to copyright issues, (there was already a project oak) and the last version of Oak was the same as the first version of Java. I can look it up to be sure if someone cares.


Java is to OAK as Wii is to Revolution. Name OAK was used by different programming language so they decided to release it under another name. (It would be confusing if there would be two different languages with the same name. In fact even name &#106avascript was confusing.)<br><br>BTW language specification is here.<br><br>http://java.sun.com/docs/books/jls/
Quote:Original post by Promit
The way I see it, the fundamental difference is as such. C++ functions under the (often incorrect) assumption that the programmer is competent. In contrast, Java assumes (sometimes correctly) the programmer is a dumbass who will make every mistake he can possibly make, turning his code base into a mess. As a result, C++ gives you all sorts of powerful tools, some very dangerous. Java takes away anything which the Java designers perceived as having any potential for abuse.
It's probably clear which side I favor.


Cute. ^_^

I'm using programming language as I want, not as it is expected to be used. However when you are talking about powerful tools, what happened to multipass compiler, short compile times, multiple entry points into program, type sizes preciselly defined in the standard, and SHR? To be forced into creating both 32 bit and 64 bit executable isn't nice either.
Quote:Original post by Raghar
C++ 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.

How about:

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.
______________________________"Man is born free, and everywhere he is in chains" - J.J. Rousseau
well I can't recall reading through these 6 pages of replies and seeing the answer, so I'll put it here:

The Programmer!
Quote:Original post by Raghar
I'm using programming language as I want, not as it is expected to be used. However when you are talking about powerful tools, what happened to multipass compiler, short compile times, multiple entry points into program, type sizes preciselly defined in the standard, and SHR? To be forced into creating both 32 bit and 64 bit executable isn't nice either.
And I moved to C# for my hobby work for the exact same reasons. Java did a lot of good things, but I feel like Java made a vast number of mistakes at the same time, and those mistakes are a point of considerable irritation for me when I have to work in Java.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Quote:Original post by Oberon_Command
Quote:Original post by Spoonbender
If you really disagree with me, then show me a program in C++ that couldn't have been made using C#.


An operating system? You would need a C# compiler that compiles to native binary, and to the best of my knowledge there aren't any...


C# operating system
http://channel9.msdn.com/ShowPost.aspx?PostID=68302
A programming language can be used to do anything. To acknowledge a languages weaknesses is logical, but to say that it can't out right perform a task that all programming languages can do is foolish for it limits ones own creativity and sets a box on what can and cannot be done.


all programming languages have their strengths and their weaknesses.
The skill of the programmer can be used to overcome those weaknesses but when in a situation where the weakness of the programming language is too apparent than use another one.

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.

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.

C++ is the most popular language, thus it is the most powerful.

JESUS IS GOD! JESUS IS THE SON OF GOD! GOD IS LOVE!

Quote:Original post by JustOwninDaFINALBOSS
C++ is the most popular language, thus it is the most powerful.


Popularity 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).

[Edited by - snk_kid on May 15, 2006 7:05:01 AM]

This topic is closed to new replies.

Advertisement