I have been asked repeatedly by friends and colleagues how I learned programming. Having done my Bachelor's Degree in Physics and currently working towards a Master's in Industrial Engineering and Project Management, I do not have an academic Computer Science background at all.
Still, I have managed to acquire some degree of programming capability. I'd like to give you some tips for learning programming, and I'll make sure to share some stories along the way.
Learn programming because it interests you
One seemingly natural thing to do in order to learn a programming language is to buy a book or video tutorial for novice programmers. They come cheap and promise a lot. Buying digital products on the internet happens in an instant and, in theory, one can start learning immediately. Only you won't if you choose to start like this. I'd argue that most people who try to learn a language this way will stop after a few weeks.
Don't just learn programming for the sake of it. Picking up your first programming language is hard. Without applying it to something you are personally interested in is even harder. Try to establish a connection between what is relevant to you and what you want to learn. There is no way that just buying a random tutorial or book will give you the motivation necessary to keep learning.
When I was 14, I got really interested in WordPress websites. Wanting to modify them, I Googled something like "How to program WordPress". Fast forward a few months and I had learned my first programming language, PHP.
If you neither have a project you need to be able to program for, nor are you intrinsically interested in programming, I suggest you stop right there. It might turn out to be really hard for you to stick to learning and you'll likely abandon programming very quickly.
Learn programming because you have to
Maybe you're not the type of person who enjoys playing around with programming languages on personal projects. Maybe you're the type of person who thrives under the right amount of external pressure. This one is for you: try to make programming a necessity to reaching a goal.
When I wanted to write my Bachelor's thesis, I talked to different people at the department of Theoretical Physics at TU Berlin. I still recall my soon-to-be supervisor sitting in his chair, asking me whether or not I had any experience programming in Python. At this point, he proposed a thesis subject to me that I was really interested in.
After I admitted that I had no experience programming in Python whatsoever, he just shrugged and told me that I'd have to learn it then. Adding that the deadline for handing in the thesis was within the next six months, we shook hands.
In this way, I got started with Python. I just had to. This is powerful and you can leverage it, too! Go ahead and try to find a small project, at your work or on your course, for which you need to program a machine. It'll work wonders.
Which programming language should you learn first?
There are so many languages that one can easily get lost. No idea where to start looking for a first programming language? I recommend choosing a language appropriate for the task you want to solve with it. Let's see...
Do you have a WordPress blog and want to add features to it? Maybe you want to change how it looks and find out how your blog is generated? What a great opportunity for you to pick up PHP! Along the way, you can learn about HTML and CSS, two languages used to define how websites look and behave.
Are you in academia and want to run simulations or experiments? Go ask your peers and colleagues which language they use and pick up whatever they recommend to you! This might be a great opportunity to learn Fortran, C or C++, Python or R!
Here's a secret: It doesn't really matter what language you start with. If you manage to learn one language and find out that it doesn't suit your needs for a new project, just learn another language. The more you program, the easier picking up new languages becomes.
There are some things you can do to facilitate your learning experience.
Get a good text editor
An important point is picking a good text editor. Microsoft Code is a free, open source editor that comes with a nice graphic interface and which has a vast amount of add-ons available. I can highly recommend it to beginners, although it must be said that it has a poor level of performance, since it's an Electron-based application.
Next, there's Sublime Text, a beautiful, very fast and highly customisable graphic text editor. I used this for years and still have a version of it installed on my computer. Written in C++ and Python, in my experience Sublime Text feels a lot snappier and more responsive than Microsoft Code does. However, Sublime Text is no Free software. In addition, a license is quite costly. Sublime Text can be tested for an unlimited amount of time though.
Learn 10 finger typing
Typing at the speed of thought is a liberating experience when learning programming. Try Keybr.com (This should be capitalised too) to learn how to type quickly.
Get a monitor, mouse and keyboard
If you learn programming cramped in front of a laptop, you haven't set yourself up for having a good time. If you have a spare 200 Euros, get a used screen, keyboard and mouse. You'll be able to work for longer periods of time without straining your body the way you would sitting in front of a laptop.
Some final thoughts
It's great that you're thinking about learning a programming language! Being able to program a computer will serve as a powerful tool, no matter what you end up doing with it. It's not easy though. Think about it in the same way you'd think about learning to play an instrument, or learning to speak a new language.