Sign in to follow this  
Felshy

Learning C

Recommended Posts

Felshy    100
I already started to learn C++ and have found it very complicated. I have heard that C is a lot simpler and a tiny bit faster.
Im more concerned with the difficulty of the language than the actual features.
The goal is to be able to make 3d games one day. Im pretty sure I can use OpenGL in C and If I ever need a high level language for the game logic I could use Lua or something.

Does this make sense to do?
Is learning C for the sake of simplicity a good idea?
Will I hit any roadblocks, or will I need to learn c++ at some point?

Share this post


Link to post
Share on other sites
ApochPiQ    22999
C is definitely a much simpler and cleaner language. It'll be a lot faster to learn and slightly easier to master than C++. However, it [i]does[/i] cut you out of a lot of really powerful stuff, and will require more code and more care to handle certain things that C++ can largely automate for you (memory/resource management is a big one; C lacks anything like C++'s RAII idiom).

I would say tough it out and learn C++. You'll sacrifice too much, and C really is [i]not[/i] designed for beginners or for people who want to get stuff done fast.

Alternatively, you could switch entirely to a language which [i]isn't[/i] horrible, like, say, C#, Python, Ruby...

Share this post


Link to post
Share on other sites
Felshy    100
[quote name='ApochPiQ' timestamp='1310457820' post='4834177']
C is definitely a much simpler and cleaner language. It'll be a lot faster to learn and slightly easier to master than C++. However, it [i]does[/i] cut you out of a lot of really powerful stuff, and will require more code and more care to handle certain things that C++ can largely automate for you (memory/resource management is a big one; C lacks anything like C++'s RAII idiom).

I would say tough it out and learn C++. You'll sacrifice too much, and C really is [i]not[/i] designed for beginners or for people who want to get stuff done fast.

Alternatively, you could switch entirely to a language which [i]isn't[/i] horrible, like, say, C#, Python, Ruby...
[/quote]

Well what If I dont really care about the extra code?
If I am a master at C then I just have to write it.
In C++, it will always be frustrating and difficult.


But I would use C# but theres no cross platform or DirectX/OpenGL. I do not want to use XNA. I want to make games the right way.
Python and ruby arent really for 3d games...?

Share this post


Link to post
Share on other sites
Tachikoma    575
Learning C can be useful from an educational standpoint, because many higher level languages are based on the C syntax. Unfortunately you will have to do a lot boilerplate work on your own in C, which usually leads to programming errors. C++ can be little better in that respect, as it introduces some language features that helps you write "safer" code. What's really important about C++ is that it introduces you to concepts, such as object oriented programming, as do other languages, such as C#, etc. OO changes the way you structure code and how you think about programming problems. I think C is a good starting point, but you should not ignore other languages, as you will have to work with them at some point.

Share this post


Link to post
Share on other sites
ApochPiQ    22999
Oh boy.


[list][*]You should [b]always[/b] care about extra code. Extra code is more stuff to type, more stuff that can go wrong, more stuff you have to maintain and remember. More code is [b]BAD.[/b][*]You won't be a master at C any time in the next 10 years, sorry. It takes a long time to get that good at things. By then you'll really, really hate the language and want something more powerful.[*]C++ will [i]not[/i] "always be frustrating and difficult." It only seems that way because you don't know it yet. Give it time. It'll come.[*]C# has DirectX support via XNA, and OpenGL bindings via libraries like Tao.[*]C# is cross-platform. There is nothing tying you to Windows. See the Mono project, for instance.[*]Get rid of this absolutely disgusting notion that there's a "right way" to make games. If the game is playable and fun, you did it right. If the game isn't playable, or isn't fun, you did it wrong. [i]Nobody on this planet should give a flying shit how you made it. That isn't the point.[/i][*]Many 3D games use Python, Lua, Ruby, and other scripting languages for high-level logic. Yeah, you'll have to do some guts-work in a lower-level language, but don't ever make the mistake of thinking that just because you don't want to write a 3D engine in a given language that the language is useless for game development.[/list]

Share this post


Link to post
Share on other sites
Nanook    537
How have you been studying C++ ? If you dont have one you should get a book.. if you really want to make games you should learn C++..

Playing around with C# and XNA could be a good idea as you'll learn to code.. Its not hard to make a transition into C++ later and its alot easier to learn.. you wont be making hardcore games right away anyways.. and with C# and XNA you might not loose your motivation beeing frustrated :)

Share this post


Link to post
Share on other sites
Dragonion    131
[quote name='Felshy' timestamp='1310457390' post='4834175']I already started to learn C++ and have found it very complicated. I have heard that C is a lot simpler and a tiny bit faster.[/quote]
The first thing you should be aware of is that C++ (with few exceptions) possesses all the syntax that C does. For that reason, virtually everything you can write in C will be translated by a C++ compiler the same way a C compiler would do it. The main difference is that C++ also provides the ability to write object-oriented code (along with something called [i]template (meta-)programming[/i]), which makes C++ a significantly more complex language.

As for speed C++ actually has the potential to outperform C (big time, even), provided that 1) you are using a compiler with good optimization capabilities (like Visual C++), and 2) you know what you are doing. The real problem is that if you do [i]not[/i] have a thorough understanding of both the language and how your code is translated to binary instructions by the compiler, your intuitive solution to a given problem may likely be more efficient if you write it in C.

[quote name='Felshy' timestamp='1310458398' post='4834180']But I would use C# but theres no cross platform or DirectX/OpenGL. I do not want to use XNA. I want to make games the right way.
Python and ruby arent really for 3d games...?[/quote]
There are basically two types of developers; those focused on development time, and those focused on efficiency. Personally I belong to the latter, but if have no problem raising the system requirements for your product instead of using a couple of years to research and develop a performance-oriented framework from scratch, and you don't mind using a combination of a gazillion different scripting technologies to get the job done as fast as possible (which -in the end- yields a much more error-prone solution, btw), then by all means write your game in C#, Java, Python, Flash, HTML or whatever requires the smallest amount of work (this is how many modern games are developed anyway). If, on the other hand, you want your code to be as efficient as possible then start with C combined with a basic understanding of assembly programming, and move on to C++ when you feel ready for it.

Share this post


Link to post
Share on other sites
Serapth    6671
[quote name='Felshy' timestamp='1310458398' post='4834180']But I would use C# but theres no cross platform or DirectX/OpenGL. I do not want to use XNA. I want to make games the right way.
[/quote]

Check your preconceived biases at the door, at least until you actually know more than you do. Seriously, where do newbie developers come up with these preconceived stupid ideas. There is no one right way. Hell, it's becoming more and more common for games to be made using a number of languages, especially triple A titles. Also yes, C# *DOES* have DirectX AND OpenGL AND is cross platform.

[quote name='Dragonion' timestamp='1310471078' post='4834251']
There are basically two types of developers; those focused on development time, and those focused on efficiency. Personally I belong to the latter, but if have no problem raising the system requirements for your product instead of using a couple of years to research and develop a performance-oriented framework from scratch, and you don't mind using a combination of a gazillion different scripting technologies to get the job done as fast as possible (which -in the end- yields a much more error-prone solution, btw), then by all means write your game in C#, Java, Python, Flash, HTML or whatever requires the smallest amount of work (this is how many modern games are developed anyway). If, on the other hand, you want your code to be as efficient as possible then start with C combined with a basic understanding of assembly programming, and move on to C++ when you feel ready for it.
[/quote]


... and now I see where people come in with these preconceived ideas. This advice is epically bad, if you are a new developer, ignore this completely. This isn't 1986, starting with C & assembly is about as stupid a way to start as you could come up with. Additionally, your summary of "two kinds of developers" is incredibly short sighted. You especially missed the pragmatic developer, who uses the right tool for the job. Where your bizarro world comment in the mid paragraph about scripting comes from, boggles my mind. First off, the majority of C++ houses these days don't even roll their own engines anymore, it's just a piss poor use of time. Second, in these C++ based games, they still contain a ton of scripting. And no, done right, it is much LESS error prone, as the scripts are effectively sandboxed and more fault tolerant than static code. To say nothing of the various advantagous.

Share this post


Link to post
Share on other sites
Serapth    6671
In regards to the first question, no, starting with C is not a good idea. The libraries are laughably bad, you need to do things that are just horrifically primitive by modern language standards ( manaully null terminating strings? ). Frankly too, C is more or less obsolete, outside of embedded systems and a few other niche markets.

Share this post


Link to post
Share on other sites
Dragonion    131
[quote name='Serapth' timestamp='1310475695' post='4834273']In regards to the first question, no, starting with C is not a good idea. The libraries are laughably bad, you need to do things that are just horrifically primitive by modern language standards ( manaully null terminating strings? ). Frankly too, C is more or less obsolete, outside of embedded systems and a few other niche markets.[/quote]
I agree most of the standard C library is annoyingly cumbersome to work with, but when I suggested starting with C I did so because the syntax of the language is (for the most part) a subset of C++ and relatively easy to approach. I am quite sure you will agree that learning C++ is easier if you already know C.

[quote name='Serapth' timestamp='1310475454' post='4834270']First off, the majority of C++ houses these days don't even roll their own engines anymore, it's just a piss poor use of time.[/quote]
True, but that's because they do it for the money; not for the challenge.

Share this post


Link to post
Share on other sites
BitMaster    8651
[quote name='Dragonion' timestamp='1310477382' post='4834285']
I am quite sure you will agree that learning C++ is easier if you already know C.
[/quote]

In my experience a lot of people who come to C++ from a C background tend to see it as "C++ = C + classes" and are rather horrible C++ programmers with a lot of baggage they need to get rid off before they can improve (if they have the self-reflection ability necessary to make that journey).

Share this post


Link to post
Share on other sites
Dragonion    131
[quote name='BitMaster' timestamp='1310478436' post='4834290']In my experience a lot of people who come to C++ from a C background tend to see it as "C++ = C + classes" and are rather horrible C++ programmers with a lot of baggage they need to get rid off before they can improve (if they have the self-reflection ability necessary to make that journey).[/quote]
I see you point, but you have to draw a thick line between C veteran programmers and people who from the beginning are only planning to learn sufficiently enough about C to move on to C++.

Share this post


Link to post
Share on other sites
rip-off    10976
[quote name='Dragonion' timestamp='1310477382' post='4834285']
I am quite sure you will agree that learning C++ is easier if you already know C.
[/quote]
Yes, if you know C you'll find it easier to start learning C++. However, if you don't know C, I wouldn't recommend starting there to learn C++.

The "hard parts" that are really at the core of both languages (mostly the pervasive assumption that the programmer is correct) are hard regardless of the route taken. There is also the idiomatic differences between the languages, one would spend lots of time having to unlearn C idioms to really allow modern C++ idioms to be useful.

Personally I believe that the way you write programs in two languages has become different enough to make learning C++ by first learning C a harder position to suggest than in times past.

Share this post


Link to post
Share on other sites
Serapth    6671
[quote name='BitMaster' timestamp='1310479633' post='4834299']
I do not agree. As soon as you are under the impression that C++ is just C with a few extra bits glued on you are on a very bad path.
[/quote]


This is true now, but frankly if you were programming when C++ started, it was much less true. In the initial days, C++ really was just C with a few extra bits glued on. Hell, it still compiled down to C in those first days. Then as the language evolved, they grew more and more apart. Now, I agree with you completely, learning C then C++ now really sets you down the road of a number of bad habits, but it wasn't always this way.


As a corollary, if I could go back in time and talk to my future self, I would say learn LISP first ( or F# or something similar if starting out today ). Procedural programming really warps you way of thinking and these days functional programming ( of which LISP was the posterboy ) is really coming to the fore but my mind really really really struggles with it. In using C# it is extremely powerful, but my brain really has to work overtime to do or even read functional code.

Share this post


Link to post
Share on other sites
BitMaster    8651
[quote name='Serapth' timestamp='1310480555' post='4834307']
[quote name='BitMaster' timestamp='1310479633' post='4834299']
I do not agree. As soon as you are under the impression that C++ is just C with a few extra bits glued on you are on a very bad path.
[/quote]


This is true now, but frankly if you were programming when C++ started, it was much less true. In the initial days, C++ really was just C with a few extra bits glued on. Hell, it still compiled down to C in those first days. [...]
[/quote]

That is true, but I was under the impression we were talking about how to learn C++ nowadays and not working on a "if I had a time machine to tell myself..." scenario (which would be better placed in the lounge). ;)

Share this post


Link to post
Share on other sites
Dragonion    131
[quote name='rip-off' timestamp='1310479955' post='4834304']Yes, if you know C you'll find it easier to start learning C++. However, if you don't know C, I wouldn't recommend starting there to learn C++.

The "hard parts" that are really at the core of both languages (mostly the pervasive assumption that the programmer is correct) are hard regardless of the route taken. There is also the idiomatic differences between the languages, one would spend lots of time having to unlearn C idioms to really allow modern C++ idioms to be useful.[/quote]
Perhaps you are right. However, I had personally been using C(99) exclusively for 8 years before I began using C++ and my experience when I swapped was that it had a lot of the features I had been missing in C. Nevertheless, and likely because I had already gotten used to thinking very 'module-oriented' when designing programs in C, the actual paradigm shift from functional/imperative to object-oriented wasn't honestly very hard.

Share this post


Link to post
Share on other sites
Serapth    6671
[quote name='BitMaster' timestamp='1310481997' post='4834322']
[quote name='Serapth' timestamp='1310480555' post='4834307']
[quote name='BitMaster' timestamp='1310479633' post='4834299']
I do not agree. As soon as you are under the impression that C++ is just C with a few extra bits glued on you are on a very bad path.
[/quote]


This is true now, but frankly if you were programming when C++ started, it was much less true. In the initial days, C++ really was just C with a few extra bits glued on. Hell, it still compiled down to C in those first days. [...]
[/quote]

That is true, but I was under the impression we were talking about how to learn C++ nowadays and not working on a "if I had a time machine to tell myself..." scenario (which would be better placed in the lounge). ;)
[/quote]


Hey, allow an old man his senile musings! :)

Share this post


Link to post
Share on other sites
rip-off    10976
[quote]
I believe i'm too old for make a bad choice.
[/quote]
You're never too old to make a bad choice!

[quote]
So what should it be the one ?
[/quote]
There is no "the one".

[quote]
C++?
[/quote]
If you want, though I'd recommend C#.

Share this post


Link to post
Share on other sites
mechulkalan    101
[quote name='rip-off' timestamp='1310574012' post='4834888']
[quote]
I believe i'm too old for make a bad choice.
[/quote]
You're never too old to make a bad choice!

[quote]
So what should it be the one ?
[/quote]
There is no "the one".

[quote]
C++?
[/quote]
If you want, though I'd recommend C#.
[/quote]

Thanks for quick reply. You recommend c# but is there a point that i could say "c# cant provide my needs. I wish i learned c++" ?

Share this post


Link to post
Share on other sites
Serapth    6671
[quote name='mechulkalan' timestamp='1310574733' post='4834894']
[quote name='rip-off' timestamp='1310574012' post='4834888']
[quote]
I believe i'm too old for make a bad choice.
[/quote]
You're never too old to make a bad choice!

[quote]
So what should it be the one ?
[/quote]
There is no "the one".

[quote]
C++?
[/quote]
If you want, though I'd recommend C#.
[/quote]

Thanks for quick reply. You recommend c# but is there a point that i could say "c# cant provide my needs. I wish i learned c++" ?
[/quote]

No, but if you ever decide to make a database app or web app, the opposite is sure as hell true!

Share this post


Link to post
Share on other sites
arbitus    440
[quote name='mechulkalan' timestamp='1310574733' post='4834894']
Thanks for quick reply. You recommend c# but is there a point that i could say "c# cant provide my needs. I wish i learned c++" ?
[/quote]

What makes you think C# can't provide for your needs?

Share this post


Link to post
Share on other sites
mechulkalan    101
[quote name='arbitus' timestamp='1310583119' post='4834945']
[quote name='mechulkalan' timestamp='1310574733' post='4834894']
Thanks for quick reply. You recommend c# but is there a point that i could say "c# cant provide my needs. I wish i learned c++" ?
[/quote]

What makes you think C# can't provide for your needs?
[/quote]

I dont know. Almost everybody keeps saying if you want to develop game you should learn c++. I guess thats the reason

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this