Page 3 of 8
Re: What's wrong with C++?
Posted: Thu Feb 11, 2010 1:10 pm
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#) ?
Re: What's wrong with C++?
Posted: Thu Feb 11, 2010 3:41 pm
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?

Re: What's wrong with C++?
Posted: Thu Feb 11, 2010 3:59 pm
by Kojack
So... how many of you are coding in Google's Go? How many even remember that Google released their own language?

Re: What's wrong with C++?
Posted: Thu Feb 11, 2010 4:01 pm
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.

Re: What's wrong with C++?
Posted: Thu Feb 11, 2010 4:08 pm
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.
Re: What's wrong with C++?
Posted: Thu Feb 11, 2010 4:26 pm
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.
Re: What's wrong with C++?
Posted: Thu Feb 11, 2010 4:38 pm
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.

Re: What's wrong with C++?
Posted: Thu Feb 11, 2010 4:42 pm
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.

Re: What's wrong with C++?
Posted: Thu Feb 11, 2010 5:46 pm
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?
Re: What's wrong with C++?
Posted: Thu Feb 11, 2010 5:56 pm
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.
Re: What's wrong with C++?
Posted: Thu Feb 11, 2010 6:13 pm
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.
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.
Re: What's wrong with C++?
Posted: Thu Feb 11, 2010 7:39 pm
by Klaim
Now the "discussion" is less fun...
Re: What's wrong with C++?
Posted: Thu Feb 11, 2010 7:47 pm
by jacmoe
Sorry

Re: What's wrong with C++?
Posted: Thu Feb 11, 2010 8:46 pm
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?

It would be taken as a compiler error

Re: What's wrong with C++?
Posted: Thu Feb 11, 2010 9:47 pm
by Irydion
Not if you replace the commas by semicolons

(and add a " in the printf ...)
Re: What's wrong with C++?
Posted: Fri Feb 12, 2010 4:01 am
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?
Re: What's wrong with C++?
Posted: Fri Feb 12, 2010 5:05 am
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)
Re: What's wrong with C++?
Posted: Fri Feb 12, 2010 5:08 am
by mkultra333
Thanks, I'll look into that. I'm fairly new to Lua.
Re: What's wrong with C++?
Posted: Fri Feb 12, 2010 9:29 am
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?

It would be taken as a compiler error

My example yes would not compile - I typed them without thinking

. 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.
Re: What's wrong with C++?
Posted: Fri Feb 12, 2010 5:09 pm
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.
Re: What's wrong with C++?
Posted: Fri Feb 12, 2010 5:17 pm
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.
Re: What's wrong with C++?
Posted: Fri Feb 12, 2010 6:08 pm
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.
Re: What's wrong with C++?
Posted: Fri Feb 12, 2010 6:16 pm
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.
The geeks at Boost uses all kinds of sick meta-programming tricks to achieve this - still not as good as C#.
Re: What's wrong with C++?
Posted: Sat Feb 13, 2010 2:45 am
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:

Re: What's wrong with C++?
Posted: Sat Feb 13, 2010 3:17 pm
by madmarx
I don't believe you one bit.
Lol

.
I am ok to post in this thread how I did, but what do I get if I show it to you?

Any candies?
wanna bet

?