Interview with Magnus Madsen about the Flix Programming Language

Flix, an open-source programming language inspired by many programming languages, enables developers to write code in a functional, imperative or logic style. Flix looks like Scala, uses a type system based on Hindley-Milner and a concurrency model inspired by Go. The JVM language supports unique features such as the polymorphic effect system and Datalog constraints.

Flix programs are compiled to JVM bytecode and developers can use the Flix Visual Studio Code extension or evaluate the language by using the online playground.

The community develops the language based on a set of principles such as: no null value, private by default, no reflection, separation of pure and impure code, correctness over performance and no global state.

The following main function is considered impure as the println function has a side effect. The Flix compiler keeps track of the purity of each expression and guarantees that a pure expression doesn’t have side effects.

def main(_args: Array[String]): Int32 & Impure =
    println("Hello world!");
    0 // exit code

The Flix language supports Polymorphic Effects making it possible to distinguish between pure functional programs and programs with side effects. Functions are pure by default, or can explicitly be marked as pure:

def add(x: Int32, y: Int32): Int32 & Pure  = 
    x + y;

Functions with side effects can be marked explicitly as impure:

def main(_args: Array[String]): Int32 & Impure =
println(add(21, 21));
0 // exit code

The compiler displays an error Impure function declared as pure whenever side effects are used in an explicitly marked Pure function:

def add(x: Int32, y: Int32): Int32 & Pure  = 
    x + y;

The separation of pure and impure code allows developers to reason about pure functions as if they are mathematical functions without side effects.

Datalog, a declarative logic programming language, may be seen as a query language such as SQL, but more advanced. Flix supports Datalog as a first-class citizen making it possible to use Datalog constraints as function arguments, returned from functions and stored in data structures. Flix may be used with Datalog to express fixpoint problems such as determining the ancestors:

def getParents(): # r  = #
    ParentOf("Mother", "GrandMother").
    ParentOf("Granddaughter", "Mother").
    ParentOf("Grandson", "Mother").

def withAncestors(): # ParentOf(String, String), 
                        AncestorOf(String, String)  = #
    AncestorOf(x, y) :- ParentOf(x, y).
    AncestorOf(x, z) :- AncestorOf(x, y), AncestorOf(y, z).

def main(_args: Array[String]): Int32 & Impure =
    query getParents(), withAncestors() 
        select (x, y) from AncestorOf(x, y) |> println;

This displays the following results:

[(Granddaughter, GrandMother), (Granddaughter, Mother), 
    (Grandson, GrandMother), (Grandson, Mother), (Mother, GrandMother)]

Flix provides built-in support for tuples and records as well as algebraic data types and pattern matching:

enum Shape 
    case Circle(Int32),          // circle radius
    case Square(Int32),          // side length
    case Rectangle(Int32, Int32) // height and width

def area(s: Shape): Int32 = match s 
    case Circle(r)       => 3 * (r * r)
    case Square(w)       => w * w
    case Rectangle(h, w) => h * 
Read More

Desktops Revolutionized Chess. Magnus Carlsen Wins by Being Human

The World Chess Championship was presently a 7 days old when some thing gorgeous occurred in Match 6: soon after approximately 8 hours of play very last Friday, a person in fact received.

It was the very first time in five years that a championship classical game—the structure played underneath lengthy time controls—didn’t finish in a draw. The chess earth could rarely consider what it was viewing. In the age of supercomputer-skilled super grandmasters, there were common fears that environment championships had been becoming uninteresting and predictable. Planning seemed to trump inventiveness.

As an alternative, this era brought out the brilliance of possibly the most fantastic chess participant ever.

Magnus Carlsen, of Norway, steamrolled Russia’s Ian Nepomniachtchi 7.5-3.5 in the best-of-14 sequence, capturing a decisive victory that solidified his legacy as the best in the history of the sport. He has been the globe winner because 2013—this was his fifth win—and is the greatest-rated participant of all time.

What even his rivals marvel at is how Carlsen, 31, has weaponized the pc revolution towards them. He does it not by overpowering opponents with calculation, but by harnessing that electronic understanding to convert online games into a lot more human battles. 

“Magnus is proud of indicating that he’s in all probability the prime participant who functions the minimum with the computer and is the the very least motivated by the laptop,” said Carlsen’s coach, Peter Heine Nielsen. “He wishes to rely on his possess evaluation, his human touch and to retain that.”

For decades now, chess grandmasters have used the perception of pcs to study lines of engage in and check out the game’s bottomless prospects. That has grow to be supercharged in current decades as impressive engines, capable of scheduling depth far over and above the human thoughts, can be loaded on anyone’s notebook. Not only do they velocity up calculation—they are ready to get sport conditions and efficiently see into the potential.

Russian grandmaster Ian Nepomniachtchi has dropped a few game titles to Carlsen in this championship.


giuseppe cacace/Agence France-Presse/Getty Visuals

When gamers these kinds of as Carlsen and Nepomniachtchi have months to prepare for a planet championship, they are armed with a great number of hours of research on this variety of program. Centered on the programs’ evaluations, they master the optimum moves in the most probable circumstances. 

Carlsen understands all of these as properly as—or greater than—anyone on the world. But he also possesses a intellect so ingenious that his greatest move is typically not enjoying the greatest move. He would fairly direct the match down a extra obscure route exactly where the player across the board could get lost.

“They say chess is a deep dark forest complete of snakes and thorns,” reported Danny Rensch, the chief chess officer of “Magnus delivers his opponents into that forest.”

Chess champions have been tinkering with the very best way to deploy personal computers for half a century. Russian Anatoly Karpov, in 1978, reportedly qualified with an

Read More