Archived

This topic is now archived and is closed to further replies.

C++ or C#

This topic is 5131 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m new here and would like to start off by saying hi to everyone. I''m a senior in high school and plan on majoring in Computer Science at NJIT when I graduate. Hopefully, after that, I''ll eventually go on to a career in game development. I''ve always had an interest in computers, video games, and programming, but have only now started to seriously learn how to program. I''ve tried to learn the fundamentals of programming, primarily through Beginning Programming for Dummies and internet tutorials. I know some BASIC, but hardly enough to get by. Right now I''m trying to learn Java and some Internet coding (i.e. HTML, XML, javascript, Flash, etc.). If all goes to plan I''ll have a class in it in January, which I desperately need. To get to the point of this post, after learning Java I''d like to get aquainted w/ C/C++. I''m just curious, how does C++ compare to C# (I''ve tried to figure it out from the much researching I''ve been doing on programming.)? From what I''ve read, it seems C# is Microsoft''s answer to Java. More importanly, would it make sense to create games in C# or should we just all stick to C++ primarly? Phew! Sorry about the long post. Just wanted to get that all out.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Hi GrouchyIssues4.

Once you learn a language well, it is much easier to migrate to a new language. My suggestion to you is to use the language you feel most comfortable with, try a little bit of each if you don''t know. Once you learn that language well, you can learn another one fairly easy.

It is hard to recommend any specific language without knowing your background but I''d say C++ is a good language to loarn. I started with VB and later switched to C++ without too much hassle.

I can''t say anything about C# since I have only seen a few lines of code. It seems ok and I assume it will be a good language to know when MS Longhorn is the OS of choice (probably 2006/2007 or so).

If your goal is to program games, I would definately recommend C++ based on the little experience I have.

Good luck!

Share this post


Link to post
Share on other sites
Learn C/C++ first. Then do C# if you are still interested, that way you''ll at least appreciate the stuff C# does for you.

I prefer C# for hobbyist development but keep my C/C++ skills sharp because thats where the industry is (and probably will be for a long time).

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
IMHO-It would make since to make games in C#. There are some things with C# and the .NET framework that would speed up game development and would make the code cleaner. It may not be as fast as C++ but I think most games will be coded with that or similar. When I said some things that I thought could be useful. Possibly a web program for patches, ladder rankings, etc... used from within a program. And just the general C# code that would make code cleaner and quicker to write. Garbage collection, etc.. And the possibility of using any of the .NET language to script the objects in your game.

quote:
Everything C# can do, C++ can do better.


I''m not trying to start or get involved in a flame war but, have you ever even used C#? If you are saying faster, and at a lower level then yes. C++ can do it "better". I love C++ and I believe it has it''s uses and places but I think eventuall C# and the CLR OR a similar technology will be used for most application programs. I believe C/C++ will eventually be used for only operating system components and I think that''s a good thing.

Share this post


Link to post
Share on other sites
quote:
Original post by Programmer One
Everything C# can do, C++ can do better.



That's true if you don't count reflection, ASP.NET, benchmarks on longhorn with C# 2.0 =] Also you just have to be kidding me if you think you can come CLOSE to the productivity in C# with C++.

Maybe you guys really don't understand what generics does for the language in 2.0 do you? =]

Not a flame.. but I guess it's just the old motto of the new thing isn't as good as the old one, such as the ASM -> higher level languages move.

Flame me if you'd like, but please note I professionally programmed with C++ for around 6 or 7 years now. At work EVERYTHING had to be changed over to C#.. just like in most business production environments.

Also please note that what Microsoft says, happens. You may not like it, you may like it. But when Microsoft pushes everything they have towards managed code and C#.. that is where the world will move.

Also.. how can anybody disagree that managed code is one of the greatest options for a Windows operating system? It will show a security and stability not seen yet on the platform.

I've heard many people complain about "I hate windows XP, it crashes a couple times a day". Those are the people who need a clue on how to use a computer, considering at work there are approximately 40-50 workstations with different hardware and software configurations.. why don't we see this problem? I mean these people need to realize most of the time you see a crash it is due to an application poking around in memory where it shouldn't be (usually by accident) or a buffer error right?


In response to the initial thread though, I think both C++ and C# are great languages. Also I would probably recommend learning C++ first in order to understand the underlying reasons C# was developed, as it fixes many of the core problems that C++ has today. Also don't be fooled by people that tell you C++ can do everything C# can =]

a) I mean if you look at the longhorn ALPHA benchmarks using VS.NET 2004, managed code is way ahead of unmanaged code. As well as Microsoft stating that "native" code execution will be retained as backwards compatibility (It's pretty much the same as DOS applications being allowed to run on Windows 95), but managed .NET is where the platform is going.

b) At our business we are now 30-50% more productive depending on the task because things can be coded a lot quicker. As well as the fact we can spend more time on business logic and less time on debugging buffer and pointer problems.

c) It is the paradigm standard for the future of Microsoft Windows from 2006 onwards.


I see the game development community waiting until around 2006-2007 in order to adopt the new managed paradigm and coding with C# and managed C++. Until then I would learn C++ and object-oriented fundamentals, and then move on to C# once you are knowledgable in C++.


EDIT: I really should have stated more on productivity.. which is one of the MAJOR aspects of managed code with .NET

When you are sitting around coding your own games and applications in your spare time for fun.. sure go ahead and use what you want and take as long as you want to do it.

In the business world, whether it be business applications, server-side applications, or game development.. what a lot of people don't understand is that PRODUCTIVITY > PERFORMANCE. As long as it performs "well enough" by the time Christmas comes.. release it.

C# and the framework are cutting MONTHS to YEARS off projects even as I post =]

[edited by - Imperil on November 11, 2003 10:36:41 PM]

[edited by - Imperil on November 11, 2003 10:39:01 PM]

Share this post


Link to post
Share on other sites
I''d recommend learning C++ first. This is because most code samples, documentation, and FAQs for game programming are done in or for C++, so it''s easier to take advantage of exisitng knowledge. This goes double if you''re about to start college. Most universities will be teaching in C or C++ (with the occasional Lisp dialect).

Share this post


Link to post
Share on other sites
I hope you guys are intelligent enough not to start a flamewar...

I agree with SiCrane and Ratman, learn C++ first so that you know what''s really happening in a program. I learnt BASIC then VB before I put my step on C++. Though I had been using VB for 2-3 years, frankly I had no clue that string is actually a collection class until I learnt C and C++. I wouldn''t know about vector, and I wouldn''t know about list.

Share this post


Link to post
Share on other sites
Since C# uses .net its execution speed is very slow compared to native C++ but compared to managed C++ it is pretty much identical.

C++.net can do just about everything that C# can (except covariant returns ::mutter:: ) and its not tied to just .net so I think, for gaming it has to be the way to go.

If speed isnt critical then using managed (.net) C++ can give you a good productivity gain and the 2003 compiler and IDE is very easy to use.

Regards


BaelWrath

If it is not nailed down it's mine and if I can prise it loose,
it's not nailed down!

[edited by - baelwrath on November 12, 2003 8:42:13 AM]

Share this post


Link to post
Share on other sites
quote:
Original post by BaelWrath
Since C# uses .net its execution speed is very slow compared to native C++ but compared to managed C++ it is pretty much identical.

C++.net can do just about everything that C# can (except covariant returns ::mutter:: ) and its not tied to just .net so I think, for gaming it has to be the way to go.

If speed isnt critical then using managed (.net) C++ can give you a good productivity gain and the 2003 compiler and IDE is very easy to use.

Regards


BaelWrath

If it is not nailed down it's mine and if I can prise it loose,
it's not nailed down!

[edited by - baelwrath on November 12, 2003 8:42:13 AM]



This statement is only correct if you call 95-98% of native execution speed "Very Slow". If you meant anything else than you are sadly mistaken =]

One of the reasons for this is not .NET and the JIT compiler. Please note that when the application is run for the first time it is compiled by the JIT which takes almost no time at all.. and then runs almost identical to native code, although it has all the benefits of a managed environment.

The ONE reason some people deem C# is slow is due to the fact it is still a beta in a way. Although used for many commercial and business appplications, it isn't completely done until version 2.0.

So far with what we've seen in C# 2.0 (due to generics mainly which gets rid of much of the boxing/unboxing issue) it performs about 97-99% of the speed of native C++. Also when you look at the results on Longhorn (the next version of Windows to be released in 2 years) managed code actually runs at about 130% or so of the speed of native code.

Remember native code is able to run in order for "backwards compatability" just like DOS was in Windows 95. Managed code is the future for Windows programming (managed C++, managed C#, managed VB) and will be the most optomized, secure, stable, and overall most native code will phase out. Microsoft chose to push C# the hardest in this area of future development because of the true object-oriented nature of the language, and not being a "language with object-oriented features".


"C++.net can do just about everything that C# can "

- lol I love seeing lines like this. Until you have reflection in C++, ASP.NET, the major productivity boost, and Microsoft pushing it the hardest, no it can't do everything C# can.. which is the reason our whole development team here had to switch over to the language.


[edited by - Imperil on November 12, 2003 9:19:36 AM]

Share this post


Link to post
Share on other sites
My simple answer? If you are new to programming then C# will teach good OO design, and then you can transfer that knowledge over to the more complex but better performing (under some circumstances) C++. C++ is capable of better performance, but you have to code it that way (obviously) and it leaves you open to make machine crashing mistakes C# on the whole won't let you do.

I've programmed in C++ professionally for years, and C# for over a year now.

Different tools for different jobs, always remember that. You get people loyal to a language like they are to their gaming systems (IE PS2 versus X-Box). Don't let yourself get drawn in.

Don't overlook Java either, with excellent free IDEs like Eclipse - plus it's ability to program mobile phone games - which are arguably at similar level of growth as the old Spectrum and C64 days - u may well be able to code the next big thing on the mobile phone platform, with all your dev tools legitimately free.

C# and C++ is a different story - there are freebie compilers out there for windows, but the de-facto industry Windows standard for C++ is real terms is Visual C++6 moving to C++7 (.Net). Although the excellent IDE SharpDevelop is free and open source, it's a bit flakey when compaired to Microsofts offering Visual C#. The catch with the MS stuff is that it's so damn expensive!

C# can be used for games (search for Quake .Net and you'll come up with some interesting stories). If you're not looking to do the next Half-Life 2 - which lets face it you are not when you first start out - you may want to start off with a simplier language that rewards your efforts quicker, and working on little mini games instead of the next Final Fantasy.

Remember alot of people used to say "use C over C++ because performance yadda yadda yadda" - those voices seem to have gone very quiet of late.

[edited by - paulsdsrubbish on November 12, 2003 9:46:40 AM]

[edited by - paulsdsrubbish on November 12, 2003 9:48:40 AM]

Share this post


Link to post
Share on other sites
"Remember alot of people used to say "use C over C++ because performance yadda yadda yadda" - those voices seem to have gone very quiet of late."

- hehe not to mention the "use ASM over C because of performance yadda yadda yadda" from years back =]

Programmers are always scared of the next paradigm shift right before it happens =]

Share this post


Link to post
Share on other sites
quote:
...no it [C++] can''t do everything C# can

Oh, yes, it can. Except for syntax, C++ can do everything that C# can do and more, given the right libraries. Of course, by the time that you''ve collected all of the libraries necessary for things like garbage collection, reflection, delegates, etc., your program will be huge.

Share this post


Link to post
Share on other sites
I can''t answer which language you should choose, but take claims that "language Y is replacing language X" with a grain of salt. According to some reports, C is still the most widely-used language in the world. Not C++. Not Java. Not C#. Apparently, rumors of its demise several years ago were greatly exaggerated.

Of course, if you''re trying to get a job in industry, it''s probably wise to take the lemming path and use what industry is using so that you''re marketable. If you''re just playing around at home, use whatever you want.

--
Dave Mikesell Software & Consulting

Share this post


Link to post
Share on other sites
quote:
Original post by merlin9x9
quote:
...no it [C++] can''t do everything C# can

Oh, yes, it can. Except for syntax, C++ can do everything that C# can do and more, given the right libraries. Of course, by the time that you''ve collected all of the libraries necessary for things like garbage collection, reflection, delegates, etc., your program will be huge.

I don''t buy this argument. Some of these features require support by the implementation, since they utilize information which the C++ compiler throws away at compile-time.

--
AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.
[Project site] [Blog] [RSS] [Browse the source] [IRC channel]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
To answer the question and not feed the flamewar that is stewing, learning *any* language will help you. The important part is the conceptual side of things. Then it all becomes a matter of learning syntax, which you can do in a day or so. You''ll know how a loop works, you just need to know the specific syntactic sugar to make it work.

The easy ones to learn (and also will help you get acquainted with OO-design) are Java and C#. C++ and C are also good ones, and there is plenty of stuff out there. If your on windows and need a cheap compiling suite, run Cygwin and use GCC to practice with. C# you can use Mono, or download the Framework from MS. There are always free compilers, and getting one, settling in and working with it are always the best ways to learn.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Doesn''t anyone cares that C# is proprietary? and that it runs only in windows? I mean, you guys should think that there are a lot of other operating systems out there.

Share this post


Link to post
Share on other sites
quote:
Original post by merlin9x9
quote:
...no it [C++] can''t do everything C# can

Oh, yes, it can. Except for syntax, C++ can do everything that C# can do and more, given the right libraries. Of course, by the time that you''ve collected all of the libraries necessary for things like garbage collection, reflection, delegates, etc., your program will be huge.



Wrong. =]

Garbage Collection:
Yes this could be implemented into C++. Of course if you want one with good performance and as optomized as the .NET CLR please be ready for a good year of development or more =]

Reflection:
Wrong. Reflection can not be used in C++ with libraries or anything of the sort. Reflection relies on both the language and the compiler.

Delegates:
Wrong. You could "mimic" delegates but they wouldn''t be a true implementation given the feature set C# provides for delegates and events. Also why would you want to use delegates in C++ when you can just use function pointers?

ASP.NET:
unmanaged OR managed C++ can''t use this.



Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
Doesn't anyone cares that C# is proprietary? and that it runs only in windows? I mean, you guys should think that there are a lot of other operating systems out there.


Point A: Wrong
Point B: Wrong
Point C: 1/2 Correct

A) C# proprietary? .. wrong. There are open standards for the language. Just because Microsoft developed the language does not mean that it is proprietary. People are freely able to create their own C# compilers, etc. Otherwise you could call Linux proprietary due to the fact Linus developed the language.

B) Wrong it does not only run on the Windows platform. Mono for linux let's it run on that platform, as well as a Mac compiler/framework being built.

C) You are correct because, yes, there are a lot of other operating systems out there.. BUT.. you are wrong in thinking that over 90% of desktop systems don't run Microsoft Windows. You would cater to the 5-10% that don't instead of the 90% that do?



[edited by - Imperil on November 12, 2003 11:24:25 AM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Learn C++, C# is trivial to learn if you know C++ first. Dont be convinced by people like Imperil, people like that have just read about Microsoft''s push towards managed code and paniced thinking C++ will soon be obsolete. It wont, if C++ was going to become obsolete, C++ would split into managed too. But you can always tell people who arnt sure what they are talking about, they are always the ones who feel they have to right huge posts to try and convince you, and themselves, that they have made the right choice in picking C#.

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
Learn C++, C# is trivial to learn if you know C++ first. Dont be convinced by people like Imperil, people like that have just read about Microsoft's push towards managed code and paniced thinking C++ will soon be obsolete. It wont, if C++ was going to become obsolete, C++ would split into managed too. But you can always tell people who arnt sure what they are talking about, they are always the ones who feel they have to right huge posts to try and convince you, and themselves, that they have made the right choice in picking C#.



Obviously this guy doesn't even know how to register a name on a message board, let alone anything about programming paradigms =]

Nowhere in my posts have I said C++ will be obsolete. Unmanaged code on a Windows operating system WILL be obsolete yes, as stated by the makers of the OS.

"It wont, if C++ was going to become obsolete, C++ would split into managed too."

- You say that I do not know what I speak of.. yet you do not know there is a managed C++ already? Meaning that C++ will not become obsolete because of the already large code-base, amount of developers, as well as the ability to write managed.


Also in the professional programming world, the majority of software providers that are switching to C# and .NET for the future is because of the new managed OS and productivity.

You see managed code is the future programming paradigm for Windows. You can use C#, J#, C++, VB.NET, whatever you want and build it in a managed environment. The reason Microsoft and the leading developers are switching to a C# platform is not because it is faster than C++.. managed C# and C++ run at identical speeds with the release of C# 2.0. The reason is that C# supports a better object-oriented model, corrects many of the problems C++ has today (no GC, fixes exception handling, reflection, standard lib that is faster than a turtle), and supports more features.


Also you think C# is trivial once you know C++? Think again. For GOOD C++ developers, yes, this is the case. For the majority of people that are using both C mixed with C++ procedural + oop, no it will not be trivial.

Learning C# is not about the language, as yes it is easy to pick up. It is the design decisions and implementations of such things as delegates, events, ref/out, reflection, etc that are the hard part.



[edited by - Imperil on November 12, 2003 11:51:07 AM]

Share this post


Link to post
Share on other sites
For the book I would like to note C++''s lacking ablitity to multi-thread correctly in an OOP Project. Ever try to create a thread for a window??? And get the messages back to the main window?? Not to mention the other things

delegates ......
events .....


Share this post


Link to post
Share on other sites
I'm sure you, GrouchyIssues4, are a bit confused now with all those differeing opinions!

My advice is this: Learn C++, and do a little C# on the side. Why C++? Because:
  • At the moment C++ is a de facto programming language in the graphics and gaming industriy as well as community.
  • Because of the above, there are many resources on C++ out there; books, sites, tutorials and foras like this with helpful people
  • If you down the road decide to use the .NET Framework you can do that with C++ (that is called Managed C++)
  • OpenGL and DirectX are C/C++ libraries and thus interface better with C++ than with C# and Java (although you can get bindings for those, and other, languages)

    As mentioned, I do recommend to learn a little C# on the side. That would be immensely useful if you, for instance, wanted to do some tools or other apps as well as graphics/games (Imperil is correct - you're extremely productive with C#).

    And, as other posters points out, it's easy to learn C# if you know C++ beforehand.



    "Yeah, I would've killed you, but I'm glad I didn't - the paperwork is a bitch"

    [edited by - rohde on November 12, 2003 11:59:43 AM]

    Share this post


    Link to post
    Share on other sites