I feel like the old trial-and-error is the best way to learn programming. Making mistakes is a part of life and helps us grow as individuals.
The same applies to writing code - if we create a script for a website and recognize the mistakes we made we then learn from it - improving our scripts and the knowledge in our brains.
When we are taught a certain way to do things we can pick up bad habits etc which are often harder to shake off...
Best way to Learn Programming that i would want to suggest is to be a self taught, of course after a little bit of guidance start practicing different constructs of programming also gudence is available online and there are sites where you can find stuff related to programming such as W3Schools Online Web Tutorials Tizag Tutorials
are nice resources for getting online stuff on programming .
I have been teaching myself over the years little by little. I learned a lot about html and css just by owning Dreamweaver. In particular CSS, I had not even attempted any CSS before using Dreamweaver, but the way the software works with css taught me a lot in a short period of time when I first started out. I love it!
The best way to learn programming is to learn it yourself. Well, you can learn it from school.. But at the end of the day you'll still do something about it. There are so many useful resources and tutorials over the internet. Use them.