Welcome,
Guest
. Please
login
or
register
.
May 23, 2013, 05:56:53 PM
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search:
Advanced search
Latest Binary Zoo Release:
Echoes+ is out now on XBox Live Indie Games.
29655
Posts in
1431
Topics by
164
Members
Latest Member:
Martoon
The Binary Zoo
General
Game Development
C++ and C# Differences?
« previous
next »
Pages:
[
1
]
2
3
...
6
Author
Topic: C++ and C# Differences? (Read 4783 times)
fog
Binary Zoo
Zookeeper
Bunnymonkey
Offline
Posts: 12656
C++ and C# Differences?
«
on:
August 11, 2011, 10:03:47 AM »
Does anyone know what the major differences are, how difficult it is to adjust from one to the other and what the major pitfalls are to be aware of?
Although a quick google linked me to a few comparisons there don't seem to be any big differences and yet I've seen enough people say how much better C# is to use than C++ that I know I must be missing something.
I'm coming at this as someone with a reasonable bit of C# experience, but no C++
Logged
TheKhakinator
Playtester
Bunnymonkey
Offline
Posts: 2182
My Dreams Left Destroyed
Re: C++ and C# Differences?
«
Reply #1 on:
August 11, 2011, 06:00:33 PM »
I think... from my experience... C# is more Java like with all This.That() and shit? C++ has none of that if I remember correctly.
I'll now /shut up/, as there are a million actually experienced coders ready to jump in here...
Logged
http://www.last.fm/music/My+Dreams+Left+Destroyed
Prime_8
Bunnymonkey
Offline
Posts: 1207
Re: C++ and C# Differences?
«
Reply #2 on:
August 12, 2011, 08:25:12 AM »
you can this & that in C++ it is a function of an objects class
mycclass has a function A , and a var B
in function a , you could get the current value of B from the object of type myclass the function belongs to.
simply
this->B = some val
becaus we know function a , is a part of a myclass , then 'this' has to be a instance of a myclass object , and the current instance that houses 'a' .
for each .. work sinside a class the same way .. when you are used to them you can make some crazy looking cod ethat works and is small in size , but can be a puzzel to read ... ( IMO i find it hard to read sometimes )
C# , is ~ most of the power of C++ , but basic feel. LOL
http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/index.jsp?topic=%2Fcom.ibm.xlcpp8a.doc%2Flanguage%2Fref%2Fcplr035.htm
C# is managed memory . err works just diff enough it can be a pain to make stuff work that wa snot C# or managed tobegin with .. C++ is not .. it's all up to you ... less bloat wear .
personaly i still prefer C++ , more libs more compatabillity , C# is nice though .
C++ , you can make an exe that requires nothing .. no runtimes or .net , or such unless you chose to link to them .
there are workarrounds for some of that too, such as dummy MS class headers but .. C# shoudl be easier to make a basic ap on a newer PC wher the .net and all that jaz came with the OS for sure .
Logged
www.ejectedcore.com
fog
Binary Zoo
Zookeeper
Bunnymonkey
Offline
Posts: 12656
Re: C++ and C# Differences?
«
Reply #3 on:
August 12, 2011, 09:39:57 PM »
Quote from: TheKhakinator on August 11, 2011, 06:00:33 PM
I think... from my experience... C# is more Java like with all This.That() and shit? C++ has none of that if I remember correctly.
I'll now /shut up/, as there are a million actually experienced coders ready to jump in here...
lol thanks. It's always useful to hear what peoples personal experiences and feelings are rather than just technical detail.....what with me not being the most technically educated coder around
Quote from: Prime_8 on August 12, 2011, 08:25:12 AM
C# is managed memory . err works just diff enough it can be a pain to make stuff work that wa snot C# or managed tobegin with .. C++ is not .. it's all up to you ... less bloat wear .
Yeah managed/unmanaged seems to be the biggie. I've no experience of an unmanaged language, but from the little I know I don't think it would be a huge issue with my coding style as I tend to avoid creating and destroying objects.
Anyway my thinking behind all of this is that AGK can be used with C++ and this appeals for a few reasons. Firstly it's obviously OOP which I prefer and would make porting my XNA code easier. Also if I have a code base of C++ then should I switch to another engine in the future porting should be a lot easier. And finally I can use Visual Studio and I've grown to love that.
Of course all of that is dependent on AGK being any good
It's out on Monday IIRC so hopefully a demo shouldn't be far away.
Logged
Prime_8
Bunnymonkey
Offline
Posts: 1207
Re: C++ and C# Differences?
«
Reply #4 on:
August 13, 2011, 08:02:57 AM »
if you code C++ , C# is not hard , just afew small changes.
C++ managed memory , is up to coder just as in C . teh extern C , lets you call or include C code in C++ , so you can run even more libs.
& !! managed memory , and properly using objects with correct constructers and destructors you will avoid memory leaks , && you will gain speed . . , potetnialy a great deal of speed.
Now i don't like VS , i use code blocks .
free ided that can use a number of compilers inc MS VC ones & , can come with mingw GCC , and that means you don;t have / need aything installed .. but you like xna . so some flavor of VS is needed.
one thing i like about C++ , and non managed memory .. is using scope as a destructor of simple types.
if( somevar == 1)
{
int SmallScope
// small scope local is only valid in this if block
} // smallscope is killed and removed form ram at this point .
but that is not as fast as if you had dec' Small scope as a full scope var .
avaiod dec' inside loops , will speed you up .
but that is C++. i suppose your compiler may optimise for you aws well depending on compile options ..LOL
Logged
www.ejectedcore.com
fog
Binary Zoo
Zookeeper
Bunnymonkey
Offline
Posts: 12656
Re: C++ and C# Differences?
«
Reply #5 on:
August 13, 2011, 04:24:05 PM »
Cheers Prime.
I'm certainly swaying towards giving the AGK with C++ approach a go so may have more questions later
Logged
Prime_8
Bunnymonkey
Offline
Posts: 1207
Re: C++ and C# Differences?
«
Reply #6 on:
August 13, 2011, 11:27:42 PM »
in the words of manuel for fawlty towers .. " I learn it form a book "
Logged
www.ejectedcore.com
fog
Binary Zoo
Zookeeper
Bunnymonkey
Offline
Posts: 12656
Re: C++ and C# Differences?
«
Reply #7 on:
August 14, 2011, 09:18:13 AM »
Quote from: Prime_8 on August 13, 2011, 11:27:42 PM
in the words of manuel for fawlty towers .. " I learn it form a book "
A classic
I'll do what I normally do and just dive in and start writing a game and tackle each hurdle as I come across it.
Logged
Prime_8
Bunnymonkey
Offline
Posts: 1207
Re: C++ and C# Differences?
«
Reply #8 on:
August 14, 2011, 12:33:07 PM »
that's what i did ..
with my teach yourself C++ is 21 days book as a ref , rather than teaching aid . ..
and of course a few good .chm files.
Logged
www.ejectedcore.com
fog
Binary Zoo
Zookeeper
Bunnymonkey
Offline
Posts: 12656
Re: C++ and C# Differences?
«
Reply #9 on:
August 17, 2011, 11:11:17 AM »
One point I forgot is how good error reporting and debugging is in Visual Studio which makes learning a hell of a lot easier. Although something like Monkey and DBPro are easier to use the error reporting and debugging are next to useless a lot of the time.
The biggest problem so far was trying to find enough space on my eeePC's tiny 4Gb C Drive to install VS, .NET 4.0 etc etc on. I hope I haven't deleted anything important!
«
Last Edit: August 17, 2011, 11:13:55 AM by fog
»
Logged
fog
Binary Zoo
Zookeeper
Bunnymonkey
Offline
Posts: 12656
Re: C++ and C# Differences?
«
Reply #10 on:
August 18, 2011, 08:24:09 PM »
Well so far I've found out that Static is handled completely differently in C++ to C#....eventually
And I was tripped up by this.X becoming this->X ....and of course the error shown in VS confused the hell out of me as it kept referring to "this" as a class and no amount of me yelling "but it's not a class!!!" was going change it's mind.
Not sure I like the whole header files thing, but I guess you get used to it. So far not so bad
Logged
Prime_8
Bunnymonkey
Offline
Posts: 1207
Re: C++ and C# Differences?
«
Reply #11 on:
August 18, 2011, 11:13:38 PM »
personlay i bastardize C++
main.h < main header
2ndmodule.h < inc in any thing that may use 2ndmodule.cpp's functions . class
main .cpp
2ndmodule.cpp , no need to include it , just compile in same project
.. keep going ... LOL
personaly that drives me nuts ..
on small stuff .. i break CPP rules and actulay put implimentations in .h
in fact ... i even do this bad habbit
main()
{
include somecode.h
}
somecode.h may contain my input section ..
i have never been formaly trained in C or C++ , only pascal.
Logged
www.ejectedcore.com
fog
Binary Zoo
Zookeeper
Bunnymonkey
Offline
Posts: 12656
Re: C++ and C# Differences?
«
Reply #12 on:
August 19, 2011, 05:25:47 PM »
Quote from: Prime_8 on August 18, 2011, 11:13:38 PM
personaly that drives me nuts ..
Yeah it's going to take some getting used to. Jumping from .h to .cpp all the time is going to get very boring....
Quote from: Prime_8 on August 18, 2011, 11:13:38 PM
on small stuff .. i break CPP rules and actulay put implimentations in .h
I didn't even know you could do that. I take it that's a very bad thing to do and it can cause problems?
Logged
fog
Binary Zoo
Zookeeper
Bunnymonkey
Offline
Posts: 12656
Re: C++ and C# Differences?
«
Reply #13 on:
August 21, 2011, 03:16:22 PM »
Quote
class MyClass
{
};
That little semi-colon at the end is driving me mad lol. C# doesn't need one and I keep forgetting the bloody thing which throws weird errors seemingly elsewhere
Logged
fog
Binary Zoo
Zookeeper
Bunnymonkey
Offline
Posts: 12656
Re: C++ and C# Differences?
«
Reply #14 on:
August 23, 2011, 09:42:14 AM »
Still not sure about Static variables and a quick Google shows there's some disagreement about how to access them properly.
If I have this in my header file:
.h
Code:
class myClass {
static int myVar;
static void myFunc();
};
how do I access that static variable in my .cpp file? I've seen this method recommended but defining the variables again at the top of the file seems wrong.
.cpp
Code:
int myClass::myVar;
void myClass::myFunc() {
myVar = 1;
}
Or maybe that is right and I'm still thinking too much like I would in C# where you don't have separate header and code files so never repeat any definitions?
Logged
Pages:
[
1
]
2
3
...
6
« previous
next »
Jump to:
Please select a destination:
-----------------------------
Feedback
-----------------------------
=> General
=> Games
=> Music
-----------------------------
General
-----------------------------
=> Game Development
=> Wildlife
Loading...