my learning began with web development, which i started by looking the source code of existing websites.
i received a more overall study time, when i studied computer science for undergraduate.
i received a very practical learning experience when i began working as a software engineer.
after all of those experiences, i think the best way is to have an app in mind and just learn what you need in order to build it. but, if it's a copy and paste approach, it's not really going to work out, so you do need to understand your findings of how to do the basic building blocks of your goal product.
For me, it started when I got my first computer.
The computer simply started with a command prompt, so no graphical interface (no windows, no mouse, etc). Incidentally this was also before modern OS existed, so this command prompt was not even "advanced" as MS-DOS.
So I started reading the instruction manual which stated with some "basic" commands, and slowly built from there, doing more "complex" things like a step calculator.
If you prefer "modern" code/programming language, then I started with a book (once again, yes, this was eons ago; before google existed).
If I was to start again now, then start with a more graphical/intuitive language. Learn the programming paradigm, then slowly move sideways to similar languages that share syntax.
In any case, having a good development/sandbox environment with debugging helps a lot to learn from one's mistakes.
I started with Visual Basic at school, then Java and C++ at Uni. I've held SM roles since then so non-techie so to speak, but recently with COVID I've got back into "programming" in the Web App space.
I'm really enjoying the challenge, as frustrating as that is :)
As I mentioned on another post, I started with the Habbo Retro scene. I was able to learn the in's and out's of how a content management system worked and a great bulk of PHP knowledge, then I started working on little odds and ends projects until I became more comfortable with PHP and SQL. Now I am learning about creating CDN's for mutating content into iOS and Android apps with web hooks that allow for app interactions to show up on the web.
I bought books about the language I wanted to learn and learned from those books. Sometimes I just Google for some specified stuff in order to get the job done. But mostly I learn my scripting skills from educational books that guide you the way through it. I'm sure there are better ways to deal with it, but for me personally I found it to be the most useful way tot do