Best approach for learning C++

  • C/C++
  • Thread starter cogneurodude
  • Start date
  • Tags
    Approach C++
In summary, the conversation discusses the need for learning programming skills before attending a cognitive neuroscience PhD program and the options for doing so. The individual is looking for suggestions on the best way to learn C++ and UNIX, and whether it is possible to learn programming on their own. Suggestions are given to try writing a simple program and seeking help from online forums. The conversation also touches on the importance of understanding flow control and state in programming.
  • #1
cogneurodude
6
0
Hello all,

I'll hopefully be attending a cognitive neuroscience PhD program next fall and I'd like to learn some programming beforehand (having programming skills helps for lots of neuroimaging labs) Labs I've worked in used UNIX and MATLAB and I'd really like to improve my knowledge before I go to graduate school.

My question is, what is the best way to do this considering my options?
I don't have much money and I can't take any courses at school in programming next semester.

Is there a good C/C++ website that offers good training for beginners that anyone recommends? A quick google search found several but I'm not sure if which one to look into.

As for UNIX, I was lucky enough to find a UNIX textbook and I have linux installed as a virtual machine so I'm set there.

Can computer programming be learned well on one's own? Would it help to meet with a CS professor next semester every other week or so to help me along?

I know my questions might be hard to answer so I appreciate any feedback!

Thanks!
 
Technology news on Phys.org
  • #2
Think of something you would like to write a program to do. KEEP IT SIMPLE, no GUI. Possibly something like a program that gets a random number, and loops until the user guesses it. Track down all the info you need to write it, do as best you can, but at least get a working product. It doesn't matter how crappy it is. One you've got your complete, but crappy program, come here, or go to a C++ board, and ask for suggestions on what you did wrong and tips about how to do better next time. This will help you gain confidence from successfully writing it on your own, and yet you still get to gain from the insights of experienced forum members. One reasonably confident, I suggest you participate in a C/C++ forum for a while. You get to help those in your place now, while learning from your more experienced peers who are also helping, and correcting you when you are wrong. The concept is not unlike the concept behind cooperative projects in formal schooling, in how it is meant to allow independence while also learning from peers.

Since your in neuroscience, a project you could use as a metric of your mastery of C++ could be a neural network, they're fun, but hard. Once you think you've mastered C++, I suggest you learn Haskell, THE language for AI and stuff like that.
 
  • #4
Thank you both for your replies!

I downloaded Visual C++ 2005 from softonic and I started looking more into online C++ help and online forums.

I like your suggestion,tylerH, about trying to write a simple program, but how do I even begin this task without a C++ textbook?

The pdf book that e1lsaman suggested looks pretty cool but it seems pretty advanced for me because the author says that he assumes the reader knows C.

I know I seem incredibly incompetent, but I am :P

I'm just looking for how to get started learning C++ with minimal programming experience
so I can obtain a working proficiency with MATLAB.
 
  • #5
cogneurodude said:
Hello all,

I'll hopefully be attending a cognitive neuroscience PhD program next fall and I'd like to learn some programming beforehand (having programming skills helps for lots of neuroimaging labs) Labs I've worked in used UNIX and MATLAB and I'd really like to improve my knowledge before I go to graduate school.

My question is, what is the best way to do this considering my options?
I don't have much money and I can't take any courses at school in programming next semester.

Is there a good C/C++ website that offers good training for beginners that anyone recommends? A quick google search found several but I'm not sure if which one to look into.

As for UNIX, I was lucky enough to find a UNIX textbook and I have linux installed as a virtual machine so I'm set there.

Can computer programming be learned well on one's own? Would it help to meet with a CS professor next semester every other week or so to help me along?

I know my questions might be hard to answer so I appreciate any feedback!

Thanks!

Hey there cogneurodude and welcome to the forums.

I used to work as a programmer but I'm nearly finished doing a math double major degree. I'll try and keep my advice relevant, concise and to the point.

With regards to learning C++, you should note that C++ is simply the C language with a bunch of extensions.

My advice when learning programming for the first time is to not get tangled with the idea of learning a high level language getting lost in definitions, features and so forth. I'll give you some ideas of what I think are important in any kind of programming:

1) Flow control

Although there are dozens and dozens of language each with their upsides and downsides, the fact is that computers (for the most part) are machines that execute procedural commands.

Given this, you need to understand what the flow control of a program is and imagine what it would look like in your head.

Its critical that you know how things are executed in all environments because if something goes wrong and you don't know the flow control of the program, you won't be able to fix it.

2) State

The next thing you need to do is imagine the state of your program. As you do more programming and go from your simple 20 line program in int main to your thousands if not hundreds of thousands of lines of code for some complex task, you will able to visualize what is going on and the relationships between the variables and the functions that use them.

You have to know state in order to fix problems. For example you may have not initialized a pointer, or a variable might be "out of bounds" or something else.

To get used to this, learn to write programs that check and correct bad states and make sure that everything has a starting value and that you write code in a way that guarantees a function will run if its variables are in a valid state.

3) Structure

When you start off you'll probably write some simple programs with ints, floats, doubles and so on, but soon you're going to have to create more organized and less redundant code. With this you need to be aware of structure.

Structure is simply some organization of data. In C,C++ you will use the struct keyword to define structure.

Before you learn things native to C++ like object oriented programming consisting of things like inheritance, polymorphism, encapsulation, virtual definitions and so on, you need to understand basic structure. Its easy to understand how things like this work if you understand how these things look in memory. Typically when you inherit from a base class you are simply stacking structures on top of each other in memory and depending on the rules you add function callbacks and so on, but I won't go into this as it will probably be confusing.

These things are things that are essential for any kind of programming. You have to see the forest from the trees if you are to become proficient. Keep the above in mind when you are learning whatever language you want to learn.

For C++ there is a book calling Thinking in C++ by Eckel and if things haven't changed, it should be free for download from his or an affiliate website.

Of course there are tonnes more things to become good at programming, but I think the above will set you up to be a better programmer than if you just read a book that explains the language and gives some examples: again its seeing the forest from the trees.

Good luck!
 
  • #6
chiro said:
Hey there cogneurodude and welcome to the forums.

I used to work as a programmer but I'm nearly finished doing a math double major degree. I'll try and keep my advice relevant, concise and to the point.

With regards to learning C++, you should note that C++ is simply the C language with a bunch of extensions.

My advice when learning programming for the first time is to not get tangled with the idea of learning a high level language getting lost in definitions, features and so forth. I'll give you some ideas of what I think are important in any kind of programming:

1) Flow control

Although there are dozens and dozens of language each with their upsides and downsides, the fact is that computers (for the most part) are machines that execute procedural commands.

Given this, you need to understand what the flow control of a program is and imagine what it would look like in your head.

Its critical that you know how things are executed in all environments because if something goes wrong and you don't know the flow control of the program, you won't be able to fix it.

2) State

The next thing you need to do is imagine the state of your program. As you do more programming and go from your simple 20 line program in int main to your thousands if not hundreds of thousands of lines of code for some complex task, you will able to visualize what is going on and the relationships between the variables and the functions that use them.

You have to know state in order to fix problems. For example you may have not initialized a pointer, or a variable might be "out of bounds" or something else.

To get used to this, learn to write programs that check and correct bad states and make sure that everything has a starting value and that you write code in a way that guarantees a function will run if its variables are in a valid state.

3) Structure

When you start off you'll probably write some simple programs with ints, floats, doubles and so on, but soon you're going to have to create more organized and less redundant code. With this you need to be aware of structure.

Structure is simply some organization of data. In C,C++ you will use the struct keyword to define structure.

Before you learn things native to C++ like object oriented programming consisting of things like inheritance, polymorphism, encapsulation, virtual definitions and so on, you need to understand basic structure. Its easy to understand how things like this work if you understand how these things look in memory. Typically when you inherit from a base class you are simply stacking structures on top of each other in memory and depending on the rules you add function callbacks and so on, but I won't go into this as it will probably be confusing.

These things are things that are essential for any kind of programming. You have to see the forest from the trees if you are to become proficient. Keep the above in mind when you are learning whatever language you want to learn.

For C++ there is a book calling Thinking in C++ by Eckel and if things haven't changed, it should be free for download from his or an affiliate website.

Of course there are tonnes more things to become good at programming, but I think the above will set you up to be a better programmer than if you just read a book that explains the language and gives some examples: again its seeing the forest from the trees.

Good luck!

Thank you so much for your informative reply!

I understand your points but I still feel pretty overwhelmed with learning C++.
I don't have much of a programming background or quantitative background for that matter so that's probably my biggest problem. I'm starting to work through a Visual Basic Textbook and do some of the exercises there. Is it a good idea to learn a simpler language like visual basic before trying to tackle C++? (Visual Basic is still important for me to learn because it is used in E-Prime.)

When I start reading the book by Eckels or reading about C++ online I get lost quickly.. is this normal given my lack of background or am I just slow?
 
  • #7
cogneurodude said:
Thank you so much for your informative reply!

I understand your points but I still feel pretty overwhelmed with learning C++.
I don't have much of a programming background or quantitative background for that matter so that's probably my biggest problem. I'm starting to work through a Visual Basic Textbook and do some of the exercises there. Is it a good idea to learn a simpler language like visual basic before trying to tackle C++? (Visual Basic is still important for me to learn because it is used in E-Prime.)

When I start reading the book by Eckels or reading about C++ online I get lost quickly.. is this normal given my lack of background or am I just slow?

It does take a bit of practice and a bit of banging your head against the wall to become proficient with programming.

With Visual Basic, I think its good to say a quick and dirty prototype up and running because you can easily create a few GUI widgets and the callback is easy to write and the syntax is easy.

I would however not recommend you use VB as a learning language. Why? They are basically the reasons I spelled out in my previous post. The first one is that the flow control of visual basic is event driven where you basically have a tonne of events and you have a callback for each event. In saying this you want to learn exactly how to direct the flow of your program and have complete control over this.

Another problem are the types that VB has. VB does have the option of enforcing data be treated in the right way if you explicitly DIM the variable (eg Dim i1 as Integer), but otherwise you can use variables that have not been explicitly defined. When you are learning this is a major trap because if you get unexpected behavior which causes your program to crash, you may end up searching for a variable that doesn't even exist.

Since you know C, learning C++ is the next logical step. Keep in mind the things I have said in my first post on the subject and hopefully things will get easier.

If you have any specific questions I'll do my best to answer them.
 

Related to Best approach for learning C++

1. What is the best way to start learning C++?

The best way to start learning C++ is to first familiarize yourself with the basic syntax and concepts of the language. This can be done through online tutorials, textbooks, or classes. It is important to also practice writing code and to try out different exercises to solidify your understanding.

2. How long does it take to learn C++?

The time it takes to learn C++ varies for each individual. It depends on your prior programming experience, the amount of time you dedicate to learning, and your learning style. Generally, it can take several months to become comfortable with the language and its advanced features.

3. What resources are available for learning C++?

There are numerous resources available for learning C++, including online tutorials, textbooks, video courses, and coding communities. It is important to find resources that suit your learning style and to use a combination of different resources for a well-rounded understanding.

4. Is C++ difficult to learn?

C++ can be challenging to learn, especially for beginners with no prior programming experience. It has a steep learning curve and requires a strong understanding of computer science principles. However, with dedication and practice, anyone can learn C++.

5. Can I use C++ for web development?

C++ is not typically used for web development, as it is a low-level programming language that is better suited for systems programming. However, there are frameworks and libraries available that allow for web development using C++, such as Wt and CPPCMS.

Similar threads

  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
15
Views
2K
  • Programming and Computer Science
Replies
16
Views
2K
  • Programming and Computer Science
2
Replies
69
Views
5K
  • Programming and Computer Science
Replies
10
Views
3K
  • Programming and Computer Science
Replies
6
Views
1K
  • Programming and Computer Science
2
Replies
54
Views
3K
  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
4
Views
1K
Back
Top