days
0
-31
-2
hours
0
-4
minutes
-3
-8
seconds
-3
-7
search
Google Research and Deep Mind engineers create Dex

Dex: New functional language for array processing

Maika Möbus
dex
© Shutterstock / eamesBot

There’s a new open source language for programming with typed indices: “Dex”, short for index. The Haskell-type language was developed as an unofficial project at Google Research and is still in the very early stages of development. Let’s take a closer look.

Dex is a new research language for array processing. It was developed by Google Research engineers Dougal Maclaurin, Alexey Radul and Matthew J. Johnson, alongside DeepMind’s Dimitrios Vytiniotis. They outlined the purpose of Dex in their workshop paper titled “Dex: array programming with typed indices”.

The concept of Dex

According to the researchers, some points complicate array programming more than necessary, e.g. managing bulk operations on high-rank arrays. The shape and indexing errors that are associated with them cause difficulties as well. That’s where Dex comes in. The functional array processing language originates in the Haskell/Meta Language (ML) family and is designed to offer an index comprehension syntax that is expressive and lightweight.

Dex could also serve as an inspiration for similar languages, as the engineers state in their paper: “We hope the language ideas we present here can influence the design of existing array programming systems.”

 

Examples

Some example programs on GitHub show Dex’s capabilities. Among them are the Mandelbrot set, the Brownian bridge and, as seen here, the Monte Carlo estimates of Pi:

estimatePiArea :: Key -> Real
estimatePiArea key =
  (k1, k2) = splitKey key
  x = rand k1
  y = rand k2
  inBounds = sq x + sq y < 1.0 4.0 * b2r inBounds estimatePiAvgVal :: Key -> Real
estimatePiAvgVal key =
  x = rand key
  4.0 * sqrt (1.0 - sq x)

meanAndStdDev :: A n. (Key -> Real) -> Key -> (Real, Real)
meanAndStdDev f key =
  samps = many @n f key
  (mean samps, std samps)

type NumSamps = 1000000

:p meanAndStdDev @NumSamps estimatePiArea 0
(3.143024, 1.6411874163007711)

:p meanAndStdDev @NumSamps estimatePiAvgVal 0
(3.1417837281469603, 0.892754742618003)

If you want to try out the new programming language, you need the Haskell Tool Stack as well as LLVM 7, e.g. via apt-get install llvm-7-dev.

SEE MORE: Top programming languages in 2019: Python sweeps the board

Dex is available on GitHub at Google Research under a BSD-3 license, as is the standard in the Haskell community. Further details can be found in the workshop paper.

Author
Maika Möbus
Maika Möbus has been an editor for Software & Support Media since January 2019. She studied Sociology at Goethe University Frankfurt and Johannes Gutenberg University Mainz.

Leave a Reply

avatar
400