Recently I came across a headline containing the phrase: "Understanding source code, compressed code, and compiled code". It sounds incredibly boring assuming they meant "understanding the differences". This has inspired me to write something that I hope is more interesting about truly understanding code.
There are a few things to consider when trying to interpret some apocryphal function - perhaps its part of a library and you can't see what it does under the hood because it's somewhere inside a DLL, perhaps it's open source but it's just difficult to comprehend.
For the former, I recommend reading the documentation for that function - and the documentation around it. Some people consider it bad practice to have functions that must be called in a certain order, and I am inclined to agree, but often you find that you must when using someone else's library, that's why it's important to understand what they were thinking when they wrote it. Let's hope that it's accurate and complete; or if that's too much to ask, let's hope that it exists.
For the latter you must consider what it is doing, how it is doing it, and why it does what it does. Perhaps you can even ask the author!
In both cases, you must hope that the symbols have meaningful and accurate names. Of course (and you likely already knew this) the internet is your friend. Whether its a thread on a forum, a GitHub issue, a stack overflow question, some random site like this one, or the official documentation, it ought to be of some use.
M'Comrade said I should write something to answer these questions he had. At first I thought it might come across as condescending, but you never know, someone could come across this post and find it useful, so I might as well. Here we go.
How do I get started on code?
You just have to start doing it. You should probably learn the basic syntax before anything else, but these days most languages are the same. If you really don't know where to start, Google something like "Hello World example tutorial in [language name]". Then pick a project that interests you. What do you want to get out of it? Is there a certain part of your life you'd like to automate? Subscribe to Computerphile.
What should a beginner watch out for?
Flow of control, make sure you have a good understanding of it. Sequence. Selection. Repetition. What else? Probably misusing some function get something specific out of it, something it wasn't intended for. Don't over-complicate or overthink things. Occam's razor. Remember to comment your code and use meaningful variable names. The computer doesn't care about such things, but you will when you come back to it a month later. If you're writing the same code multiple times, you're doing it wrong, make a function.
Where is a good place to start?
That's just like the first question. Compilers can be quite a pain to set up, so get an IDE. If you don't want to install some massive piece of software on your computer, websites can be quite a fun thing to get going with. You don't even need an internet connection. Output is easy. You get instant results too. JavaScript also does a few neat things that make it easy to learn, like type coercion. When you start working on larger projects, you'll find it useful to have some sort of issue tracking, you can use Trello or Jira for this. While it can be fun starting out with an "easy" language like JavaScript or Python, it is also useful to learn a compiled language like C early on, so that you get a better understanding of what you're actually telling the computer to do.
What is a good mindset to have?
I'd say the greatest attribute to have is patience. The computer will do what you want it to do eventually. It will always do what you tell it to (except in a few rare cases I won't get into). Consider the difference between those two things. You also have to be willing to get into the nitty gritty really nerdy stuff, should the need arise. Try not to be intimidated by complex code; take the time to understand it.
What background material is needed to help?
At the risk of being reductive, whatever is relevant. Google the subjects, find some books, read the reviews. I would advise against paying for anything though. The best things in life are free, advice included. The best background material is experience. You can take online classes, but again, there are free ones on YouTube. I would recommend doing some maths revision, if you are working on games since you'll need to use trigonometry, but again, it's not necessary, and there will likely be a guide telling you how to do what you want anyway.
How many hours should I code a week?
That's up to you, and how seriously you want to pursue the practice. If you are not passionate for it, that's okay, perhaps try a different language or project, or perhaps it not for you. If you are serious about it, then you should use some kind of repository service like GitHub to keep your projects organised and in one place. As a general tip - not just for programming - plan when you're going to do stuff, make time for your hobbies, set a date.
This post has been a bit different from the usual, I'm not sharing anything new that I've learnt, but even if this only helps one person, writing it will have been worth it.