layout | title | description | redirect_from | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
page |
Getting started with Gleam |
Getting your computer ready for Gleam development. |
|
To prepare your computer for Gleam development you'll need to install Gleam, Erlang, rebar3 the Erlang built tool, and optionally install any Gleam plugins for your editor.
- Installing Gleam
- Installing Erlang
- Installing rebar3
- Editor Plugins
- GitPod online Gleam development environment
The easiest way to install Gleam on Linux, Windows, and Apple macOS is to download a prebuilt version of the compiler from the GitHub release page.
With Homebrew installed run the following:
brew update
brew install gleam
asdf is a tool for installing and managing multiple version of programming languages at the same time. Install the asdf-gleam plugin to manage Gleam with asdf.
Gleam is available through the Arch User Repository
as package gleam
. You can use your prefered helper
to install it or clone it for manual build from https://aur.archlinux.org/gleam.git.
Gleam is available in ports, and also in binary packages. You may need
to use the latest
package repo, amend per instructions in
/etc/pkg/FreeBSD.conf
. See below for adjusting your PATH to use latest
Erlang/OTP runtime and not just the standard OTP21:
$ pkg install -r FreeBSD lang/gleam lang/erlang-runtime23
$ export PATH=/usr/local/lib/erlang23/bin:$PATH
The compiler is written in the Rust programming language and so if you wish to build Gleam from source you will need to install the Rust compiler.
# Download the Gleam source code git repository
cd /tmp
git clone https://github.com/gleam-lang/gleam.git --branch v0.8.0
cd gleam
# Build the Gleam compiler. This will take some time!
make install
# Verify the compiler is installed
# Prints "gleam $VERSION"
gleam --version
Gleam compiles to Erlang code, so Erlang needs to be installed to run Gleam code.
Precompiled builds for many popular operating systems can be downloaded from the Erlang solutions website.
Guides for installing Erlang on specific operating systems can be found below, as well as information on installing multiple versions of Erlang at once using version management tools.
Once Erlang has been installed you can check it is working by typing erl -version
in your computer's terminal. You will see version information like
this if all is well:
$ erl -version
Erlang (SMP,ASYNC_THREADS,HIPE) (BEAM) emulator version 10.1
sudo apt-get update
sudo apt-get install erlang
sudo apt-get update
sudo apt-get install erlang
With Homebrew installed run the following:
brew update
brew install erlang
With Chocolatey installed on your computer run the following:
choco install erlang
The asdf version manager has a plugin for installing Erlang. Installation and usage instructions can be found here:
Latest stable compiled version:
$ wget https://s3.amazonaws.com/rebar3/rebar3 && chmod +x rebar3
From Source (assuming you have a full Erlang install):
$ git clone https://github.com/erlang/rebar3.git
$ cd rebar3
$ ./bootstrap
Stable versions can also be obtained from the releases page.
The rebar3 escript can also extract itself with a run script under the user's home directory:
$ ./rebar3 local install
===> Extracting rebar3 libs to ~/.cache/rebar3/lib...
===> Writing rebar3 run script ~/.cache/rebar3/bin/rebar3...
===> Add to $PATH for use: export PATH=~/.cache/rebar3/bin:$PATH
To keep it up to date after you've installed rebar3 this way you can use rebar3 local upgrade
which
fetches the latest stable release and extracts to the same place as above. A nightly version can
also be obtained if desired.
Gleam plugins are available for several popular editors. If one exists for your editor of choice consider installing it for syntax highlighting and other niceties.
- Vim - https://github.com/gleam-lang/gleam.vim
- Emacs - https://github.com/gleam-lang/gleam-mode
- Visual Studio Code - https://github.com/rawburt/vscode-gleam-syntax
- Sublime Text 3 - https://github.com/molnarmark/sublime-gleam
- Atom - https://github.com/itsgreggreg/language-gleam
Gleam can be tested on Gitpod. The environment comes with Erlang and Elixir. The port 3000 is also exposed if you want to run a web server.
Language Tour - In this chapter we explore the fundamentals of the Gleam language, namely its syntax, core data structures, flow control features, and static type system.