C or C++ or C#

Started by
46 comments, last by Sneftel 16 years, 7 months ago
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.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Advertisement
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*.
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.

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)
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.
Quote:Of course justice isn't equal. Rich people can afford lawyers, where poor people get McLawyers.
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

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.
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.
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 ;)
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.

This topic is closed to new replies.

Advertisement