How to Install Pony Language on Windows 10 Using WSL 2: A Step-by-Step Guide

Learn how to install the Pony programming language on Windows 10 using WSL 2. This guide covers setting up WSL, installing Ponyup, configuring your environment, and compiling your first Pony program.

How to Install Pony Language on Windows 10 Using WSL 2: A Step-by-Step Guide
Photo by Annie Spratt / Unsplash

Pony is a modern, high-performance programming language designed for speed, safety, and concurrency. Combining object-oriented and actor-model paradigms, Pony allows developers to build efficient, parallel applications with ease.

This guide walks you through installing Pony on Windows 10 using the Windows Subsystem for Linux version 2 (WSL 2), enabling a smooth development experience on a Windows machine.

Prepare Your Windows 10 Environment with WSL 2

Before installing Pony, you need a working WSL 2 Linux distribution. If WSL is not yet enabled on your system, start by setting it up. Microsoft’s official documentation provides a detailed walkthrough, or you can check this comprehensive guide on Enabling Linux Subsystem on Windows 10.

Once WSL 2 and your preferred Linux distro (like Ubuntu) are installed and running, open your Linux terminal to proceed.

Install Ponyup, the Pony Toolchain Manager

Ponyup is the essential tool for installing and managing Pony compiler versions and updates. Without it, installing Pony is not possible.

Run the following command in your WSL terminal to download and install Ponyup:

sh -c "$(curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/ponylang/ponyup/latest-release/ponyup-init.sh)"

After installation, you will see a message indicating that ponyup has been placed in a local directory, typically:

/home/user/.local/share/ponyup/bin

To use ponyup globally, you need to make it accessible from anywhere.

Configure Ponyup for Global Access

You can make the ponyup command available globally by either updating your PATH environment variable or creating a symbolic link.

Option One: Update PATH Variable

Add the ponyup binary directory to your PATH:

export PATH=/home/user/.local/share/ponyup/bin:$PATH
source ~/.bashrc

Note that sometimes this method may not work immediately, requiring a terminal restart or manual source reload.

Create a symbolic link to /usr/bin so that ponyup is globally executable:

sudo ln -s /home/user/.local/share/ponyup/bin/ponyup /usr/bin/ponyup

Verify by running:

ponyup --help

You should see the help information, confirming ponyup is accessible.

Set Your Default Pony Platform

Pony requires setting the platform corresponding to your Linux distribution. For example, on Ubuntu 20.04, run:

ponyup default ubuntu20.04

Other supported platforms are listed in the official Pony documentation.

If your platform is not listed, you may skip this step.

Install a C Compiler Required for Pony

Pony is built using C, so a C compiler like Clang is essential.

On Debian-based distributions like Ubuntu, install Clang with:

sudo apt install clang

For Fedora or CentOS, use:

sudo dnf install clang

or

sudo yum install clang

You might also need to install additional libraries depending on your distribution; see the Pony additional requirements for details.

Install the Latest Pony Compiler Release

Now, install the Pony compiler (ponyc) with ponyup:

ponyup update ponyc release

Make the ponyc command globally executable similarly to ponyup by creating a symbolic link:

sudo ln -s /home/user/.local/share/ponyup/bin/ponyc /usr/bin/ponyc

Compile and Run Your First Pony Program

Create a simple Pony project to test your setup:

mkdir ~/helloworld && cd ~/helloworld
nano main.pony

Add the following code to main.pony:

actor Main
  new create(env: Env) =>
    env.out.print("Hello, world!")

Save and exit the editor (Ctrl+S then Ctrl+X).

Compile the program:

ponyc -o bin

The -o bin flag specifies the output directory.

Run the compiled program:

./bin/helloworld

You should see:

Hello, world!

Summary and Next Steps

Installing Pony on Windows 10 using WSL 2 provides a robust environment for developing fast, concurrent applications. With Ponyup managing your compiler and dependencies, and Clang installed as the required C compiler, you’re ready to build sophisticated Pony projects.

Future tutorials will cover setting up a full development environment, including editors, debugging tools, and advanced Pony features.

For more information, visit the official Pony website and explore their documentation to deepen your understanding of this powerful language.