GLang is a dynamically-typed, interpreted programming language. This means when you create something in the language, you don't have to give it a type (GLang does this for you!)
When a language is interpreted, it essentially means the language is run through line-by-line to build an output. For example, if we create a function in an interpreted language, the code is never read until we actually call the function. You can think of an interpreter as a magnifying glass that studies your program as you run it. Its typically slower during run time, but there are ways to optimize interpreted parts.
Does speed matter?
In many cases, yes, but GLang isn't focused entirely on speed, rather being as close as possible to human language without the complexity of memory management. This is called being high level, and when a language is high level, it is close as it can possibly get to natural language. A high level language keeps the programmer away from managing things like objects on the stack or heap (GLang does this for you!)
You can install GLang from here, and install instructions are available here.
GLang is recommended to be used in VSCode or Zed, however, you can use it in any text editor! As long as you have access to a terminal and text editor, you can write GLang programs.
Before we do anything in GLang, we need to create a new project folder. You can do this in the terminal with the glang command! To start, open a new terminal and simply input:
glang new hello_project
This will create a new folder titled "hello_project" with the "src" folder and a "main.glang" file inside.
If we take a look at the "main.glang" file, you'll see a program already written for you.
func main() {
bark("Hello, world!");
}
main();
Don't worry about what all of this means, for now we want to run this program. Open a new terminal in the "hello_project" folder, and type:
glang main.glang
In your terminal, you will see the output:
Hello, world!
The glang command is used simply for that, running GLang programs.
Let's go back to the "main.glang" file for a second. If we look at the second line:
bark("Hello, world!");
This line is actually outputting text to the terminal. We can modify it to be any text, as long as it's inside quotes "":
bark("Hello from GLang!");
Now, if we re-run the program with:
glang main.glang
In the terminal, we will see the output:
Hello from GLang!
You have successfully written your first line of GLang🎉🎉