Link Search Menu Expand Document

Getting Started

Table of contents

  1. Hello World!
  2. REPL
  3. Comments

Hello World!

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 hello-world.du:

print("Hello, World!");

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.

$ ./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 hello-world.du file can be called directly from the shell. 2 things are required:

  • Make the file file executable: chmod +x hello-world.du
  • Add a shebang line to the top of the script: #!/usr/bin/env dictu

REPL

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 (nil excluded).

Dictu Version: 0.30.0
>>> var someNumber = 10;
>>> 5 + someNumber;
15
>>> _;
15

Comments

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
*/

This site uses Just The Docs, with modifications.