C as first language

Started by
40 comments, last by nilkn 15 years, 4 months ago
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.

throw table_exception("(? ???)? ? ???");

Advertisement
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 :)
--------------------------------------Not All Martyrs See Divinity, But At Least You Tried
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.
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.
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++.


[size="2"]Don't talk about writing games, don't write design docs, don't spend your time on web boards. Sit in your house write 20 games when you complete them you will either want to do it the rest of your life or not * Andre Lamothe
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.
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.
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).
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.

PS, lingua franca - the language of the Francs.
If you insist on learning C, this book seems to be good.

This topic is closed to new replies.

Advertisement