Giovanni's Diary > Subjects > Programming > Notes >
Programming advice
There are some basic principles and ideas that you really understand only after years of experience, and knowing them earlier would have been really beneficial and would have not wasted a lot of time.
Here is a collection of key things I have learned over the years. They are particularly relevant for me, because of my background and how I think, but I think anyone can get some values out of them.
Have Fun and explore ideas
This is the most important thing in order to keep going on programming and improving without serious burnouts. Especially if your job is boring and stressful, programming on your free time can be really fun and can motivate you in your actual job. Practice recreatinoal programming, as a lifestyle or not.
I struggled a lot with this in my early programming years. Since I am historically an anxious person always concearned about its future, programming "for fun" and programming for "my sustainable future" where two completaly separate things, and I would often discard the former. I liked learning about algorithms and programming languages, don't get me wrong, but I was constantly thinking about "this may help me to get a job" or "this is useless to get a job, so I should focus elsewhere".
A second error I did early on was to think too much about certain technologies being "the best". There are certain communities, which I now think are quite toxic and stay away from them, that threat their favourite program as their religion. Examples include Linux distributions like Nixos, programming languages in particular Rust, and editing software like Vim. This only makes you incredibly limited, biased and, frankly, stupid.
Eventually I matured (if you can say so) out of this mentality and started exploring my ideas and anything what I would find interesting. From game engines to programming languages, I started writing so many things, discovering new worlds, programming day and night until my body could not type anymore. Through this constant practice I exercised how to work and create software of any kind, which is very useful for "my sustainable future" by the way, and I felt like I was learning naturally.
A related advice would be to do a lot of projects in many different areas. This is how you become a well-rounded programmer able to solve all kinds of problems.
Write things from scratch
There is no better way to learn something than to write it from scratch. While this may not be the best advice for the day to day job (it is totally fine to use someonelse's code), I belive it is incredibly benecificial for educational purposes. Try to go as low level as possible (phisically or logically), master the basics and you will be able to write anything.
This is one of the reasons why I still program mostly in C. I want to be used to setting up compilation and linking, to manage menory, etc, because this is how you understand how the computer works. I may be really stupid, but for me theory is not enough and I need lots of practice to truly understand something and be able to fully take advantage of a technology.
Write easily (re)usable software
Understanding this and applying it in anything that I do made me a way better programmer. Everytime you have write some functionality for your projects, think about how this can be extracted out of the project and be its own thing. Eventually, for new projects you will have already wrote most of the code in the past, and you can just reuse it.
I want to emphasize the term "easy". Apis should be simple and clear, as the creator of Perl Larry Wall said "Easy things should be easy, hard things should be possible". The best examples are the stb libraries or my own micro-headers, which can be integrated in your projects just by copy-pasting a single header file. This is the level of reusability you should aim for.
If your code is easy to read, it is more understandable by other programmers, more maintainable and customizable.
Travel: Programming Notes, Index