2

My question is: Is learning C++ without learning C enough to program any kind of computer programs and get the computer to it`s maximum level (Full Control except the tasks that need Assembly language)? Thank you

2

14 Answers 14

9

Yes, there is no point in learning C first if you want to learn C++. They are two different languages and learning C first is not a requirement.

Everything you can do in C you can do in C++ (probably in a safer way too)

5
  • 5
    I second that. While syntactically C is indeed mostly a subset of C++ (except for the bits that aren't), the two languages have their own, and very distinct, idioms. This starts with arrays (C indices vs. C++ iterators: using C-style arrays in C++ is bad style in most situations), and extends into OOP where the differences in style are blatantly obvious. This advice might seem a bit obvious, but after seeing thousands of lines of really disgusting C/C++ code I really urge you: Do not try to write C code in C++, or vice versa. Write C code in C and C++ code in C++. Flow with the paradigm. Dec 23, 2009 at 12:43
  • I'd like to see a correct C++ program which uses RAII and longjmp please. There are some things you can do in C which C++ has no idiomatic mechanism for. Dec 23, 2009 at 12:43
  • 3
    @Pete Kirkham: Uses longjmp for what? What can you make a C program do using longjmp that can not be done in a C++ program?
    – jalf
    Dec 23, 2009 at 13:04
  • @Patrick: technically yes you are 100% right. But generally speaking most people will disagree that it's C++: it's simply C compiled as C++ (that technically makes it C++, but it's not what people mean) Dec 23, 2009 at 14:57
  • @Patrick: why would anyone use a C++ compiler to compile C code? The only reason I could think of is ignorance of how to use "extern C". Plus, there are subtle differences as C++ is NOT an exact superset of C (e.g. long long, variable length arrays or func in C99). Use the C compiler for C code and save yourself the trouble. Dec 23, 2009 at 15:10
2

I think the important question to ask is 'What do you want to do?'

There are many tasks and situations where neither C or C++ are exactly appropriate. They also present quite a steep learning curve and do not lend themselves to fast results.

If you are starting out I would recommend a simpler language such as Python (or even PHP for web stuff) but don't take my word for it and ask about - form your own opinion.

Knowing C is useful as it lets you know in greater depth what the computer is actually doing, but for the sake of productivity (and your sanity) it's probably best going with something a bit more high-level to start with.

2

This reminds me of the question "Should I learn driving with manual transmission (stick shift) to drive a truck or automatic transmission to drive a car". Different skill sets and usage really. With C you "think" procedurally. With C++ you "think" of Objects. Your entire program is structures differently. True, the "syntax" of C++ is a super-set of C but these are really two different languages. Because most C++ compilers also compile C code, there is a common misunderstanding that C++ is just an extension of C. This is only true about the syntax not the concept. For example, you use the same alphabet to write in English and French but the languages are very different.

I hope this helps.

2
  • Unfortunately, the alphabets of French and English aren't quite identical. Ask any French teacher who has tried to teach Americans how to type all those accents and special characters: tlt.its.psu.edu/suggestions/international/bylanguage/…
    – Telemachus
    Dec 23, 2009 at 14:09
  • Exactly! Just like C++ programmer trying to explain the dot notation to a C programmer :) Dec 23, 2009 at 14:44
1

C++ is a great place to start and yes, you can do everything with it. There's no advantage to learning C unless you are planning on working on platforms where it is particularly well suited, such as embedded electronics.

If you master C++ as a language and the OO concepts behind it you will have no difficulty picking up any other programming language. What's more you'll have a much better appreciation for memory management than you would get if you started with a slightly higher level language such as Java.

Good luck.

1

I think it all depends on the platform you wish to develop for.

If you want to develop applications on the Mac or iPhone you need to use the Cocoa and Cocoa Touch frameworks which are (mostly) written in Objective-C.

If you want to develop games for most consoles you need to use the native frameworks which are almost all written in C++.

I'm not sure what the Windows frameworks use, but I'd guess at C++.

The language you use is secondary to the frameworks you'll need to use for the platform you're developing for.

0

Yes, C++ is (pretty much) a superset of C

2
  • 1
    Except the bits that aren't :-)
    – paxdiablo
    Dec 23, 2009 at 12:17
  • I started in C and moved into C++ and I can't see moving in the other direction would be any more difficult
    – Patrick
    Dec 23, 2009 at 12:24
0

C++ is include all of C features and more other features like the support of OOP, so the answer is Yes you can.

0

it's different languages.. chose depending that you want to do...

1
  • What's more, it's different paradigms. It's different libraries. It's different ways of doing basic things like reading a file or looping over a list, of allocating (and freeing) memory. Dec 23, 2009 at 12:46
0

Yes, you can start learning C++. Start with non-OOP part of C++, which is similar to C. Then you can move to the OOP part. Most of the books teaching C++ from ground up follow this approach.

2
  • 1
    i disagree ... this is a very bad approach ... OO aproach is much more natural and clear ... procedural programming forces you to think the way a computer works ... OOP tries to force the computer to work the way you think ... i myself started with procedural programming ... later, when i started to get my head around OOP, i realized there was a lot of things to let go ... i practically rediscovered programming ...
    – back2dos
    Dec 23, 2009 at 12:51
  • I'm not so sure that there is a correct answer here, but for what it's worth, I find procedural programming far more natural and clear than OO programming (and I find functional programming often clearer than the first two). Humans vary in their styles, from what I hear.
    – Telemachus
    Dec 23, 2009 at 14:06
0

me just learn c++ but no problem in understanding c

c++ is much more supportive and safe than c.

although it is a puls puls version...

0

C++ is all that C is, and then more, so using C++ will not prevent you from doing anything with the computer that you can do in C (although it will in some cases prevent you from writing what in C would normally be an error in any case because C++ compilers use stronger type checking).

Now with respect to "Full Control"; there are some tasks that are the responsibility of the OS, and modern OS's will prevent you from having full control at user level (because processes have to play nicely together). Of course if you are coding for an embedded target, or writing a bootloader or OS, or a kernel mode driver, then you do have full control; and that is why C and C++ are used predominantly for such tasks because they are intrinsically systems-level languages.

0

I think any language is just medium of expressing one's logic, the main thing is your logic which needs to be perfect. First of all you must understand what are the features that could be explored in C++ that are not available in C.

C is known for its simplicity. If you start learning C, you will very well understand that how crisp and clear this language is. However, it is not a compulsion that you should learn C first and then C++; Its just a recommendation.

Learning C first is like playing level 1 of a game, where C++ is level 2 :-) Having said that you can always play level 2 directly and can equally succeed in that, but with a little difficulty. :-)

0

I started by learning C++ and it was fine.

However it wouldn't hurt to have a browse through C before diving into C++. Loosely speaking C is a subset and you will learn the fundamentals there. C++ tends to have some tricky topics to grasp so you'll be safer by having strong foundations.

3
  • Not a strict subset (there are incompatibilities) but close enough for the vast majority of stuff.
    – paxdiablo
    Dec 23, 2009 at 12:18
  • Not a subset, and most of what is common good practices in C is frowned upon in C++. It's better to treat them as distinct languages, and choose one of them to learn, rather than treating one as an introduction to the other.
    – jalf
    Dec 23, 2009 at 13:24
  • Well, realistically if you are developing C++ you will end up having to include/link C libraries so it's definitively not a waste of time. About being a subset, I didn't mean it strictly. There are incompatibilities but 99% of the stuff is there.
    – rui
    Dec 23, 2009 at 13:28
0

If you are starting programming, I would say start with C. It will give many basics and will let you think in a more low-level way than starting C++. You do not need to be the boss in C, just get the basics that will help in the future.

There is a nice article written by Joel Spolsky (joelonsoftware.com) that talks about how to start.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.