Getting started

  1. Install Mys as described on the Installation page.

  2. Create a package called foo with the command mys new foo, and then enter it. This package is used in throughout the tutorial.


    src/main.mys implements the hello world application.

    func main():
        print("Hello, world!")
  3. Build and run the application with the command mys run. It prints Hello, world!, just as expected.


  4. src/lib.mys implements the function add() and its test add(). This examplifies how to test your Mys modules.

    func add(first: i64, second: i64) -> i64:
        return first + second
    test add():
        assert add(1, 2) == 3
  5. Build and run the tests with the command mys test.


  6. Run mys test -c to build and run the tests again and create a coverage report.


  7. Open the coverage report in a web browser. The URL is found in the output of the previous step.


  8. Add the bar package as a dependency and use its hello() function.

    package.toml with the bar dependency added:

    name = "foo"
    version = "0.1.0"
    authors = ["Mys Lang <>"]
    description = "Add a short package description here."
    bar = "latest"

    src/main.mys importing hello() from the bar module:

    from bar import hello
    func main(argv: [string]):
  9. Build and run the new application. Notice how the dependency is downloaded and that mys run universe prints Hello, universe!.


  10. Replace the code in src/main.mys with the code below. It examplifies how to use functions, classes, errors, types and command line arguments. The syntax is almost identical to Python, so many readers should easily understand it.

    func func_1(a: i64) -> (i64, string):
        if a == 5:
            text = "Foo"
            text = "Bar"
        return 2 * a, text
    func func_2(a: i64, b: i64) -> i64:
        for i in range(b):
            a += i * b
        return a
    func func_3(a: i64) -> {i64: [f64]}:
        return {
            1: [2.0],
            10 * a: [7.5, -1.0]
    func func_4():
            raise ValueError()
            print("func_4():      An error occurred.")
    func func_5() -> [i64]:
        small: [i64] = []
        for v in [3, 1, 5, 7, 2]:
            if v < 5:
        return small
    class Calc:
        value: i64
        func triple(self):
            self.value *= 3
    func main(argv: [string]):
        value = i64(argv[1])
        print("func_1(value):", func_1(value))
        print("func_2(value):", func_2(value, 1))
        print("func_3(value):", func_3(value))
        print("func_5():     ", func_5())
        calc = Calc(value)
        print("calc:         ", calc)
  11. Build and run it with mys run 5.


  12. Continue to explore Mys by reading the Language Reference, and at the same time modify the code in src/main.mys to test anything you find interesting.