Sign in to follow this  
JonathanCCC

C as first language

Recommended Posts

hi all, so i've decided to learn and master C as my first language. I just want to make sure I have the standard software etc for doing so. At the moment I am on Windows XP and are using the Miracle C compiler, and that is it. Just to do basic programs and get used to the language. Is this ok? secondly, once i'm comfortable with it, what software should I get to create windows form link software with a GUI? and then after that, what game packages would I look at? I know they are a long way ahead, but i'm just curious. Finally does the visual C++ express compiler compile traditional C? or should I stick with Miracle C? thanks in advance Jonathan

Share this post


Link to post
Share on other sites
Why are you using this "Miracle C" for C programming? Using gcc or the Microsoft compiler makes a lot more sense (to me anyways).

Also, if you're wanting to do Windows and game programming, starting off with C is a "bad idea". It is, quite frankly, an antiquated language that is generally only used nowadays for very low level programming for drivers, microcontrollers, etc. If you want C-like syntax then I highly recommend giving C# a try. You'll thank me and everyone else who backs be up on this.

Share this post


Link to post
Share on other sites
hey thanks for the response

what is this gcc compiler, and which microsoft one are you talking about?

and I know C isn't the best language, the reason i'm wanting to start on it is for fun since I like programming in general, and to get an understanding of low-level programming before jumping upto C#. Just so I can appriciate and understand more of the inner-workings, and hey, i'm just doing it for fun at the moment so i'm not in a rush to build a game anytime soon. But I was just wondering what stuff I could use to play around with in C for GUI's and games, or is it true that it's just not really possible anymore with this out-dated language?

Share this post


Link to post
Share on other sites
GCC compiler.
Microsoft compiler

Writing a GUI in C would be a pain, in my opinion. Certain languages lend themselves to certain tasks. You can create GUIs and games in C, but it would be a lot of work for little or no extra benefit.

Commonly recommended beginner languages are Python and C#.

Share this post


Link to post
Share on other sites
The popular C++ compilers should be compliant with the majority of C. There are some later additions to C (the C99 standards) that I don't think are fully implemented in many C++ compilers, but the older standards are generally okay as far as I know.

I'm still fond of C. It has its place; Linux is still very C oriented, and it's a good language for low-level libraries. But C tends to get unwieldy when working on large applications, and there are more appropriate languages out there for GUI work. There's also a bunch of gotchas that can make it frustrating for beginner programmers; expect a bunch of bewildering debugging sessions. C is still a language that's worth learning - it's good for lower level algorithm implementation that needs to be compiled on different platforms. But beginners tend to get hung up on the syntax and bugs rather than learn the craft of good programming techniques.

I like Python as a less stressful language that's more beginner friendly. Everyone around here says good things about C# too.

Share this post


Link to post
Share on other sites
If you're going to stick with C, I recommend you check out Allegro and SDL, which are both low-level libraries useful for writing games written in C. Unfortunately most of the tutorials you will find are written in C++, but some, like the ones on this visually offensive Allegro tutorial site, are written in such a way that very little C++ is actually used, if any. You could skip the ones on classes and complete the Allegro section with no problem.

Share this post


Link to post
Share on other sites
Quote:
Original post by JonathanCCC
and to get an understanding of low-level programming before jumping upto C#.


Would you train to become a mechanic before applying for a drivers' license? Don't make the task of programming hard for yourself.

Quote:
But I was just wondering what stuff I could use to play around with in C for GUI's


Would you learn how to drift before mastering parallel parking? Writing a program that uses a GUI properly (and avoiding lots of headaches and bizarre workarounds that seem to work most of the time) requires understanding a lot about how to design an *organized* program, and separate the task into its components neatly. Work on simpler problems first.

Quote:
and games


GUI development has nothing to do with game development. You can make a game in any language, from the first programming lesson onward. You just need to expand your definition of "game".

The gcc compiler is probably the best-known one out there, at least among those who've ever used something other than DOS and Windows. "Miracle C", OTOH, I've never heard of, and you can rest assured I've been around a long, long time ;)

Share this post


Link to post
Share on other sites
C may not be very beginner friendly, but it does have some virtues as a first language.

Firstly, C is the "lingua Franka" of computer languages -- The common tongue: just about every single programmer on earth can "speak" in C, even if its not their prefered language. I daresay that more open-source and example code is written in C, as well as code within published papers, than in any other language. Further, the syntax constructs themselves of many more recent languages share a great deal with C -- Objective-C, C++, C#, D and many others.

Second, it really is a "structured assembly language" -- meaning that its easier to see how C translates to machine code than many OOP, dynamic or JIT/interpreted languages are -- at least with the traditional model of what a computer is -- though this is changing with more and more parallel and distributed computers.

Third, most folks seem to grasp procedural programming easier than other styles. OOP, for example, requires too much up-front effort to implement a good design than a fresh-faced programmer is usually able to muster. Functional programming is too much of a head-trip for many, though it seems more natural for those with a particularly strong mathematical bent.

Finally, and anecdotally, C seems to foster an attitude of "do it myself once, then find/make a library" -- Many new languages like Java, or any of the .NET languages have such extensive support libraries that most folks end up never rolling their own, even once. This is not a bad thing in and of itself, in fact its quite contrary in a non-learning environment, but my own oppinion is that doing is the best way of learning -- you simply understand that doubly-linked list more intimately by writing it yourself, and you gain valuable insight into its pre-packaged implimentations (which are for certain faster and better tested than your own.) I guess that whether you see this as a benefit or not is down to whether you're a top-down or a bottom-up kinda person.

Share this post


Link to post
Share on other sites
Quote:
Original post by Ravyne
C may not be very beginner friendly, but it does have some virtues as a first language.

I agree with your arguments. That's why I recommend every programmer learn C. But while I feel C makes a excellent second language, I think it's a bit unwieldy as a very first language. All the extra steps to go through the compiler process, add in header files, function declarations, memory management issues and strange error messages (such as the dreaded seg faults) can be really disheartening to someone who have never programmed before.

I think interpreted languages like Python are a better introduction. Beginners can start with a few commands in an interpreter to get an overview of the language before diving into writing programs. They can also avoid the problems with managing memory and get down to solving programming problems. Once a beginning programmer has got the basics of how to break down a problem into implementable chunks, and how to debug their code in a more friendly language, then they'll be better able to approach a more thorny language like C.

Of course, you might be able to start with C if you've got a C programmer who is good at teaching to help you. My experience in teaching C labs is that most beginners will hit a show stopper problem that requires advice to solve. I feel there's a danger for C beginners that without ready help they might get too frustrated and quit learning programming altogether.

For the record, C wasn't my first langauge. I learned with BASIC. I don't think I'd have picked it up as readily if I didn't already have that experience.

Edit: I might be derailing from the original argument somewhat [smile]. I guess my tip to the OP: if you're learning C and find it a bit too confusing, don't get too frustrated with programming in general. If you feel really stuck, try another higher level language for a bit and plan to come back to C later. And don't be afraid to ask C questions in the this forum when you hit a serious problem!

Share this post


Link to post
Share on other sites
Quote:
Original post by Zahlman
Quote:
Original post by JonathanCCC
and to get an understanding of low-level programming before jumping upto C#.


Would you train to become a mechanic before applying for a drivers' license? Don't make the task of programming hard for yourself.


I basically agree with the rest of your statements, but I really am beginning to tire of this analogy being applied to anything and everything.

Driving a car and fixing one are entirely distinct and no more similar than being a bird watcher is to knowing how to fly. The analogy is inaccurate and shallow in every context I've witnessed it applied.

I would posit that a more apt analogy might be one relating traditional hand-tools to their modern electric counterparts. Like C to C#, the traditional tools:
1 - Offer a certain insight into, and appreciation of, their modern counterparts.
2 - Are a common point of understanding to woodworkers around the world.
3 - Are sometimes more appropriate or suited to the task at hand.
4 - Are sometimes the only option for the task at hand.

Of course, the true test of most analogies are to test the relationship between the subjects' negative aspects. Like C to C#, the traditional tools:
1 - Require more work, but offer greater precision and flexibility in return.
2 - Are most-probably headed into a smaller and smaller niche.
3 - Are held in high regard by their stalwarts.
4 - Are looked upon as antiquated by most.
5 - Are not very productive, in modern terms.
6 - Nevertheless built much of the world around us.

Share this post


Link to post
Share on other sites
bottom line, if you're going to use C, do yourself a favour and learn C++, because C++ includes all of C, which you will learn along the way, but without forcing you to do a lot of VERY ugly things that C will make you do.

By learning C++, you will pretty much learn C, and by the time you're comfortable with C++, you will know all of the reasons C++ is a far better language, and the pitfalls of certain techniques in C. C isn't so much an outdated language, because you can do everything with it that you can in any other language, it's just that C and C++ have outdated standard libraries that are not nearly as relavent as they once were. threading and networking have become just as relevant as string handling and math, but these languages haven't directly addressed them

that being said, i'll mention C#, not because I use it(which i don't, i've played but never had a need to really delv deep), but because if you suggest C++ straight out, the C# crowd get a little offended :)

Share this post


Link to post
Share on other sites
I'll second that...

If you MUST learn C... And that of course is ultimately YOUR choice and YOUR choice alone, then learn C++.

I learned C++ first and had no real intension of learning C... But soon after mastering some of the C++ basics, I wanted to code Window apps using the Win32 API and found that its native language was C.

Anyway to cut a VERY long story short, learning C after C++ was relatively straight forward, for me anyway, and I'm glad that I went ahead and got to grips with that language.

C and C++ are sooo intertwined on many levels, that it's almost possible (almost being the operative word) to assume that they are the same language. They're not of course, but the transition from one to the other is not a daunting task. However, which way around one should learn; C then C++ or vice versa is subject to debate.

I will mention C# in that it IS a language worth considering too. I must admit I wasn't a fan of C# at first. But after using it, I would definitely recommend anyone to give it a try first and THEN judge.

Hell... Learn ALL three. C, C++ and C# all come from that same 'C' family and these languages will all be around (yes C too!) for a long while yet.

Whatever you decide to do... Good Luck!

BTW Do yourself a favour and download the Visual C++ and C# Express compilers from the Microsoft websites. They're totally free and are some of the BEST compilers around.

Share this post


Link to post
Share on other sites
Quote:
Original post by godsenddeath
bottom line, if you're going to use C, do yourself a favour and learn C++, because C++ includes all of C, which you will learn along the way, but without forcing you to do a lot of VERY ugly things that C will make you do.

By learning C++, you will pretty much learn C, and by the time you're comfortable with C++, you will know all of the reasons C++ is a far better language, and the pitfalls of certain techniques in C. C isn't so much an outdated language, because you can do everything with it that you can in any other language, it's just that C and C++ have outdated standard libraries that are not nearly as relavent as they once were. threading and networking have become just as relevant as string handling and math, but these languages haven't directly addressed them

I don't want to drag this into a language war argument, but there are significant differences between C and C++, as well as the sorts of applications they are good for. If you were to properly learn C++, you'd avoid all the C way of doing things in the first place. C++ works at a higher level of abstraction than C, which makes it easier for large applications but less suitable for low level libraries. Plus C is the "lingua franca" of programming languages; if you're writing extensions for other languages, they typically work easier with C than C++. There's also the issue that you're more likely to have a C compiler for an exotic device than one for C++. This isn't to diss C++ for its role in development, but there are perfectly valid reasons to use pure C even today.

Share this post


Link to post
Share on other sites
Quote:
Original post by Trapper Zoid
Quote:
Original post by godsenddeath
bottom line, if you're going to use C, do yourself a favour and learn C++, because C++ includes all of C, which you will learn along the way, but without forcing you to do a lot of VERY ugly things that C will make you do.

By learning C++, you will pretty much learn C, and by the time you're comfortable with C++, you will know all of the reasons C++ is a far better language, and the pitfalls of certain techniques in C. C isn't so much an outdated language, because you can do everything with it that you can in any other language, it's just that C and C++ have outdated standard libraries that are not nearly as relavent as they once were. threading and networking have become just as relevant as string handling and math, but these languages haven't directly addressed them

I don't want to drag this into a language war argument, but there are significant differences between C and C++, as well as the sorts of applications they are good for. If you were to properly learn C++, you'd avoid all the C way of doing things in the first place. C++ works at a higher level of abstraction than C, which makes it easier for large applications but less suitable for low level libraries. Plus C is the "lingua franca" of programming languages; if you're writing extensions for other languages, they typically work easier with C than C++. There's also the issue that you're more likely to have a C compiler for an exotic device than one for C++. This isn't to diss C++ for its role in development, but there are perfectly valid reasons to use pure C even today.

Yeah if you read a modern C++ book like Stroustroup's C is only mentioned in the appendix so C and C++ are quite different if learned properly.
Anyways ditch Miracle C if that is even a real compiler(I thought this post was a joke when I first read that to tell the truth) and use what everyone else uses nowadays i.e. GCC or MS Visual C++.


Share this post


Link to post
Share on other sites
Quote:
Original post by JonathanCCC
and I know C isn't the best language, the reason i'm wanting to start on it is for fun since I like programming in general, and to get an understanding of low-level programming before jumping upto C#.


C++ contains a near-perfect subset of C, but allows you to create much more organized code. You can do anything you would want to do is C, and you can ignore all the glorious C++ features, but they're still there if you want them. For example, you can write some code and require the knowledge of the factorial of 250. You could write a factorial function and call is, but you probably don't want to have such a time-consuming function call. You could just calculate the number and hardcode it in, but you could make a typo and the readability will lower. You could also use template mate-programming to find the answer at compile time. That could be the only C++ thing about your code if you wanted.

Quote:
Original post by Trapper Zoid
I'm still fond of C. It has its place; Linux is still very C oriented, and it's a good language for low-level libraries.


I believe that's because Linus Torvalds hates C++.

Quote:
Original post by Ravyne
Third, most folks seem to grasp procedural programming easier than other styles. OOP, for example, requires too much up-front effort to implement a good design than a fresh-faced programmer is usually able to muster. Functional programming is too much of a head-trip for many, though it seems more natural for those with a particularly strong mathematical bent.


I believe this is why most teachers and tutorials seem not to teach classes very early on. Whether that's a good thing or not. It seems most people learn procedural C++ first and learn object-oriented C++ second.

Quote:
Finally, and anecdotally, C seems to foster an attitude of "do it myself once, then find/make a library"


I agree that that is a very good way to learn. My college C++ teacher taught that way, although I wonder if it wasn't for a lack of knowing the standard library.

This would be a harder learning style for C++, though. You could try to write your own std::list or std::vector, but you probably would have trouble with some of the features. I know the whole point of DIYS is not to make it as good as, just to learn from making it, but I'd want to reproduce every feature.



Whether or not you decide to learn C or C++, I recommend using GCC. It's a very good compiler and does a decant job making your code run faster than you intended.

Then again, there is a philosophy that learning assembly is a good place to start. You really learn the ins and outs of computers that way. I can't say I'm entirely against it. Sure, you could crash your computer every time you run your program, and it's really hard, but you theoretically will come out a very strong, understanding programmer.

Share this post


Link to post
Share on other sites
Quote:
Original post by Splinter of Chaos
Then again, there is a philosophy that learning assembly is a good place to start. You really learn the ins and outs of computers that way. I can't say I'm entirely against it. Sure, you could crash your computer every time you run your program, and it's really hard,


Any modern operating system will completely isolate assembly programs. Sure, they're still interpreted directly by the processor (which reads the machine code instructions and translates them to whatever command set it can execute) but a large variety of operations, including those that could crash or compromise your computer, will simply fail as soon as they are attempted because the operating system does not allow them.

So, don't worry about this: when you learn assembly programming, you can only crash your own program, and only in ways that are typical of C and C++ programming.

Quote:
but you theoretically will come out a very strong, understanding programmer.


No programmer can be strong and understanding after learning only one language, regardless of what that language is. Every language has some things to teach, but no language can teach all of them. For instance, there's no way you can get a monadic interpretation of imperative programming just by using assembly (or C).

Share this post


Link to post
Share on other sites
Quote:
Original post by Oluseyi
Quote:
Original post by Ravyne
C may not be very beginner friendly, but it does have some virtues as a first language.

None of the things you state is a first language benefit.


I disagree, but I freely admit to being a bottom-up person. I don't believe in learning higher-level concepts without first having the base knowledge to at least form a mental model of how things are working behind the scenes.

Being the most common language of articles and tutorials (and similar enough in syntax to many others) certainly is a boon for someone trying to learn.

Being a "structured assembly language" and giving the student an idea of what's going on in the CPU is also beneficial, in my opinion.

I don't see what your argument with my third point was, unless you disagree that procedural languages are typically easier to grasp for most folks.

Quote:
PS, lingua franca - the language of the Francs.


The fine folks at Merriam-Webster would like to disagree.

Share this post


Link to post
Share on other sites
Quote:
Original post by HomerSp
I learned C first and today I kinda regret I did. You'll most of the time end up using a mix between C and C++ and not taking advantage of the C++ std library.


This is one of the best points made here IMHO. Someone said something about it putting you into the mind-set of doing something yourself as well. These 2 points have made my coding not nearly as productive as it could have been, mostly because of a lack of trust for other code, even if its been tested by many others and praised as working. Of course, it is always my code that doesn't work and has bugs.

It's not that C is a bad language at all (IMO), but for me at least, the first language you start with tends to set your brain on a certain way of thinking and makes it harder to break out of this self-inflicted mold.

Cheers
-Scott

Share this post


Link to post
Share on other sites
many thanks for all the replies guys,

I will have a look at the GCC compiler, although I am surprised none of you have heard of this Miracle C one, it was one of the top listed when I googled "c compiler", it's seems ok enough, very simple and basic, but still, i'll check out gcc. The Allegro looks really good too, i'll check that out once i'm fluent in C :).

On the visual c++ 2008 express compiler, I didn't think that could compile standard C? am I wrong? If someone could confirm that it does fine, then i'll probably use that.

I perhaps should of also added in my original post, as I have already decided to learn C, I was just wondering what the best software, compilers, etc to use were. I have programmed a little in C# before, I tried following the XNA tutorial on the xna website, the 2d spaceship one, I created the program but didn't get a full grasp and understanding. But anyway the reason I want to learn C is just because certainly I am a bottom-up kind of person, and to have some experience and understanding in low-level programming. I guess i'm just satisfying my curiosity for these older, less productive, yet arguably more powerful languages. Before long i'll probably move up to C++ and then C# though.

I'm also reading a book on assembly for fun, without actually coding in it, just to try and understand how computers work abit more.

But of course if someone posted on here who was desperate to get game programming as soon as possible I would reccommend C# and XNA, or C++. However I just want to mess around and try programming, then perhaps game programming with C alittle before jumping up to these high level languages, and get spoilt too fast :).

thanks

Jonathan

Share this post


Link to post
Share on other sites
Quote:
Original post by Ravyne
Quote:
Original post by Zahlman
Quote:
Original post by JonathanCCC
and to get an understanding of low-level programming before jumping upto C#.


Would you train to become a mechanic before applying for a drivers' license? Don't make the task of programming hard for yourself.

Driving a car and fixing one are entirely distinct and no more similar than being a bird watcher is to knowing how to fly. The analogy is inaccurate and shallow in every context I've witnessed it applied.


At least to me, this is the point of the analogy.

There are certain aspects of programming that are simply more important than others. Being competent with low-level memory management is an important skill and one I would look for if I were interviewing a programmer for an advanced position, but there are other skills I'd pay much more attention to in the vast majority of cases. I would care much more about whether the programmer understands how to break a problem down into its pieces (the core activity of programming) and how to build a coherent, modular, additive design.

C requires the programmer to spend his time on these less important, tedious aspects. It would be tremendously difficult, if not impossible, for the average person to start with C and learn the principles of good software design and algorithm design at the same time.

Furthermore, it is a common fallacy to think that low-level tasks must be studied only in a correspondingly low-level language. I firmly believe, for example, that one would gain a far superior knowledge of low-level memory management by, say, writing a garbage collector in Scheme than by using C.

Note that this is an argument against C only as a first language, not as a language in general. C has its place in the commercial and industrial world.

Quote:
Original post by popsoftheyear
It's not that C is a bad language at all (IMO), but for me at least, the first language you start with tends to set your brain on a certain way of thinking and makes it harder to break out of this self-inflicted mold.


I believe this is an under-appreciated point. I have mixed opinions on Joel Spolsky, but this is one quote I do agree with:

Quote:
Joel Spolsky
Programming consists of overcoming two things: accidental difficulties, things which are difficult because you happen to be using inadequate programming tools, and things which are actually difficult, which no programming tool or language is going to solve. An example of an accidental difficulty is manual memory management, e.g. “malloc” and “free,” or the singleton classes people create in Java because they don’t have top level functions. An example of something which is actually difficult is dealing with the subtle interactions between different parts of a program, for example, figuring out all the implications of a new feature that you just added.


C is filled with accidental difficulties. I've found in general that many beginners starting with C focus all their time on learning how to work around C's accidental difficulties without ever learning how to solve true programming or computer science problems that are difficult in and of themselves. Further, many come out with the misconception that all languages have these accidental difficulties.

C promotes an antiquated way of thinking about problems and computational processes. Learning C as a first language poses the danger of making it unnecessarily difficult for the programmer to learn modern ways of thinking about processes.

[Edited by - nilkn on December 16, 2008 3:57:39 PM]

Share this post


Link to post
Share on other sites
Quote:

In the visual c++ 2008 express compiler, I didn't think that could compile standard C?

Well, for the most part C++ is a superset of C, so a C++ compiler would usually be able to compile C source.

But even so, the Microsoft compiler does support C.

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