Environments: A Deep Dive

What Are Environments?

An environment is a filesystem snapshot of the runtime. It includes everything that is necessary to run whatever is in its associated code cells - from the operating system to the smallest dependency.

Environments make articles a fruitful basis for easy experimentation and collaboration.

Nextjournal automatically versions an article's entire dependency stack. If new dependencies are added, a new version of the environment is created. A researcher can always go back to a previous version, import the environment into a new article, or remix their work in an collaborative effort.

What's Happening

An environment is a filesystem snapshot of the runtime stored as a Docker image. These images are a sophisticated software abstraction hidden behind our notebook interface. You will never have to worry about how to install Docker, manage images, or prepare them for others to use. This quick tour of Nextjournal's architecture will help convey the power of the platform.

Docker Images

Most images used in Nextjournal use Ubuntu 18.04 LTS as a base. On top of that are system libraries that extend the functionality of the Linux core.

The stuff you care most about - your carefully crafted code, written descriptions, and imported datasets - all sit atop of this stack of dependencies. This is so tightly coupled that running a little code and some data on two different computers can require hours of effort to install and configure the correct software stack. Nextjournal's environments eliminate concerns around dependencies so you can focus on your work.

Versioning

While Nextjournal does make setup easier, what we're really passionate about is making changes easier.

Version Control Systems like Git have revolutionized the development of software by recording every committed change to source code. This simplifies collaboration by reducing risk and ultimately incentivizes openness; if someone commits an ill-advised change, simply rewind to a previous version of the source code.

Nextjournal offers versioning across your entire project: from your source code all the way down to the most basic dependency. This means:

  • Sharing research with a peer is no longer difficult. Provide a URL and it immediately runs in their web browser.

  • Updating a depreciated library is no longer a risky position. Install the new software, tinker with your code, and if it's not working out, rewind.

  • Collaborating is no longer painful. Others can take your fully-attributed work, hit the remix button, and experiment with different datasets and easily alter code.

Default Environments

The default environments available in Nextjournal are listed below. Note that each language is running within this notebook. A true polyglot experience.

Default environments are no different then your own custom environments. To see any environment's features and how it is built, click on the language name in the lower right corner of any cell.

Bash

Based on Ubuntu 18.04 LTS.

lsb_release -d
0.7s
Bash

Python

Python default environments with support for code completion through the jedi package.

Python 3

import sys, jedi, numpy, scipy, matplotlib, altair
sys.version
0.9s
Python 3 (Python)
'3.7.5 (default, Oct 25 2019, 15:51:11) \n[GCC 7.3.0]'

Python 2

import sys, jedi, numpy, scipy, matplotlib, altair
sys.version
0.4s
Python 2 (Python)
'2.7.17 |Anaconda, Inc.| (default, Oct 21 2019, 19:04:46) \n[GCC 7.3.0]'

Tensorflow

import warnings, platform
with warnings.catch_warnings():
  warnings.filterwarnings("ignore",category=FutureWarning)
  import tensorflow as tf
  print("Python version: %s.\nTensorflow version: %s.\n" % 
    (platform.python_version(),tf.__version__)) 
0.7s
TensorflowPython + Tensorflow (Python)

Pytorch

import platform, torch
print("Python version: %s.\nPyTorch version: %s." %
      (platform.python_version(),torch.__version__))
1.6s
PyTorchPython + PyTorch (Python)

R

R.version.string
0.8s
R

Julia

"$VERSION"
0.8s
Julia (Julia)
"1.3.0"

Clojure

(clojure-version)
0.1s
Clojure
"1.10.1"

Jupyter

Agda

agda -V
0.8s
Agda (Bash in agda)

Elixir

System.version
0.6s
Elixir
"1.9.1"

F#

mono -V | grep "Mono JIT compiler version"
msbuild -ver | grep -e "Microsoft.*version"
fsharpc --help | grep -e "Microsoft.*version"
nuget | grep "NuGet Version:"
paket --version
2.1s
Bash in F#

Go

import ( "runtime" )
runtime.Version()
1.6s
Go (lgo)

Haskell

echo "Stack $(stack --version | sed s/,.*//)"
grep resolver ${STACK_ROOT}/global-project/stack.yaml
stack exec ghc -- -V
echo "IHaskell version $(ihaskell -V)"
0.8s
Bash in Haskell

IPython

__IPYTHON__
0.1s
IPythonJupyter IPython (Python)
True

IR

IRkernel::log_error("Hello, world.")
0.7s
IRkernelJupyter IRkernel (R)

IJulia

IJulia.set_verbose(false)
3.7s
IJuliaJupyter IJulia (Julia)
false

Node.js

process.version
0.2s
Javascript (Node.js)
'v10.16.2'

Racket Scheme

(version)
0.1s
Racket
"7.3"

Ruby

RUBY_VERSION
0.0s
Ruby 2.6.3
"2.6.3"

Rust

extern crate rustc_version_runtime; use rustc_version_runtime::version;
println!("Rust v{}", version());
18.1s
Rust

Scala

val ver = scala.util.Properties.versionString
1.2s
Scala 2.12.8
ver: String = "version 2.12.8"

Xeus Cling C++

#include <iostream>
std::cout << "Clang version " << __clang_version__ << std::endl;
0.4s

More Than a Notebook

Nextjournal promises complete reproducibility across your entire project. For a broad overview what what makes Nextjournal different from other notebooks and development environments, check out Why Nextjournal or sign up today to try for yourself.

Runtimes (22)
Runtime Languages (11)