I've seen a lot of topics on this forum about how to start programming, or where to start, people getting confused on what to do and where to go. I am going to write this topic solely for the purposes of helping people find the resources they require to get started with programming. I will also do a general overview of programming to start with, understanding classes, variables and common statements.
Basic Programming Principles
Apart from web languages such as JavaScript, HTML, CSS and other like languages, the most used type of language is a programming language.
Programming languages are languages that are designed specifically to translate user readable code to binary code. They are the fundamental parts of what makes a computer work properly. Without a programming language, no other language will run or execute. Think of a programming language like an engine of a car. Without the engine, the car simply won't run.
In technical terms, without software and code, a computer won't turn on, because it does not have the functionality or the software to piece together what to do on start-up. This is where a programming language becomes handy.
HTML, unlike other languages, is a Markup language. Markup languages are used to display web content. Primarily, there are used to execute programming languages easier. A markup language will not run without an engine - this engine is like Trident, which is a web technology designed to render and display web pages through the HTML markup specification. Trident, like Chromium and other web rendering technologies, are engines specifically designed for one purpose - to make it easier for a programming language to display content.
So how does a markup language run and how does it know what to execute? The engines we spoke about just now uses a Parsing engine, or a Parser. A Parser is kind of like a library of keywords, and it identifies each keyword and converts them into user-readable content. For example, most HTML code pages will render thusly:
The engine will launch the page through a new instance of a Parser (we will talk about instances later on) and the Parser will then read the contents of the code.
For each keyword within a greater than and less than symbol (the '<' and the '>', if that doesn't render because I won't know until this is posted, you should know what I mean), the Parser will generate a new instance of the display content related to that keyword followed by the properties of that content, such as background colour and whether or not to display borders.
The engine will return the content back to the web browser. These engines can be developed in many languages, but the most common is C++.
And last but not least, is a scripting language. Like JavaScript and Lua, a scripting language is designed to extend functionality or content for an already developed application; although this is slightly different in terms of JavaScript. Scripting languages, unlike Markup languages, do not require an engine, but do require at least a Parser and the library which can be integrated into the final application.
In Lua, for example, if you created an application in C++ for Windows, and you want people to extend it and add "modifications", you would assign your classes and events that you want registered in Lua. Basically what this means is that when the Lua scripts are handled by the Parser, the parser will find the registered events or classes in your application and execute them accordingly. Scripting languages are quite difficult to understand if you are new to programming, so unless you know technical jargon there is no point in me trying to explain. I am sure there are better examples out there as well.
Want to Program?
So you want to get into programming and you don't know where to start? The best way to start is to understand the basic logical building blocks of what makes a programming language a language in first place. You need to understand: classes, variables and functions.
Let's get started by explaining classes. All programming languages will start with a class that is executed by the compiler at runtime. Firstly, the compiler will find the "Main.c" if working in C, "Main.cpp" if working in C++, or "Program.cs" if working in C#. Other languages may differ. It is crucial these files exist in your program when you compile, otherwise the compiler will start throwing errors at you. Some compilers may give you the option to choose your starting object and function, like Visual Studio's compilers.
Wait, what's a compiler? A compiler is simply another application that parses, interprets, analyses and executes source code. Without a compiler, a programming language won't function. Wait, so you need a program to run a program? Yes and no. Binary applications, applications that are written purely in Binary code, don't actually need another program, but they do need an interpreter. In short, a computer needs to interpret on and off switches (0s and 1s) to execute logic gates, boolean expressions among other things. This kind of discussion can be saved though, because I can go on for hours on how a computer works from the ground up.
For the purposes of this short tutorial, I will be using the C programming language since that is the most commonly used.
class Main
{
int i; //this is a variable, and this is also a comment. Comments are not interpreted by the compiler
/*
Alternatively, you can use a comment block like so. In the example code before, you can execute a function.
*/
int Main(string args[]) {
return i; /*
When a function is identified with a data type (like int, which is shorthand for integer - a whole number), the function must return a value that has the same data type.
You cannot return a uint on a function defined as an int, even when they are both whole numbers.
*/
}
/*You can use the keyword 'void' to tell the compiler to return 'null' when this function is executed.
All functions need to return a value, even if you do not explicitly call it, like in the previous function.
What the compiler notices in the below example is an implied conversion. Depending on the compiler
will depend on whether or not you can be lazy and have the compiler automatically convert values
to other values, this is implied conversion. Telling the compiler to convert one value to another is through
code is explicit conversion. VB.NET is infamous for its implied nature of converting values to other values,
or data types. The below example is not supported in C version 9, use 'void otherFunction(void)' to accept
no arguments. Arguments, or parameters, are basically references to variables declared when the function
is opened, and the references can only be used within the function.
*/
void otherFunction() {}
//In C, you can instantiate classes into a variable, so let's take the following examples.
public class MyClass {}
MyClass myVar;
/*
Basically, what we are doing above is assigning the 'myVar' with the data class 'MyClass'. myVar will
access the contents of this class under its new name and will be able to access exclusive methods and
variables. Exclusive variables and properties, or types with the 'public' keyword in front of it, are declared
as belonging to the class.
*/
}