In these notes we are looking at three languages: Python, Dafny, and Idris. All three languages of these languages are very featured.

In this initial topic, we will provide an overview of the programming features of Python(3), Dafny, and Idris(2). CS886 itself will delve into the verification side. Within these notes we will explain more features as we go, but still features required for programming.

Python

Python is a well-known, long-standing, widely-used programming language. As a multi-paradigm language, Python supports:

We can write our programs using any of these paradigms, however, by default imperative programming is the norm.

Python is also an interpreted language, meaning that programs are executed on the fly.

Python is dynamically typed. The types of our values, expressions, and statements are checked at runtime. In fact Python is gradually typed. Supporting typing hints that static analysis tools, such as mypy, can use to check that type-hinted and non-type-hinted code are well-typed.

These hints, however, are dropped at runtime! Typing annotations are checked at both compile and runtimes.

On the surface, Python has indentation based syntax, with-statements, pattern matching, decorators, Python uses # for block and line comments.

As a language, Python is very rich. We will not go beyond the basics in these notes.

Dafny

Dafny is an industry backed verification-aware programming language. Originally developed at Microsoft research, Dafny is championed by Amazon and has been used in developing products at both companies. Like Python, Dafny is too a multi-paradigm language supporting:

The syntax for functions and imperative programs are separate. The imperative fragment of Dafny takes from C/C#-style languages complete with statements and expressions. The functional fragment is almost C-style but supports only expressions. Although we can write our programs using either syntax, by default imperative programming is the main language.

Dafny uses:

Although the functional and imperative syntax are separate, there is some overlap between them!

Unlike Python, Dafny is a compiled language meaning we compile our programs down to an executable from which we can run our programs. In fact, Dafny supports Multi-language code generation, enabling Dafny programs to be ‘compiled’ down to different languages. For example, the Dafny compiler can create versions of your program in C#, Python, GO, and Rust.

Interestingly, Dafny is also a termination-aware language. This means that Dafny will check to see if your programmes are likely to terminate. Dafny, however, will let you wrote programs that are non-terminating.

As a language, Dafny is very rich and supports other functionality we will not mention here. We will not explore all of what Dafny has to offer here nor in CS886. Any other features required for CS886, that are not documented here, will be introduced as required during the module.

Guides

Some programming guides for Dafny:

Idris

Idris is a research-backed verification-aware programming language. Originally developed at the University of St Andrews, Idris is a general purpose functional programming language that supports dependent types. (We will talk about them more in CS886.) Since its inception Idris has gone through at least one major change, Idris(2) improved the Idris language by supporting quantities (we will talk about them more in CS886) and made Idris(2) self-hosting. In these notes we will talk about features common to all Idris versions, and thus refer to Idris(2) as just Idris.

Unlike Python and Dafny, Idris is not a multi-paradigm language. Idris is a:

Idris’ syntax ostensibly takes from the Haskell-family of languages, with differences here and there. Where possible we will explain the differences.

Idris uses:

Like Dafny, Idris is too a compiled language meaning we compile our programs down to an executable from which we can run our programs. Also like Dafny, Idris supports multi-language code generation, enabling Idris programs to be ‘compiled’ down to different languages. For example, the Idris compiler can create versions of your program in Chez Scheme, Racket, Javascript, Java, PHP, and Python

As a language, Idris is relatively simple. The compiler, and other features of the language implementation, however, is rich with functionality. We will not explore all of what Idris has to offer here nor in CS886. Any other features required for CS886, that are not documented here, will be introduced as required during the module.

Guides

Some programming Guides for Idris are:

Quiz

We end this initial topic with a short quiz.