If I already know C++, should I learn C?

Hello. I know C++ very well, and I was wondering what other languages could I learn? I already know Python, Ruby, HTML(5), XML, CSS(3), JavaScript, jQuery, PHP, C++ and very basic MySQL. So I was browsing the web and I saw a language called 'Perl'. I tried to look for tutorials but had no luck. I have heard it is a C/C++ type language in that the syntax is similar. Having no luck finding a tutorial for Perl I thought 'Wait a second! I'm such a dummy! Why don't I learn C? After all, I already know C++!'.

So is there a point in learning C if I already know C++? Is there much of a difference? I have heard that if you write C code in a C++ compiler it will run fine, but not the other way around. Is this true?

Another question I have in mind: On the internet I have heard people saying that PHP is interpreted by C, and has similar syntax to C. Is this true also?

Sorry if these questions sound a bit idiotic, I'm just curious and can't seem to find the answer on the internet.

ANY help is appreciated! Thanks!
So is there a point in learning C if I already know C++?


If you know C++, then you already know 98% of [the rules of] C.

The major differences in C:

1) No operator overloading
2) No function overloading
3) No classes
4) No templates
5) structs exist in a separate namespace:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
struct A
{
    //...
};

typedef struct
{
    //...
} B;

int main()
{
    A a; // compiler error, 'A' does not exist in this namespace
    struct A a2;  // OK
    B b;  // OK, the struct is typedef'd to be in this namespace
}


There are a few other differences, but really, that's kind of it.

The biggest part about "learning C" is style differences. Just because you know the language rules doesn't mean you know how to use them properly.


I have heard that if you write C code in a C++ compiler it will run fine, but not the other way around. Is this true?


A lot of the time, yes that's true. C++ is mostly backwards compatible with C. However it is very possible to write C code that will not compile as C++... usually by using a C++ keyword as a variable name or something.

On the internet I have heard people saying that PHP is interpreted by C


That depends on the software doing the interpreting.

and has similar syntax to C. Is this true also?


C++, C#, PHP, Java, Javascript, D, and about a dozen other languages all have "C-like" syntax.
Thanks for the help! I know C does not have classes, because C++ was originally called 'C with classes'. You have helped me out a lot. I dont think I will learn C, because it seems like it's C++'s 'Younger brother' that cant do as much.

Again, this has cleared up a lot of things for me. Thanks! ;-)
There are such languages as for example C#, Java...

By the way the difference between an experienced programmer and a beginner is that if the beginner open a book on some unknown language and see a familiar language consttruction as for example the while loop he says: " I know already this language!". The experienced programmer after reading the book from the very beginning to the end says: "I learned some basics of this new language.".:)


Unfortunately opposite to you I can not say that I know already C++.:)
Last edited on
The C++ environment has a bit of baggage to support some of those wonderful features that C doesn't have. So C still has its ways of doing things and its place. But for many it's not worth considering.
Topic archived. No new replies allowed.