What's wrong with C++?

A place for Ogre users to discuss non-Ogre subjects with friends from the community.
Post Reply
User avatar
madmarx
OGRE Expert User
OGRE Expert User
Posts: 1671
Joined: Mon Jan 21, 2008 10:26 pm
x 50

Re: What's wrong with C++?

Post by madmarx »

jacmoe wrote :
Even then, you can't compete with a language like C# - especially when doing reflection.
I don't understand. I have written a C++ library. With it, I only declare a C++ class, with some functions and members. During the declaration I add some characteristics to the functions and members (but I can set them automatically), and that gives me automatically reflection, scripting, serializing, remote calls class written.. for the elements that I have chosen. I could do a lot more functionnality (tuple generation etc...). I can choose for which function I want scripting enable or not, functor declared or not etc... This is pure C++. And use only the declaration (so no function is at that moment coded, only the declaration is written).

So since the declaration only allows me to generate all these functionnalities (without any moc compiler or anything like this), I don't see how C# could do better (which might not be surprising sice I don't know much C#) ?
Tutorials + Ogre searchable API + more for Ogre1.7 : http://sourceforge.net/projects/so3dtools/
Corresponding thread : http://www.ogre3d.org/forums/viewtopic. ... 93&start=0
User avatar
syedhs
Silver Sponsor
Silver Sponsor
Posts: 2703
Joined: Mon Aug 29, 2005 3:24 pm
Location: Kuala Lumpur, Malaysia
x 51

Re: What's wrong with C++?

Post by syedhs »

Speaking of number of lines, I wonder what would the line number if I coded as below:-

Code: Select all

for (int j=0, j < 10;++j),printf("Hello,world),int ch=getch(),if (ch==27) return 0....
Would it be taken as one-liner? :mrgreen:
A willow deeply scarred, somebody's broken heart
And a washed-out dream
They follow the pattern of the wind, ya' see
Cause they got no place to be
That's why I'm starting with me
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: What's wrong with C++?

Post by Kojack »

So... how many of you are coding in Google's Go? How many even remember that Google released their own language?
:)
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: What's wrong with C++?

Post by jacmoe »

Kojack wrote:So... how many of you are coding in Google's Go? How many even remember that Google released their own language?
:)
Exactly. :wink:
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
nikki
Old One
Posts: 2730
Joined: Sat Sep 17, 2005 10:08 am
Location: San Francisco
x 13
Contact:

Re: What's wrong with C++?

Post by nikki »

I just can't imagine my program not working directly with the machine, but over some 'layer' that talks with the machine. I've tinkered with so many langauges, but when it comes to writing 'real programs', it only 'feels right in C++' for some reason.
jjp
Silver Sponsor
Silver Sponsor
Posts: 597
Joined: Sun Jan 07, 2007 11:55 pm
Location: Cologne, Germany
Contact:

Re: What's wrong with C++?

Post by jjp »

nikki wrote:I just can't imagine my program not working directly with the machine, but over some 'layer' that talks with the machine.
Well, even with C++ you're all but working directly with the machine. You still have to trust a sophisticated compiler, the code of which you probably do not fully understand. And when your application executes it does not have free reign over the machine but can do certain things only by asking the OS to do it, i.e. another layer that talks with the machine.
Enough is never enough.
User avatar
nikki
Old One
Posts: 2730
Joined: Sat Sep 17, 2005 10:08 am
Location: San Francisco
x 13
Contact:

Re: What's wrong with C++?

Post by nikki »

jjp wrote:
nikki wrote:I just can't imagine my program not working directly with the machine, but over some 'layer' that talks with the machine.
Well, even with C++ you're all but working directly with the machine. You still have to trust a sophisticated compiler, the code of which you probably do not fully understand. And when your application executes it does not have free reign over the machine but can do certain things only by asking the OS to do it, i.e. another layer that talks with the machine.
You're right. I was sleepy when I posted that. :oops:
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: What's wrong with C++?

Post by jacmoe »

madmarx wrote: I don't see how C# could do better (which might not be surprising sice I don't know much C#) ?
I am not the right person to explain this to you, but take a look at this:
http://www.dotnetjohn.com/articles.aspx?articleid=273
Especially listing 5. :)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: What's wrong with C++?

Post by jacmoe »

There's no need for mocking.
The example you came up with is invalid because vba script is not a real language is it?
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: What's wrong with C++?

Post by jacmoe »

Oh, I missed that part where you wrote 'pure SQL' - still that's not a real programming language? I bet you could do it, so my hat off to you.
But comparing a structured query language with a programming language is far fetched IMO.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: What's wrong with C++?

Post by jacmoe »

SQL is a domain specific language, isn't it?
I bet you can write the game of chess in it, if you're good at it. :wink:

That's not the point.
Even if C++ is more concise in its syntax, you still have to write more lines of code to accomplish the same task than you would if using a higher-level language.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
x 56
Contact:

Re: What's wrong with C++?

Post by Klaim »

Now the "discussion" is less fun...
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: What's wrong with C++?

Post by jacmoe »

Sorry :)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
lonewolff
Ogre Magi
Posts: 1207
Joined: Wed Dec 28, 2005 12:58 am
x 6

Re: What's wrong with C++?

Post by lonewolff »

syedhs wrote:Speaking of number of lines, I wonder what would the line number if I coded as below:-

Code: Select all

for (int j=0, j < 10;++j),printf("Hello,world),int ch=getch(),if (ch==27) return 0....
Would it be taken as one-liner? :mrgreen:
It would be taken as a compiler error :lol:
Irydion
Kobold
Posts: 26
Joined: Thu Nov 12, 2009 10:02 pm
Location: France
x 1

Re: What's wrong with C++?

Post by Irydion »

Not if you replace the commas by semicolons ;) (and add a " in the printf ...)
Somebody set up us the bomb !
User avatar
mkultra333
Gold Sponsor
Gold Sponsor
Posts: 1894
Joined: Sun Mar 08, 2009 5:25 am
x 114

Re: What's wrong with C++?

Post by mkultra333 »

Know what I hate? When a language doesn't require you to declare variables before you use them.

I'm doing a bit of scripting in Lua, and one nasty bug I've hit once or twice is when I set up some variable (say, "DemonGreyHealth") and then later accidentally misspell it (say, "DemonGrayHealth"). No error is reported, but suddenly the results are not correct. What is going on?...

C++ will just flat out slap you in the face at compile time and say "What the HELL is THIS?" and point it's angry, glowing red finger at DemonGrayHealth.

Although it doesn't at all mind

Code: Select all

if(DemonGreyHealth = 0) 
{ 
   KillMonster(DemonGrey) ;
}  
Hey, how come the demon keeps dying even when I haven't hit it yet?
"In theory there is no difference between practice and theory. In practice, there is." - Psychology Textbook.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: What's wrong with C++?

Post by Kojack »

I'm doing a bit of scripting in Lua, and one nasty bug I've hit once or twice is when I set up some variable (say, "DemonGreyHealth") and then later accidentally misspell it (say, "DemonGrayHealth"). No error is reported, but suddenly the results are not correct. What is going on?...
This is easy to fix, lua comes with a script in the etc directory called strict.lua. It makes lua give an error if you try to access an undeclared variable.
(It adds custom index and newindex operators to the meta table of the global table)
User avatar
mkultra333
Gold Sponsor
Gold Sponsor
Posts: 1894
Joined: Sun Mar 08, 2009 5:25 am
x 114

Re: What's wrong with C++?

Post by mkultra333 »

Thanks, I'll look into that. I'm fairly new to Lua.
"In theory there is no difference between practice and theory. In practice, there is." - Psychology Textbook.
User avatar
syedhs
Silver Sponsor
Silver Sponsor
Posts: 2703
Joined: Mon Aug 29, 2005 3:24 pm
Location: Kuala Lumpur, Malaysia
x 51

Re: What's wrong with C++?

Post by syedhs »

lonewolff wrote:
syedhs wrote:Speaking of number of lines, I wonder what would the line number if I coded as below:-

Code: Select all

for (int j=0, j < 10;++j),printf("Hello,world),int ch=getch(),if (ch==27) return 0....
Would it be taken as one-liner? :mrgreen:
It would be taken as a compiler error :lol:
My example yes would not compile - I typed them without thinking :wink: . But you can actually have all those lines 'combined' using comma and they are one of the most often used trick in Obfuscated C contest.
A willow deeply scarred, somebody's broken heart
And a washed-out dream
They follow the pattern of the wind, ya' see
Cause they got no place to be
That's why I'm starting with me
warmi
Gnoll
Posts: 674
Joined: Sun May 27, 2007 3:56 am
Location: USA

Re: What's wrong with C++?

Post by warmi »

madmarx wrote:jacmoe wrote :
Even then, you can't compete with a language like C# - especially when doing reflection.
I don't understand. I have written a C++ library. With it, I only declare a C++ class, with some functions and members. During the declaration I add some characteristics to the functions and members (but I can set them automatically), and that gives me automatically reflection, scripting, serializing, remote calls class written.. for the elements that I have chosen. I could do a lot more functionnality (tuple generation etc...). I can choose for which function I want scripting enable or not, functor declared or not etc... This is pure C++. And use only the declaration (so no function is at that moment coded, only the declaration is written).

So since the declaration only allows me to generate all these functionnalities (without any moc compiler or anything like this), I don't see how C# could do better (which might not be surprising sice I don't know much C#) ?
C++ as a language will never be able to match C# in terms of fancy stuff like reflection etc ... but that's ok , because it was never meant to.
In C# you end up paying the price for a lot of features which are cool but useful to some while imposing performance penalties on all - this kind of tradeof is exactly the opposite of what C/C++ languages are all about …..
In short you guys are talking apples and oranges.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: What's wrong with C++?

Post by jacmoe »

That's a very classic answer. :)
We talked about productivity, not what kind of fruit it was.
Given good libraries, you can be almost as productive in C++ as in C#. Almost.
C# is more dynamic. A modern language.
I use C++ because I like it. And because it's widely used and flexible.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
madmarx
OGRE Expert User
OGRE Expert User
Posts: 1671
Joined: Mon Jan 21, 2008 10:26 pm
x 50

Re: What's wrong with C++?

Post by madmarx »

Hi, I can do reflection like the one of the C# listing 5 of your link in pure C++. Same for attributes (even if I have a maximum of 1024 different kinds of attributes in my case, due to preprocessor limit).

But concerning languages , some 'datas' might even be languages. Is lua a programming language?

I did shoot-them-up engin that used only images to stores : trajectories, rotations, deplacement, positionning of elements. It was way more productive than doing the corresponding traj with the corresponding maths. A noob could create in a few seconds different kind of swarms. In that case is this 'image driven' language, a high level programming language?

I don't know the answer.
Tutorials + Ogre searchable API + more for Ogre1.7 : http://sourceforge.net/projects/so3dtools/
Corresponding thread : http://www.ogre3d.org/forums/viewtopic. ... 93&start=0
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: What's wrong with C++?

Post by jacmoe »

I don't believe you one bit. :)
Not even Stroustrup himself is that far:
http://root.cern.ch/drupal/content/c-di ... rup-part-2
(See 'reflection' section).

If you can do this, you can do what no-one has been able to do reliably, and the world would be at your feet. :wink:

The geeks at Boost uses all kinds of sick meta-programming tricks to achieve this - still not as good as C#.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: What's wrong with C++?

Post by Kojack »

Is lua a programming language?
Yes it is.
In that case is this 'image driven' language, a high level programming language?
Can the images specify mathematical operations and conditional flow control? If yes, then it's a programming language. If no, then it's just data.

Here's an image based programming language:
http://www.dangermouse.net/esoteric/piet.html
And here's Hello World written in Piet:Image
User avatar
madmarx
OGRE Expert User
OGRE Expert User
Posts: 1671
Joined: Mon Jan 21, 2008 10:26 pm
x 50

Re: What's wrong with C++?

Post by madmarx »

I don't believe you one bit.
Lol :D .
I am ok to post in this thread how I did, but what do I get if I show it to you? :D Any candies? :D

wanna bet 8) ?
Tutorials + Ogre searchable API + more for Ogre1.7 : http://sourceforge.net/projects/so3dtools/
Corresponding thread : http://www.ogre3d.org/forums/viewtopic. ... 93&start=0
Post Reply