We’ve already learned how to enter the REPL and run code there. Now, let’s create a Dictu file and execute it. Open your favorite code editor, and create a new file with a
.du extension. If you’re new to programming or aren’t sure which editor to use, Visual Studio Code (with the Dictu extension), Atom, or Sublime Text are all fantastic (and free) choices.
We’re going to call our file
That’s all we’ll put in it for now. Let’s execute our file. It’s just like entering the REPL, except we add the path to out file after
$ ./dictu new_dictu.du Hello World!
As you see,
Hello, World! is printed to the screen. You have just created your first Dictu program, now onto bigger and better things!
The REPL is a language shell, allowing you to run code on the fly via your terminal. This is very useful for debugging, or small little checks you may want to perform. When you enter the REPL, there is a magic variable
_ which stores the last returned value (
Dictu Version: 0.20.0 >>> var someNumber = 10; >>> 5 + someNumber; 15 >>> _; 15
It’s always important to comment your code! Comments are used to explain what your code does. Dictu’s syntax will be familiar to any programmer.
// This is a single line comment /* This is a multiline comment */