How to Effectively Learn Programming Through Real-World Applications

In summary, the conversation discusses the best approach for self-learning programming, particularly in C/C++. The participants suggest starting with a general introductory book and then moving on to more advanced books or online tutorials. They also emphasize the importance of actually coding and completing projects, rather than just reading about programming. It is suggested to pick a specific domain to focus on and to break down larger projects into smaller tasks. The conversation also touches on the usefulness of learning Linux and recommends the book "The C Programming Language" by Kernighan and Ritchie.
  • #1
Ans426
33
0
Hi,

I have some basic background in Python and was planning to self-learn more programming.

I was wondering if people here that have self-learnt programming in C/C++ and now using it for "real world" purposes (such as image analysis for BEC or data processing in particle physics) can share some experience on how they did so.

I'm of course aware that the first thing you would need to do is to pick up a programming book, read through it and work on the exercises in it.
However it seems to me that even doing so doesn't seem to give you skills quite at the "practical" level.
After all, nobody in the real world would write a program to simulate a few particles, sort a list or just solve some simple differential equations as they would in the textbooks. Any comments appreciated!
Thanks
 
Physics news on Phys.org
  • #2
Ans426 said:
I'm of course aware that the first thing you would need to do is to pick up a programming book, read through it and work on the exercises in it.
However it seems to me that even doing so doesn't seem to give you skills quite at the "practical" level.
After all, nobody in the real world would write a program to simulate a few particles, sort a list or just solve some simple differential equations as they would in the textbooks.

You have to start somewhere. After you you complete a general introductory book, move on to more advanced books covering specific topics you are interested in.
 
  • #3
Programming books or, my own preference, online tutorials are great for getting the syntax down. Once you know the basics, though, I'd start applying them immediately. You can find a good number of practice exercises and fun project ideas online, and not necessarily only hugely simplified ones. Keep reading through the books while you're at it, since that's a good way to pick up new language features, but I'd make that a secondary concern. There's no substitute for actually coding a complex project.
 
  • #4
It's pretty simple: first you program, then you program some more, and then you program even more.

There are a lot of good books out there, and Google Is Your Friend. (If you want to continue with Python, the Python Essential Reference is wonderful.) StackOverflow is good for asking questions.

Project Euler has a lot of exercises.
 
  • #5
After all, nobody in the real world would write a program to simulate a few particles, sort a list or just solve some simple differential equations as they would in the textbooks.

In the real world we don't ever have to sort lists? News to me! Admittedly a lot of the basic stuff is done these days through libraries but we still need to know how all the basic data structures work in order to build bigger and more complex ones.

Plenty of books out there on architecture of large software systems however you can read all of them and still won't be able to code a simple Hello World program unless you learn the basics of a language.
 
  • #6
Program.

You'll have to write pointless programs to challenge yourself in all the ways. Find exercises online or in books and do them.
 
  • #7
Ans426 said:
After all, nobody in the real world would write a program to simulate a few particles, sort a list or just solve some simple differential equations as they would in the textbooks.

That's the wrong way to look at it. If you can't write small programs that work, I guarantee you can't write big programs that work.

Learning to program is like any practical skill. You learn a lot more and a lot faster by completing 100 different small projects successfully, rather than attempting to do one huge project and giving up before you finish it.
 
  • #8
Programming is exactly like riding a bike ... you can read about it all you want but until you do it you don't know how to do it.
 
  • #9
Hey Ans426 and welcome to the forums.

Adding on the advice given by the posters above, you need to pick a domain.

Picking a domain means that you can focus on something specific and it will be the step that needs to be carried before deciding on (a) project(s).

With big projects, divide them into mini-projects or tasks. Create libraries of code that will be used for future projects.

If you don't pick a domain, then what will happen is that your scope and focus will be way to wide meaning that you either a) will be trying to do may more than you can handle and not actually get anything done or b) you won't even know where to start because you are considered way too much to start out with.
 
  • #10
I don't know if reading a book would be the best thing. I learned programming through 8 years of pure doing, reading little pieces of books here and there and TONS of online example code. Just this year, I picked up Kernighan & Ritchie's C programming book (this is a must read for anyone who's serious about programming in any scope, Kernighan helped write the UNIX kernel and Ritchie basically wrote the C language). I can't say whether it's easier to learn [in general] these things from a book or from doing, but what I do know for certain is that I always found reading books to be really boring. Studying physics has helped me get over that, but I still never read books for trivial things where I can read documentation or examples online as I go.

It will be useful for you to also know how to use Linux. Learning C and learning systems kind of go hand in hand with each other (though knowing Linux isn't exactly *required*, but compiling, running, doing basic things in Linux is something you should know since Linux is heavily used in science and other fields in industry). If you're really ambitious, you can get the book I mentioned above and just work through it. It's very short, but dense and it comes with exercises. I can't say for sure whether this method will work for you. It may scare you away because it's too hard, but you might end up saving a lot of time doing the baby stuff. If you can learn C, you can learn practically anything.

Also, with this book I mentioned, it's not really written for anyone in particular. C is simple and general that way, but what I mean is that you won't find any applications really towards science or math. That's ok. Once you know how to do the stuff in there, you begin to understand how to program the physics and the math. After that, you'd want to learn about optimization techniques and maybe parallel programming... but starting with something general is the best idea I think.

Anyway, I wrote this post assuming that you wanted to do something related to scientific computing. Also, my background isn't exactly professional. I did lots of programming in high school (mostly on web engines) and I started doing astrophysics research a year ago when I started on the physics BS, but no real work experience in professional software writing/engineering. Just an FYI.
 
  • #11
Ans426 said:
I was wondering if people here that have self-learnt programming in C/C++ and now using it for "real world" purposes (such as image analysis for BEC or data processing in particle physics) can share some experience on how they did so.

One thing that you can do is to download an open source package, try to get it working. Most of them have bug lists and open projects and you can work on some of them.

http://en.wikipedia.org/wiki/ROOT
http://www.tina-vision.net/
http://en.wikipedia.org/wiki/List_of_free_and_open_source_software_packages

However it seems to me that even doing so doesn't seem to give you skills quite at the "practical" level.
After all, nobody in the real world would write a program to simulate a few particles, sort a list or just solve some simple differential equations as they would in the textbooks.

Right. They'd download a program and modify it so that they can do it. Which is what you can do with those packages... :-) :-) :-) :-) Also be prepared for days to weeks of frustration as you try to get the package installed. Be also prepared for poor/non-existent/misleading documentation, which will teach you how important documentation is.

Also, one thing good about working on an open source project is that you learn some of the social skills that you'll need in the real world. Once you have finished the coding, having people review it, and then convincing people to put it into the tree is quite useful.
 
  • #12
Also writing code is easy. It's reading and modifying other people's code that gets painful, and one reason to work on a big project is that you will "feel the pain" of having to figure out and fix other people's bad code.
 
  • #13
denks said:
In the real world we don't ever have to sort lists? News to me! Admittedly a lot of the basic stuff is done these days through libraries but we still need to know how all the basic data structures work in order to build bigger and more complex ones.

On the other hand, writing your own program may not be the best way of learning this sort of thing. One thing that would work is to write a sort program once. Spend a day or two, writing together a program to sort a list. Then download an implementation of STL. Compare. You'll see the difference between a paper airplane and a Boeing 747.

You can do the same for differential equation code. Write your own. Look at professional code. Compare. Learn what they are doing that's different.

Part of programming is to know when *not* to write your own stuff. For list sorting, you do *NOT* want to write your own routine as another other than a "let me fold a paper airplane" exercise.

You want to use STL. For ODE stuff, you really don't want to write your own code either. Use Scipy, and then download and take apart Scipy to see how to works.

Also do you want small projects, but open source makes it possible to do that in a way that is useful. For example, it would be better if instead of writing a "throw away" ODE calculator, you look at scipy, and then implement some thing is missing.

One big advantage of CS, is that if you want to learn aerospace engineering, you can't just download a copy of a Boeing 747, change the wing slightly and have Boeing redo the 747, whereas with software engineering, you can.

Something else that would be useful (i.e. I'd like to do it if I had the time, but I don't) is to write some simple scientific apps for the Android apps store.
 
  • #14
Thanks a lot for all the feedback.

I'm guess I made myself a bit unclear.
What I meant was it seemed to me that nobody in the real world would write programs that ONLY sorts a list or do so simple tasks in a couple hundred of lines.
I'm aware that the basics are very important and I certainly know how to write my only algorithm to sort a list or do some basic numerical stuff or directly using stuff from SciPy/Matlibplot.

Based on the above comments, would it be a good idea if I first read and worked on all the exercises in a book in C++ (say Accelerated C++ or C++ Primer Plus, or if anyone could recommend some good online tutorials) , and then trying to working on larger codes from TINA or ROOT?

Thanks again.
 
Last edited:
  • #15
twofish-quant said:
Also writing code is easy. It's reading and modifying other people's code that gets painful, and one reason to work on a big project is that you will "feel the pain" of having to figure out and fix other people's bad code.

If writing code is so easy, why bother fixing somebody else's? :)
 
  • #16
Pythagorean said:
If writing code is so easy, why bother fixing somebody else's? :)

If only it were that easy!
 
  • #17
Pythagorean said:
If writing code is so easy, why bother fixing somebody else's? :)

If there is a huge app(s) or large libraries you have to maintain you are not going to write it all from scratch, you will be wading through thousands of lines of code written by possibly dozens of different coders. Some will be neat and elegant, some will be average, some will be just plain unreadable and you will be left scratching your head how it even manages to compile let alone work as required. Many of those coders will no longer work for the organisation so you are on your own to figure out what's going wrong or how to add the new requirement. Once you feel the pain of having to fix someone else's code then you generally try to do better with your own. It surprising how fast you learn why you should code things a certain way and get an appreciation for good design when you see the abominations that happen when others have done things differently.
 

What are the benefits of self-learning programming?

Self-learning programming allows individuals to learn at their own pace and in their own style. It also allows for greater flexibility and the ability to choose specific topics or languages to focus on. Additionally, self-learning programming can be a cost-effective way to gain valuable skills for a career in technology.

What resources are available for self-learning programming?

There are a variety of resources available for self-learning programming, including online tutorials, coding bootcamps, books, and websites such as Codeacademy and Udemy. It is important to research and choose resources that align with your learning style and goals.

How can I stay motivated while self-learning programming?

Staying motivated while self-learning programming can be challenging, but there are a few strategies that can help. Setting tangible goals and regularly tracking your progress can help keep you motivated. It can also be helpful to join online communities or attend coding meetups to connect with others who are also learning programming.

What programming language should I start with?

The best programming language to start with may vary depending on your goals and interests. However, some popular options for beginners include Python, Java, and JavaScript. It is also helpful to research the job market and demand for different programming languages in your area.

How can I measure my progress while self-learning programming?

There are a few ways to measure your progress while self-learning programming. One way is to regularly complete coding challenges or projects and track your improvement. Another option is to take online quizzes or tests to assess your knowledge. It can also be helpful to seek feedback from others, such as through code reviews or mentorship.

Similar threads

  • STEM Academic Advising
Replies
12
Views
1K
  • STEM Academic Advising
Replies
3
Views
811
  • STEM Academic Advising
Replies
6
Views
786
Replies
2
Views
794
  • STEM Academic Advising
Replies
2
Views
1K
  • STEM Academic Advising
Replies
4
Views
2K
  • STEM Academic Advising
Replies
10
Views
2K
  • STEM Academic Advising
Replies
24
Views
2K
  • STEM Academic Advising
Replies
3
Views
1K
  • STEM Academic Advising
Replies
9
Views
1K
Back
Top