c and games

Started by
34 comments, last by Electrons 15 years, 10 months ago
It's worth noting that pointers aren't really fundamental to programming, nor are memory addresses. What is fundamental about pointers is the referential semantics they provide (which are provided in just about any language capable of nontrivial programs). And memory addresses are more fundamental to machine architecture than programming, which in the abstract doesn't really concern itself with those details.

Remember, C operates on an abstract machine like any other language. At one point it may have been a realistic option to believe that C gives you 'control' and is 'close to the metal,' but on modern CPUs this is almost never true.

On the larger issue, it is more important that somebody start writing games than that they start writing games in [The Most Ideal Language For Beginners]. C wouldn't be my recommendation as a first language to anybody, but if the OP is already more than a few weeks worth of education into the language, trying to get him to switch can be more harmful than not.
Advertisement
I started in Assembly, then moved to C, then to VB, then to C++. I liked C....*ducks from the stones being thrown*
If you want to go down the C lane, then I'd recommend simply going straight to C++. C has a lot of pitfals that C++ has amended. C++ isn't without its own problems but they are often brought out by the more advanced topics.

Some of my gripes with C coming from C++ is:
  • All variables must be declared before any statements (this is a pain in the arse - seriously)
  • You must either typedef a structure (messy) or have 'struct' in front of every use of the structure type (code bloat)
  • No templates bring pointer hacks to the masses

C really is an old language. C++ is almost 30 years old, but its still light years ahead of C.
Quote:Original post by phil67rpg
what is a good starter game using c


Jet Set Willy.
Quote:Original post by thre3dee
If you want to go down the C lane, then I'd recommend simply going straight to C++. C has a lot of pitfals that C++ has amended. C++ isn't without its own problems but they are often brought out by the more advanced topics.

Some of my gripes with C coming from C++ is:
  • All variables must be declared before any statements (this is a pain in the arse - seriously)
  • You must either typedef a structure (messy) or have 'struct' in front of every use of the structure type (code bloat)
  • No templates bring pointer hacks to the masses

C really is an old language. C++ is almost 30 years old, but its still light years ahead of C.


I think it's a good thing that you need to declare all variables before any statements, especially as a beginner because it forces you to really think your code through before you write it, and also it's only in the beginning of every scope - so you can declare variables in the middle of a function if you introduce a new scope with {}.

Just typedef a forward declaration and it wont get messy with recursive structures (I assume that's what you meant?).

Templates I agree with though, really nice thing, but tbh, as a hobby programmer you rarely need that generic programming anyway, if you're coding solo and just starting out you don't exactly care about reusable code and maintainability since you're not gonna be writing apps with 100K+ lines of code.

I actually started out with C++ but have gone over to C because I found the OOP and advanced features of C++ overly complex and confusing, C is much easier to learn and start out with imo.
Quote:Original post by marsong
Quote:Original post by thre3dee
If you want to go down the C lane, then I'd recommend simply going straight to C++. C has a lot of pitfals that C++ has amended. C++ isn't without its own problems but they are often brought out by the more advanced topics.

Some of my gripes with C coming from C++ is:
  • All variables must be declared before any statements (this is a pain in the arse - seriously)
  • You must either typedef a structure (messy) or have 'struct' in front of every use of the structure type (code bloat)
  • No templates bring pointer hacks to the masses

C really is an old language. C++ is almost 30 years old, but its still light years ahead of C.


I think it's a good thing that you need to declare all variables before any statements, especially as a beginner because it forces you to really think your code through before you write it, and also it's only in the beginning of every scope - so you can declare variables in the middle of a function if you introduce a new scope with {}.

Just typedef a forward declaration and it wont get messy with recursive structures (I assume that's what you meant?).

Templates I agree with though, really nice thing, but tbh, as a hobby programmer you rarely need that generic programming anyway, if you're coding solo and just starting out you don't exactly care about reusable code and maintainability since you're not gonna be writing apps with 100K+ lines of code.

I actually started out with C++ but have gone over to C because I found the OOP and advanced features of C++ overly complex and confusing, C is much easier to learn and start out with imo.


Well, C++ is just C with OO. A few differences is syntax here and there but there isn't much of a reason to go to C becaause OO is difficult in C++. Just don't use OO in C++ and you're almost writing C. Its just that, in order to get anywhere in the games industry you'll probablty have to learn OO inevitably whether its in C++ or not.

OO is a blessing not a curse (I hope).
Quote:Marsong:
I think it's a good thing that you need to declare all variables before any statements, especially as a beginner because it forces you to really think your code through before you write it,
It’s actually a bad thing to have to create your variables right up front.

Quote: but tbh, as a hobby programmer you rarely need that generic programming anyway...if you're coding solo and just starting out you don't exactly care about reusable code and maintainability
You sure you want to be saying this?

Quote: C is much easier to learn and start out with imo
No it isn’t. You have little abstraction, and some really awkward design choices for beginners. The lack of a first class string type is very problematic for beginners in C. You can’t learn C string manipulation partially.

Quote:thre3dee:
Well, C++ is just C with OO....Just don't use OO in C++ and you're almost writing C.
Wrong. C++ has a common C subset, but it is not C with some OO tacked on. C++ code and C code are written differently.
Quote:Original post by thre3dee
Well, C++ is just C with OO.


There is a lot to comment on, but I'll just tackle this one point:

C++ is not an object oriented langauge. C++ is distinctly a multi-paradigm langauge, one of those paradigms being object oriented.

C++ supports imperative, generic, object-oriented and functional programming.

If you're strictly using its object oriented facilities, you're using about 25% of C++'s functionality.

C, OTOH, is strictly a single paradigm langauge (imperative).
Quote:Original post by fpsgamer
Quote:Original post by thre3dee
Well, C++ is just C with OO.


There is a lot to comment on, but I'll just tackle this one point:

C++ is not an object oriented langauge. C++ is distinctly a multi-paradigm langauge, one of those paradigms being object oriented.

C++ supports imperative, generic, object-oriented and functional programming.

If you're strictly using its object oriented facilities, you're using about 25% of C++'s functionality.

C, OTOH, is strictly a single paradigm langauge (imperative).


Yeah that quote wasn't put well, but essentially, why explicitly use C when C++ is fundamentally easier to use than C when it comes to the same principles.

What I'm trying to say is that learning imperative (C-like) code in C++ is possible however without the pitfalls of C (such as forward declaration of function variables and the like).

You're better off learning C++ from the beginning instead of C then C++ as it a lot more common in the games development industry.
soo... basically what are the programming languages you would prefer to write codes in...?? if you wanted to write games only,that is...??

This topic is closed to new replies.

Advertisement