Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


C or C++ or C#


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • This topic is locked This topic is locked
47 replies to this topic

#1 SLaYaH   Members   -  Reputation: 122

Like
0Likes
Like

Posted 28 August 2007 - 12:17 PM

I am stuck trying to decide, originally I was only deciding between C or C++ but now theres C# and I'm not sure what to do. If at all possible I'd like to know pros and cons of each and whcih you would suggest to learn coding for an ALL AROUND programmer, not just for gaming but may be part in gaming. Thanks in advanced.

Sponsor:

#2 Spoonbender   Members   -  Reputation: 1254

Like
0Likes
Like

Posted 28 August 2007 - 12:29 PM

C: Sucks (But used a lot in operating systems, or embedded stuff)
C++: A pain in the ass.
C#: Nice and easy to use.

The best thing to do? Learn all of them.
I'd suggest starting with C# though.

#3 TheTroll   Members   -  Reputation: 882

Like
0Likes
Like

Posted 28 August 2007 - 12:29 PM

A lot depends on what your goals are but I am a big fan of C# now days.

C is mainly used for legacy stuff, micro-controllers and some driver work.

C++ lots of code, examples and tutorials out there. Also a lot of people working in it, so lots of advice. A lot to learn just to get the basics down.

C#, still the new kid of the block, a lot less typing then C++ to get the same thing done. Memory management is taken care of for you. Good libraries.

theTroll

#4 Nick Gravelyn   Members   -  Reputation: 851

Like
0Likes
Like

Posted 28 August 2007 - 12:38 PM

I'd agree with learn all of them.

C - I don't mind so much. It takes a bit to get comfortable with pointers and memory management, but once you get it you're all set.

C++ - I think of this as a necessary evil. I like a lot of the OO features in C++, but I hate some of the dumb notation (cout << "Hello World"; looks strange with the << compared to C's printf("Hello World!");). It's all preference though.

C# - I LOVE C#. I use XNA and .NET for all my primary programming. I recently started working with C# in OS X too because I liked it so much.

So I'd say learn C# first because it has a little bit easier learning curve. Then take on C because it'll probably be useful at some point to know it. Then learn C++. C++ builds a bit on C so knowing C will help you a lot with C++.

#5 Palidine   Members   -  Reputation: 1279

Like
0Likes
Like

Posted 28 August 2007 - 12:44 PM

C# is the easiest beginner language of the three

C++ you'll need to get a job in the game biz

C is good to know

-me

#6 cshowe   Members   -  Reputation: 360

Like
0Likes
Like

Posted 28 August 2007 - 12:54 PM

I agree with everyone - C# is a great language to start with

Quote:
Original post by TheTroll
C++ lots of code, examples and tutorials out there. Also a lot of people working in it, so lots of advice. A lot to learn just to get the basics down.


While this is true an enormous number of tutorials on the internet are complete crap and teach terrible habits. For some reason there is more misinformation about C++ floating around the net than most other langauges.



#7 D_Tr   Members   -  Reputation: 362

Like
0Likes
Like

Posted 28 August 2007 - 12:57 PM

Personally i found c++'s extra challenge over c# interesting (pointers, memory management), but it's a matter of taste. Especially if you know c++, it will be really easy to learn the other 2. The same holds for c# to some extend. I really can't think of a reason to stick to pure c when c++'s oop features make your life so much easier, so my suggestion is: Try c# and c++ and pick the one you like most. Then learn the other one too if you want; it will be easy.

#8 Ravyne   GDNet+   -  Reputation: 7743

Like
0Likes
Like

Posted 28 August 2007 - 02:12 PM

It depends on what you want to get from your learning experience. C# is probably the easiest to learn, in part because the .net framework (its standard library) is very thorough and its API reflects its RAD (Rapid Application Development) origins. You feel very productive with C#.

On the other hand, C is a great language to learn how the computer works as a machine, because it provides no high-level abstractions of its own and essentially frees the programmer to do whatever they wish (Hardware/OS restrictions aside.) You can, for example, impliment features in C that are commonly found in OO languages like C++ or C#, such as polymorphism. C can give you a window into the workings of things that you might take for granted in another language. Another plus is that C is a much smaller language than, for example, C++ (in both the number of keywords and the scope of its built-in features) so you can get your head around it more quickly.

C++ is, to a certain extent, the oft-maligned industry standard. Realistically speaking, C++ is the language you must know to develop games (and most other software) professionally, at least for now. Its not a bad language, but its not a great one either. In the years since (and some would even say prior to) it's creation, more practical and elegant solutions have been devised to many of the issues it was created to address. There are certainly better Object-oriented languages than C++. There are certainly better Procedural, Functional and Aspect-Oriented languages as well. Where those languages typically "fail", is that they support one paradigm really well at the expense of the others -- C++, on the other hand, is generally considered to be a multi-paradigm language: It doesn't reign over any one paradigm, but it can do them all with varying levels of effort and success.

Its a bit like you're going on a trip abroad and need to hire a translator. If you're just visiting France, it makes sense to hire someone fluent in French -- but if you're taking a trip across Europe, it makes more sense to hire a translator who, while not fluent any one of the languages in question, speaks them all well enough. Sometimes you can't, for various reasons, hire a new translator for every region you visit. The same is often true in the professional software world -- most of the time you can't choose the best language for the job with each new project. This, combined with easy migration from C, is why C++ is the dominant language today, in my opinion.


Which language is best for a beginner though? Its hard to say. I'll go out on a very short limb and say that its not C++. Its simply not a language which has a scope that's fit for a beginner. Personally, I went from C to C++, and had prior experience with various BASIC dialects. This was a fit for me because I'm the type of person who likes to learn from the bottom up. For those more inclined to the top-down approach, C# will probably provide more immediate satisfaction. In either case, C++ will have to be learned down the road if you intend to pursue programming professionally. Even if you don't end up using it as your primary language, its position as a very popular, multi-paradigm language has essentially made it the language of the masses, so even if you do not write it, you still must be able to read and understand it.

#9 cshowe   Members   -  Reputation: 360

Like
0Likes
Like

Posted 28 August 2007 - 02:33 PM

Quote:
Original post by ravyne2001
On the other hand, C is a great language to learn how the computer works as a machine


No it isn't. C is an abstraction like every other language and has very to do with how the computer works as a machine. There have been numerous posts by myself an others about this misconception. There is one language that will help you learn how the computer works as a machine and it's the appropriate assembly language.

C is useful because there is a C compiler on virtually every platform you can imagine and because its runtime is very small. Very few other languages can make this claim (Forth comes to mind).


#10 SLaYaH   Members   -  Reputation: 122

Like
0Likes
Like

Posted 28 August 2007 - 04:45 PM

Okay from what I have read, and thank EVERYONE that has replied for their replys again I really appreciate your time.

I should learn C# for the time being because it is the easiest language to start out with, then move on to C++ for game dev, and knowing some C would be good on the side.

What would be the preferred C# compiler?
Should I start learning C# from the workshop you guys have here ?

Thanks in advanced again.

#11 Promit   Moderators   -  Reputation: 7335

Like
0Likes
Like

Posted 28 August 2007 - 04:51 PM

Quote:
Original post by cshowe
There is one language that will help you learn how the computer works as a machine and it's the appropriate assembly language.
Well, no. Assembly is a bit better than C in terms of exposing you to the details, but there's still so much that is hidden from direct view that simply learning to write assembly is woefully inadequate.

#12 Hodgman   Moderators   -  Reputation: 30926

Like
0Likes
Like

Posted 28 August 2007 - 04:56 PM

Quote:
Original post by cshowe
Quote:
Original post by ravyne2001
On the other hand, C is a great language to learn how the computer works as a machine

No it isn't. C is an abstraction like every other language and has very [little] to do with how the computer works as a machine. There have been numerous posts by myself an others about this misconception. There is one language that will help you learn how the computer works as a machine and it's the appropriate assembly language.

Stop being argumentative just for the sake of it :P
You're not seeing the woods for the trees...

C is *closer* to machine level than higher level languages like C# (i.e. it has raw pointers, can be freely mixed with assembly code, etc...).
Everyone (including ravyne) knows C isn't machine level, but it's C L O S E R.

e.g. #1 Learning how to deal with strings correctly in C will teach you a lot more about "how the computer works as a machine" compared to using a C++/C#/Java/etc string class.

e.g. #2 You can write a program in C that accepts an arbitrary hexadecimal value from the user and tries to read 17 bytes from that memory address (which may well cause a seg-fault etc...). Higher languages such as C#/Java won't let you do silly low-level things like this because they are *more abstracted*.

#13 cshowe   Members   -  Reputation: 360

Like
0Likes
Like

Posted 28 August 2007 - 05:00 PM

Quote:
Original post by Promit
Quote:
Original post by cshowe
There is one language that will help you learn how the computer works as a machine and it's the appropriate assembly language.
Well, no. Assembly is a bit better than C in terms of exposing you to the details, but there's still so much that is hidden from direct view that simply learning to write assembly is woefully inadequate.


Yeah that's a good point actually. I'm so used to thinking of assembly only in ring 0 that I forgot that it's easy to learn it without all the architecture stuff.



#14 Nick Gravelyn   Members   -  Reputation: 851

Like
0Likes
Like

Posted 28 August 2007 - 05:01 PM

Quote:
Original post by SLaYaH
Okay from what I have read, and thank EVERYONE that has replied for their replys again I really appreciate your time.

I should learn C# for the time being because it is the easiest language to start out with, then move on to C++ for game dev, and knowing some C would be good on the side.

What would be the preferred C# compiler?
Should I start learning C# from the workshop you guys have here ?

Thanks in advanced again.


The workshop's probably a good idea. Otherwise you can grab a cheap C# book for probably less than $20.

As for compilers, there's really only two that are used: Microsoft Visual C# (you can download Visual C# Express for free) and the Mono Project. Being that you're likely on Windows, get Visual C#. Mono is great if you're doing C# on Mac or Linux, but on Windows there's really no point. Go download Visual C# Express and that'll be everything you need. (Edit: You might also want to download Visual C# Express SP1)

#15 KG_Brad   Members   -  Reputation: 134

Like
0Likes
Like

Posted 28 August 2007 - 05:06 PM

I prefer using C. There are some newer games programmed in C (e.g.: Halo, City of Heroes/Villains)

Also, John Carmack used C for every id project up to (but not including) Doom 3.

#16 cshowe   Members   -  Reputation: 360

Like
0Likes
Like

Posted 28 August 2007 - 05:12 PM

Quote:
Original post by Hodgman
good points


I'm not sure I really agree. As you state there are two things that C allows you to do that managed languages don't One is pointers and direct access to "memory", the other is integration with assembly.

The first is really just another (huge) abstraction. Even in managed languages there is some sense that you have 4GB of memory to allocate and that it's stored in memory some place and that you can refer to these things by addresses (both C# and Java have references). On the other hand even in C you're living in a flat address space by yourself - an abstraction that is very far from the actuality of the machine. So I'm not sure that pointers actually teach you that much more about the machine.

I think that people tend to associate C with understanding the computer because it's traditionally used in operating system programming, device drivers, and other truly low level programming. Here the interface with assembly is essential to actually making things work. But learning hello world in C and hello world in C# teaches you exactly the same amount about computers. Just because a program is written in C doesn't mean that it's teaching you about low level machine architecture (as Promit pointed out neither does assembly). But telling beginners that they'll come to great understanding about the way the computer works by learning C is not accurate or particularly helpful - they'll understand how a computer works by studying systems architecture and not by learning a language.

All that said I do agree that C is slightly less abstracted than C# so maybe I'm just nitpicking and derailing the thread



#17 Xai   Crossbones+   -  Reputation: 1456

Like
0Likes
Like

Posted 28 August 2007 - 05:20 PM

Quote:
Original post by cshowe
Quote:
Original post by ravyne2001
On the other hand, C is a great language to learn how the computer works as a machine


No it isn't. C is an abstraction like every other language and has very to do with how the computer works as a machine. There have been numerous posts by myself an others about this misconception. There is one language that will help you learn how the computer works as a machine and it's the appropriate assembly language.

C is useful because there is a C compiler on virtually every platform you can imagine and because its runtime is very small. Very few other languages can make this claim (Forth comes to mind).


do you really not believe that C is a good approximation of the VIRTUAL MACHINE that most other development is built upon? People don't design a language like ruby out of the available pieces of assembly language for a particular system like PowerPC or PDP-11, they design it abstractly, then map it back to the C abstraction (or something sitting on top of it).

C is and has been the near-universal lowest-level programming "machine" for cross-platform development since at least the late 80s. Sure there are others and always have and will be. Sure some people need raw assembly language - primarily as an optimization of the implementation of something, NOT to design with.

P.S. Sorry for hijacking the thread.

#18 Nathan Baum   Members   -  Reputation: 1027

Like
0Likes
Like

Posted 28 August 2007 - 05:25 PM

Quote:
Original post by Hodgman
C is *closer* to machine level than higher level languages like C# (i.e. it has raw pointers, can be freely mixed with assembly code, etc...).

No it can't. Certain implementations of C offer inline assembly. How "freely" the two can be mixed is highly variable. And C# has pointers, and at least one C# compiler supports inline MSIL assembly. So, you're wrong all around, basically.
Quote:

e.g. #1 Learning how to deal with strings correctly in C will teach you a lot more about "how the computer works as a machine" compared to using a C++/C#/Java/etc string class.

No, it'll teach you about how C-style strings work. Given that they work the same on all implementations of C, even when running on machines with wildly differing architectures, that should be a clue that string handling doesn't reveal the secrets of "how the computer works as a machine".
Quote:

e.g. #2 You can write a program in C that accepts an arbitrary hexadecimal value from the user and tries to read 17 bytes from that memory address (which may well cause a seg-fault etc...). Higher languages such as C#/Java won't let you do silly low-level things like this because they are *more abstracted*.

C# will let you do silly things like that, not that it matters. The ability to crash your program by probing random memory addresses does not make a language "closer to the metal". BASIC allowed you to probe random memory addresses, yet it was, in many ways, "higher level" than C.

#19 Hodgman   Moderators   -  Reputation: 30926

Like
0Likes
Like

Posted 28 August 2007 - 05:28 PM

Quote:
Original post by cshowe
they'll understand how a computer works by studying systems architecture and not by learning a language.

You hit the nail on the head there.

Learning to use C without understanding how the OS works probably just creates more voodoo/cargo-cult coders ;)


#20 Nathan Baum   Members   -  Reputation: 1027

Like
0Likes
Like

Posted 28 August 2007 - 05:33 PM

Quote:
Original post by Xai
do you really not believe that C is a good approximation of the VIRTUAL MACHINE that most other development is built upon?

No. C is an abstraction of machines that were cutting edge several decades ago. Most modern programs are developed on machines where C's view of the world just isn't applicable. "C the language" doesn't understand that many computers have more than one processor, or that memory is arranged in a heirarchy of caches, amongst other things.

A language which was actually designed to represent the realities of modern computer hardware would contain explicit language-level support for multiprocessing and cache-aware memory control.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS