Jump to content

Beginner's help

the_noot

I'm sure this is one of many similar topics, and while I did take the time to look through older topics and read through the resources thread, I still have some general questions that I feel would be better answered by some of the veterans on this forum.

 

As a background, I'm a student, first year, electronic and telecommunication engineering. Virtually nill high-school programming experience and some of the basic programming proficiency that was enough to pass a programming course with a half decent mark.

 

Going on however, I really do want to properly learn programming, and the fact that my class lecturer is one of the meaner boys in the bunch is a bonus.

 

We started off with C for the basic programming course, matrix, recursive functions, working with files, structures etcetera. This semester however we have switched over to C++ for data structures and algorithms and the difficulty spiked up considerably due to the simple fact the one course and one laboratory related to pointers were far from enough, thus, I'm personally in a pickle.

 

I'll start off with my questions:

 

As data structures and algorithms are essential for any half decent programmer, and the difference between C and C++ being very small bar some of the integrated libraries which I understand C++ has for making stuff easier, would it be more productive to go back to pointer basics in C, or keep on track with C++? I also need to take my course in mind which kinda implies that I need to make sure I can translate from C to C++ and back constantly.

I understand that C++ is much modern per say, but in real-world application and work field, would it make sense to continue practicing C alongside C++ or just focus on C++?

Talking about Object Oriented programming, I know that C++ is a viable language, however due to uni I'll be very much forced to take the OOP course in Java. Are the core principles for OO the same? Would the switch from C++ to Java be difficult?

I really want to do more work/studying myself, however self teaching is and can be very difficult. Is it more practical to set goals and think up projects in order to teach myself, or should I make use of programming books I have laying around or can get my hands on? Should I try teach myself through youtube tutorials and other popular programming forums? (I have a C++ book for object oriented programming)

 

I'm sorry if my english is abit off or some of my sentences make half-sense, I'm abit tired. xD

 

Link to comment
Share on other sites

Link to post
Share on other sites

It depends on what you end up wanting to do. Since you mentioned you're going for electronics and communications engineering, it would be more prudent to study C than C++ because C is often used in firmware development. Knowing the basics of C++ is still handy though, just in case you come across it. But anything "higher level" like Java or C# is not used in embedded systems where your field is most likely going to be working on.

 

However, knowing how the keywords work in C and getting organization down, you can have some OOP-like concepts in C.

Link to comment
Share on other sites

Link to post
Share on other sites

Well, I think that the question you are asking here is like "should I learn to drive an automatic or a manual car?" when not knowing anything about cars at all. One builds on another, pretty much all things about C are still there in C++.

If you take lots of C code, and write one C++ line, everything will work fine with a C++ compiler. All C code is valid C++ code. For example, you can still work with printf() in C++ instead of std::cout, but you can only use the latter with a C++ compiler.

Answering your question: If you feel more comfortable with C, go with it. Knowledge that you will gain will help you lots with C++, and make you appreciate its features more. However, I think you should still work with C++ topics that are required by your curriculum.

 

Link to comment
Share on other sites

Link to post
Share on other sites

11 minutes ago, the_noot said:

would it be more productive to go back to pointer basics in C, or keep on track with C++?

Stick with C++ since it's what you're using. There's not much point in going back to C when you need to use C++. If you need to go back to basics on a topic, do so with C++

16 minutes ago, the_noot said:

I also need to take my course in mind which kinda implies that I need to make sure I can translate from C to C++ and back constantly.

If that's the case then that's something you may want to practice doing.

20 minutes ago, the_noot said:

would it make sense to continue practicing C alongside C++ or just focus on C++?

It depends.

 

If it's important for your current course, as you implied above, then probably. At least to the extent that you need it. If you already know C well enough for this course then you may not need to do much/any practice with it and just focus on C++.

 

Whether or not you choose to continue learning/improving with C or C++ after your course depends on what you want to do career/hobby wise. There are situations where you would still want/need to use C over C++ and vice versa.

 

For example

When to use C over C++, and C++ over C?

Why would anybody use C over C++?

 

C or C++ (or both) may be critical to what you want to do. Or you may be able to forever walk away from those languages at the end of your course and still have an amazing career.

 

It doesn't hurt to know them though.

32 minutes ago, the_noot said:

Talking about Object Oriented programming, I know that C++ is a viable language, however due to uni I'll be very much forced to take the OOP course in Java. Are the core principles for OO the same?

Yes, the object oriented programming principles are the same regardless of language. The specifics of how they're done can be different depending on language syntax/features, and I expect there may be a few OOP things that C++ will let you do that Java won't, however the general concepts don't change.

51 minutes ago, the_noot said:

Would the switch from C++ to Java be difficult?

In general, no, it shouldn't be too difficult to learn Java given that you already have experience with C and C++. However if you're completely new to OOP, then that can make it difficult. It depends on how easily you grasp the subject. Some people have issues learning and understanding OOP concepts, some don't.

 

Whether you end up liking Java or not is a completely different question though.

39 minutes ago, the_noot said:

I really want to do more work/studying myself, however self teaching is and can be very difficult. Is it more practical to set goals and think up projects in order to teach myself, or should I make use of programming books I have laying around or can get my hands on? Should I try teach myself through youtube tutorials and other popular programming forums? (I have a C++ book for object oriented programming)

Projects are great for practicing what you already know and through doing them you are likely to run into things you don't know how to do.

 

Tutorials, books, videos, etc are great for learning about specific topics however they tend to be limited in showing you how to apply what you're learning. They usually show you some examples but they can't cover everything.

 

You'll want to do both.

Link to comment
Share on other sites

Link to post
Share on other sites

37 minutes ago, Gachr said:

All C code is valid C++ code.

Most C is valid C++ yes, but that hasn't been true for a long time.

1474412270.2748842

Link to comment
Share on other sites

Link to post
Share on other sites

13 hours ago, fizzlesticks said:

Most C is valid C++ yes, but that hasn't been true for a long time.

Oh, really? Any sources?

Link to comment
Share on other sites

Link to post
Share on other sites

Appreciate the help and timely responses. I'll be going back to the basics through C++ and revisit C specifics in the near future when I'm not as constrained by these courses, since C will be necessary for microcontrollers and the sorts specific to my study field.

 

I also wish to consider, in the future, another language that would be a "nice-to-have" on the resume, but I'll leave that to the future and focus on getting familiar and proficient enough in C/C++ (and Java if the course lecturer so demands). Once again, cheers for the help.

Link to comment
Share on other sites

Link to post
Share on other sites

2 hours ago, Gachr said:

Oh, really? Any sources?

int main()
{
    int class = 5;
    return 0;
}

Valid in C (because C has no "class" keyword), invalid in C++.

(Copypasta'd from Stack Overflow.)

Write in C.

Link to comment
Share on other sites

Link to post
Share on other sites

2 hours ago, Gachr said:

Oh, really? Any sources?

One of the important diffirences:

	int a = 10;
	void *b = &a;
	int *c = b;
	printf("%d\n", *c);

Valid C, because implicit pointer conversion is allowed.

Invalid C++, explicit cast required.

Link to comment
Share on other sites

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

×