Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

HF Rulez the UniverseHF Rulez the Universe
code vending machine
development programming language learn coding how to tutorial guide

How to Learn Any Programming Language

Posted Feb 2, 2024 04:00 PM
Today you will learn exactly how I have started learning each of the programming languages I know. It's an easy to follow process that allows you to ask questions (Google, AI/LLM, etc) and get answers. This format works for any language and is a great way to start. In my examples I will use ___ to represent the language you are learning. You should research any topics you don't understand, and definitely any terms / words you are not familiar with from the question set. There are also many different ways to accomplish each task, and plenty of "side quests" you can go on from each question. Luckily, within each few questions there are hundreds of fun projects & real business use cases that you can build with the code you learn how to write.

I hope this helps you! This is something I have never really compiled in depth, but a learning method (question asking) I have used successfully for almost two decades. I've used this type of method to learn PHP, SQL, Python, JS, Solidity, and more. If you can master this list and continue growing with a language, I promise you will be able to soon unlock the ability to create whatever program, script, app, website, or tool you could ever want.

What You Need
Windows, Mac, or Linux computer. You can also start with a server without a GUI if you want to use command line. That's how I prefer to do most of my work, alongside software to edit the files.

Your computer probably comes with Notepad, TextEdit, Word, Libre Office, or another text editing software. While some of these can be used to write code, you will want to pick the best editor for the language you are learning. VS Code can be a good choice if you aren't sure.

Over the years I've had to code on airplanes, trains, cars, floors, couches, desks, beds, and all in between. You can get some quality code pushed out with or without wifi. But for starters, you should make sure you have reliable access to internet for any questions (the times of learning to code with a book published 10 years ago are over!), and a good code editor specifically setup & popular for your language.

One way to make sure your computer is setup for development is to use a working example of Hello World. Once you are able to run that code, you are ready to start learning every concept in the question set!

The Hello World Method
One thing I want to mention before I jump into my question set for learning any programming language is the coder favorite "Hello, World". It will be known to many of you, but it's important to mention. I almost always make sure to have a working copy of Hello World in any new language I learn. The reason for this is so that I can establish a few key requirements:
- My computer is capable of compiling/interpreting this programming language
- I am able to save a file, open/run the file, and see real text output
- I can edit the file, understand how it's operating on a basic level in order to print out the phrase Hello, World

This becomes a springboard for me as it's one of the best ways to avoid the headaches that everyone faces with their first new language: the issue of not knowing what a file should look like, how it runs, and whether or not your computer is even setup properly to run working code let alone any buggy code you may write.

As you go through the initial questions, you will reach a point where you are either thoroughly confused, or you feel like you are on a roll. If you get stuck, your best bet is to look up Hello World for your language and continue from there. It's a great way to get a good example of code that can be ran to print out a message when you run it as a script/program.

600+ Programming Language Examples (Hello World Collection)
Hello World in 15 Languages
Hello World in 30 Languages

Questions to Ask
Please note that the goal here is to not ask all questions at once. You should understand each question, its answers, and try to find out if there are multiple ways to do things. You should not move on to the next question until you are comfortable with the questions before. I have set up the list this way to help a new programmer learn certain concepts. There are many more in between that will be needed, but to set up a script in any language, you can follow these steps.

Feel free to skip any questions you don't need, but otherwise you can use these to reliably learn a language via Google, Bing, any search engine, or an LLM.

Quote:What file extension does ___ use for a script I can open / run? (examples: .php, .py, .js, .cpp)
Can I create a single file script in ___?
Does ___ have starting / ending tags? (example: )
What are scope and closures in ___?
Do I need to use new lines, ; or other symbols, or indents for syntax in ___?
How do I add comments to my code in ___?
How do I print text Hello World with ___?
How do I run a ___ file on Mac/Windows/Linux to see output?
How do I debug a program in ___?
How do I define a variable in ___?
How can I use a ___ script/program from command line to pass in parameters? (example: python hello.py 'world' )
What are data types, and what types are available in ___?
How do I perform type conversion in ___?
How do I set a variable with a string value in ___?
How do I combine two strings together (concatenate) in ___?
How can I set a variable with a number value in ___?
How do I set a variable to equal true or false in ___?
What is the difference between =, ==, and === in ___?
Are there "truthy" or "falsey" values in ___?
How do I create an if statement in ___?
How do I create an if/else statement in ___?
How can I get the length of a string in ___?
How do I calculate math like 2 + 3, or 3 * 5, or 10 / 2, etc in ___ ?
How can I store a list / array of items in ___?
How do I get the length of a list / array in ___?
How can I select the 1st, or last, or a specific item in a list / array in ___?
How can I add a new item to a list / array in ___?
How can I loop through a list / array?
How do I check if a value exists in a list / array in ___?
What is object-oriented programming (OOP) in ___?
What is functional programming in ___?
How to define a function in ___?
How to use / call a function in ___?
How to pass parameters / variables into a function with ___?
How do I handle errors and exceptions in ___?
How can I create a class in ___?
How can I declare / define variables in a class using ___?
How can I define functions inside a class with ___?
How can I include / import another ___ file?
How do I use an imported/included function or class in ___?
How do I check if a file exists in a folder with ___?
How do I check if a folder exists with ___?
What's the easiest way to list all files in a directory with ___?
How can I open a local file with ___?
How can I read the contents of a file with ___?
How do I create a file with the word "test" in it, with ___?
How do I update a file to say "test2" in it, with ___?
How do I delete a file with ___?
How do I update a file with ___?
How do I read data from a JSON file with ___?
How can I write data to a JSON file with ___?
What's a simple way to read a CSV file with ___?
How do I save data to a CSV file with ___?
How can I use an environment file of project settings with ___? (ex: .env file)
How do I connect to a database with ___?
What's the simplest way to add (insert) data into a database with ___?
How can I get (select) data from a database with ___?
What is the easiest method to update data in a database with ___?
How do I remove (delete) data from a database with ___?

There are many more questions you can ask from there, including how to send or receive HTTP POST/GET/PUT or other requests to interact on the web, or to use other methods & protocols. You can go low level with some languages, interacting with the Windows, Mac, Linux systems or other platforms too. Depending on language you may go in one direction more than others. That's totally fine.

Finally, once you have mastered all of the topics above for your new programming language, you can start to build with others tools. The reason that I highly recommend leaving this for last is so you can have an extremely solid understanding of the language before you use code you will need to interact with, understand, and debug in the future.
Quote:How can I use a third party library with ___?
How can I install dependencies and manage versions for ___?
What are common frameworks, libraries, or starter codebases for ___?

The best thing you can do is commit yourself to a set period of time to learn the language per day, or week. You will find that the concepts from the questions & their answers will come together in a way where you have a true mastery of the most common data types, files, and basic folder/data/function structures needed to put together some great projects in any programming language you want. Good luck & I hope you are a master of coding soon enough!