Programming Languages on FreeBSD: Complete Guide
FreeBSD is a serious development platform. Clang ships in base, DTrace is built in, and jails give you isolated environments without the overhead of full virtualization. Whether you are building system utilities in C, deploying web applications in Python, or compiling performance-critical services in Rust, FreeBSD has first-class or near-first-class support for every major programming language.
This guide covers thirteen languages with concrete installation commands, version management strategies, and FreeBSD-specific notes that matter in practice.
FreeBSD as a Development Platform
Before diving into individual languages, it is worth understanding what makes FreeBSD distinct as a development environment.
Clang is the default compiler. FreeBSD switched from GCC to Clang/LLVM in the base system years ago. This means every FreeBSD installation can compile C and C++ code out of the box with no additional packages. GCC is available via pkg when you need it for compatibility reasons.
DTrace is built in. FreeBSD includes DTrace support in the kernel, giving you production-safe dynamic tracing for any language that supports it. You can trace system calls, profile function execution, and debug performance issues across your entire stack. See our DTrace tutorial for a practical introduction.
Jails provide lightweight isolation. Instead of spinning up Docker containers or virtual machines, you can use FreeBSD jails to create isolated development environments. Each jail gets its own filesystem, network stack, and package set. This is invaluable when you need to test against multiple language versions or library configurations simultaneously.
Ports and packages coexist. The pkg binary package manager handles most cases, but the Ports Collection lets you compile any package from source with custom options. This matters for languages like Python where you might want specific build flags or for situations where the binary package lags behind upstream releases.
C and C++ (Clang in Base, GCC via pkg)
C and C++ need no installation on FreeBSD. Clang is part of the base system.
sh# Check the base system compiler cc --version c++ --version # Install GCC if needed for compatibility pkg install gcc13 # Use GCC explicitly gcc13 -o myprogram myprogram.c g++13 -o myprogram myprogram.cpp
Version management: The base system Clang version tracks the FreeBSD release. For newer Clang versions, install llvm18 or whichever version you need from packages. Multiple GCC versions can coexist side by side.
FreeBSD-specific notes: Many C projects assume GCC and use GCC-specific extensions. Clang handles most of these, but you will occasionally need -Wno-error flags or minor source patches. The CFLAGS and LDFLAGS environment variables work as expected. FreeBSD's make is BSD make, not GNU make -- install gmake if your project requires it.
Common use: System programming, kernel modules, ports/package development, embedded systems, performance-critical applications.
Python
Python is the workhorse for scripting, automation, web development, and data science on FreeBSD.
sh# Install Python (latest stable) pkg install python311 # Or install a specific version pkg install python39 pkg install python310 # Install pip and venv pkg install py311-pip py311-virtualenv # Create a virtual environment python3.11 -m venv myproject source myproject/bin/activate
Version management: FreeBSD packages multiple Python versions simultaneously. You can have Python 3.9, 3.10, and 3.11 installed at the same time. The python3 symlink points to the default version. For more granular control, use pyenv which builds Python from source:
shpkg install pyenv pyenv install 3.12.0 pyenv global 3.12.0
FreeBSD-specific notes: Some Python packages with C extensions may need portmaster or manual compilation if wheels are not available for FreeBSD. Set PYTHONDONTWRITEBYTECODE=1 in jails to avoid permission issues. The py311-sqlite3 package is separate from the main Python package -- install it if you need SQLite support.
Common use: Web applications (Django, Flask, FastAPI), automation scripts, system administration, data analysis, machine learning prototyping.
Rust
Rust has excellent FreeBSD support. The choice is between rustup (upstream installer) and pkg (system packages).
sh# Option 1: rustup (recommended for development) pkg install curl curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh # Option 2: system packages pkg install rust cargo # Verify rustc --version cargo --version
Version management: rustup is the clear winner here. It lets you switch between stable, beta, and nightly toolchains instantly. It also manages cross-compilation targets. The pkg version is fine for building Rust software you depend on but lags behind upstream by weeks or months.
shrustup default stable rustup default nightly rustup target add x86_64-unknown-freebsd
FreeBSD-specific notes: Rust's std library has full Tier 2 support for FreeBSD (x86_64 and aarch64). Most crates compile without modification. Crates that depend on Linux-specific syscalls (e.g., io_uring, epoll) will not work, but FreeBSD equivalents (kqueue) are well-supported. The cc crate correctly detects Clang on FreeBSD.
Common use: System tools, CLI applications, web services (Actix, Axum), performance-critical libraries, WebAssembly compilation.
Go
Go works well on FreeBSD with one important caveat around CGO.
sh# Install Go pkg install go # Verify go version # Set up workspace mkdir -p ~/go/{bin,src,pkg} export GOPATH=$HOME/go export PATH=$PATH:$GOPATH/bin
Version management: The pkg version is usually recent enough. For bleeding-edge versions, download the official binary tarball from golang.org and extract it to /usr/local/go.
FreeBSD-specific notes: CGO works on FreeBSD but uses Clang instead of GCC by default. Set CC=clang explicitly if a build script expects it. Some Go packages that use CGO and assume Linux headers will fail. Pure Go packages work without issues. The kqueue event mechanism is used instead of epoll, and Go's runtime handles this transparently.
sh# If CGO causes issues, try pure Go CGO_ENABLED=0 go build -o myapp .
Common use: Web services, microservices, CLI tools, network programming, DevOps tooling, container-adjacent infrastructure.
Java (OpenJDK)
FreeBSD provides multiple OpenJDK versions through packages.
sh# Install OpenJDK 21 (LTS) pkg install openjdk21 # Or OpenJDK 17 (previous LTS) pkg install openjdk17 # Set JAVA_HOME export JAVA_HOME=/usr/local/openjdk21 export PATH=$JAVA_HOME/bin:$PATH # Verify java -version javac -version
Version management: Multiple OpenJDK versions can coexist. Switch between them by changing JAVA_HOME. There is no jenv or sdkman equivalent packaged for FreeBSD, but both can be installed manually and work correctly.
FreeBSD-specific notes: The FreeBSD OpenJDK port requires fdescfs and procfs to be mounted. Add these to /etc/fstab if they are not already present:
shellfdesc /dev/fd fdescfs rw 0 0 proc /proc procfs rw 0 0
Java applications that use java.nio will use kqueue on FreeBSD, which performs well. Build tools like Maven and Gradle work without modification. Install them with pkg install maven or pkg install gradle.
Common use: Enterprise applications, Spring Boot services, Android development (limited), build tooling, big data processing.
Ruby
Ruby is well-supported on FreeBSD, with both system packages and rbenv available.
sh# Option 1: system package pkg install ruby32 # Option 2: rbenv (recommended for development) pkg install rbenv ruby-build rbenv init rbenv install 3.2.2 rbenv global 3.2.2 # Install bundler gem install bundler
Version management: rbenv is the standard approach. It compiles Ruby from source, so ensure you have build dependencies installed:
shpkg install autoconf bison libyaml libffi readline openssl
FreeBSD-specific notes: Some native gem extensions assume Linux. The nokogiri gem, for instance, works but may need pkg install libxml2 libxslt first. Rails development works fully on FreeBSD. The thin and puma web servers use kqueue for event handling.
Common use: Web applications (Rails, Sinatra), scripting, DevOps tooling (Chef, Puppet), static site generation (Jekyll).
PHP
PHP remains essential for web hosting and application deployment. FreeBSD supports multiple concurrent PHP versions.
sh# Install PHP 8.3 pkg install php83 php83-extensions # Install PHP-FPM for web serving pkg install php83-fpm # Enable FPM sysrc php_fpm_enable=YES service php-fpm start # Common extensions pkg install php83-mysqli php83-gd php83-curl php83-mbstring php83-zip php83-xml
Version management: FreeBSD packages PHP 8.1, 8.2, and 8.3 simultaneously. Each version has its own FPM service, configuration directory, and extension set. This makes running multiple PHP versions on the same server straightforward -- useful when migrating applications between PHP versions.
FreeBSD-specific notes: PHP-FPM configuration lives in /usr/local/etc/php-fpm.d/. The default pool configuration expects a www user and group. Composer installs cleanly via pkg install php-composer2. If you are setting up a full web stack on a FreeBSD VPS, PHP-FPM behind Nginx is the standard deployment pattern.
Common use: WordPress and CMS hosting, Laravel and Symfony applications, API backends, legacy application maintenance.
Node.js
Node.js and npm are available as packages. Multiple major versions are supported.
sh# Install the current LTS version pkg install node20 npm-node20 # Or the latest version pkg install node22 npm-node22 # Verify node --version npm --version
Version management: For switching between Node versions, install nvm (Node Version Manager):
sh# Install nvm pkg install nvm # Load nvm source /usr/local/share/nvm/nvm.sh # Install and use a specific version nvm install 20 nvm use 20
FreeBSD-specific notes: Native addons that depend on Linux-specific APIs (like inotify) will use FreeBSD alternatives (kqueue) if the package supports it. Most popular npm packages work without modification. Node uses libuv under the hood, which has solid FreeBSD support. The node-gyp tool uses Clang on FreeBSD, which occasionally causes issues with packages that assume GCC.
Common use: Web applications (Express, Next.js, Nest.js), API servers, build tooling, real-time applications, serverless functions.
Perl
Perl ships in the FreeBSD base system. No installation required.
sh# Check the base system version perl --version # Install a newer version if needed pkg install perl5.38 # Install CPAN modules cpan install JSON::XS cpan install DBI
Version management: The base system Perl is intentionally conservative. If you need a newer version, install it from packages. Both versions can coexist. Use the full path (/usr/local/bin/perl5.38) to invoke the packaged version.
FreeBSD-specific notes: Perl is deeply embedded in FreeBSD's infrastructure. Many system scripts and ports build tools depend on it. Do not remove or replace the base system Perl. The Ports Collection uses Perl extensively, and the portmaster tool is written in Perl.
Common use: System administration scripts, text processing, legacy applications, Ports Collection infrastructure, bioinformatics.
Lua and LuaJIT
Lua is lightweight, fast, and commonly used for embedding in applications and configuration.
sh# Install Lua pkg install lua54 # Install LuaJIT (JIT-compiled, faster) pkg install luajit-openresty # Install the LuaRocks package manager pkg install luarocks
Version management: Lua 5.3 and 5.4 are available as separate packages. LuaJIT is compatible with Lua 5.1. LuaRocks handles module installation for all versions.
FreeBSD-specific notes: LuaJIT is commonly used with Nginx (via OpenResty) for high-performance web applications on FreeBSD. The luajit-openresty package is the maintained fork and is preferred over the original LuaJIT. Lua's small footprint makes it ideal for use inside FreeBSD jails where you want minimal overhead.
Common use: Nginx scripting (OpenResty), game development, embedded scripting, configuration languages, Redis scripting.
Zig
Zig is a modern systems language gaining traction as both a standalone language and a drop-in C/C++ cross-compiler.
sh# Install Zig pkg install zig # Verify zig version # Compile a simple program zig build-exe hello.zig # Use Zig as a C compiler zig cc -o myprogram myprogram.c
Version management: The pkg version may lag behind upstream. For the latest release, download the official binary tarball from ziglang.org and extract it to /usr/local/zig.
FreeBSD-specific notes: Zig's FreeBSD support is Tier 2 (guaranteed to build). The zig cc command can cross-compile C code for multiple targets from FreeBSD, which is one of Zig's standout features. Zig does not depend on Clang or GCC at runtime -- it bundles its own compilation backend.
Common use: Systems programming, cross-compilation, C/C++ interop, game engines, performance-critical applications.
Haskell (GHC)
Haskell development on FreeBSD centers around the Glasgow Haskell Compiler and the Cabal or Stack build tools.
sh# Install GHC and Cabal pkg install ghc cabal-install # Update the package index cabal update # Install Stack (alternative build tool) pkg install stack # Create a new project cabal init myproject
Version management: GHC versions are tied to the package version. For multiple GHC versions, use ghcup which works on FreeBSD:
shcurl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh ghcup install ghc 9.6.3 ghcup set ghc 9.6.3
FreeBSD-specific notes: GHC compilation on FreeBSD is resource-intensive. Expect long build times for large Haskell projects. Some Haskell libraries that use Template Haskell or FFI bindings may need adjustments for FreeBSD. The network and unix packages work correctly. Stack works on FreeBSD but defaults to building from source since there are no pre-built binaries for most packages.
Common use: Compilers, formal verification, financial systems, concurrent programming, research.
Erlang and Elixir
Erlang's BEAM virtual machine runs well on FreeBSD, and Elixir builds on top of it.
sh# Install Erlang/OTP pkg install erlang-runtime27 # Install Elixir pkg install elixir # Verify erl -version elixir --version # Install Hex (Elixir package manager) mix local.hex
Version management: For multiple Erlang versions, use kerl. For multiple Elixir versions, use kiex. Both work on FreeBSD.
sh# kerl for Erlang pkg install autoconf curl -O https://raw.githubusercontent.com/kerl/kerl/master/kerl chmod +x kerl ./kerl build 26.2 26.2 ./kerl install 26.2 ~/erlang/26.2
FreeBSD-specific notes: Erlang's schedulers work well with FreeBSD's threading model. The BEAM VM uses kqueue for I/O polling on FreeBSD. For production Erlang deployments, FreeBSD is a well-tested platform -- WhatsApp famously ran on FreeBSD with Erlang. Elixir's Phoenix framework deploys identically to Linux.
Common use: Telecom systems, real-time messaging, distributed systems, Phoenix web applications, IoT platforms.
Language Comparison Table
| Language | Install Method | Version Management | FreeBSD Support | In Base? |
|----------|---------------|-------------------|-----------------|----------|
| C/C++ (Clang) | Base system | Tracks FreeBSD release | Excellent | Yes |
| C/C++ (GCC) | pkg install gcc13 | Multiple versions via pkg | Excellent | No |
| Python | pkg install python311 | pyenv, multiple pkg versions | Excellent | No |
| Rust | rustup or pkg install rust | rustup (stable/nightly) | Very Good (Tier 2) | No |
| Go | pkg install go | Binary tarball | Very Good | No |
| Java | pkg install openjdk21 | Multiple pkg versions | Very Good | No |
| Ruby | pkg install ruby32 or rbenv | rbenv, ruby-build | Good | No |
| PHP | pkg install php83 | Multiple pkg versions | Excellent | No |
| Node.js | pkg install node20 | nvm | Good | No |
| Perl | Base system | pkg install perl5.38 | Excellent | Yes |
| Lua | pkg install lua54 | Multiple pkg versions | Good | No |
| Zig | pkg install zig | Binary tarball | Good (Tier 2) | No |
| Haskell | pkg install ghc | ghcup | Fair | No |
| Erlang | pkg install erlang-runtime27 | kerl | Very Good | No |
| Elixir | pkg install elixir | kiex | Very Good | No |
Setting Up a Development Environment on FreeBSD
A practical development setup on FreeBSD combines several of the tools discussed above. Here is a general approach:
- Start with a clean FreeBSD installation on a VPS or local machine.
- Use jails for project isolation. Each jail can have its own language runtime, dependencies, and configuration. See our jails guide for setup instructions.
- Install your language toolchains using the commands above.
- Set up your editor. Neovim (
pkg install neovim) and VS Code (via remote SSH) both work well on FreeBSD. - Use DTrace for profiling. Once your code runs, use DTrace to profile system calls, trace function entry/exit, and identify bottlenecks without modifying your code.
Frequently Asked Questions
Which programming languages are included in the FreeBSD base system?
FreeBSD includes C and C++ compilers (Clang/LLVM) and Perl in the base system. Everything else -- Python, Rust, Go, Java, Ruby, PHP, Node.js, and others -- must be installed via pkg or the Ports Collection. The base system also includes sh (POSIX shell) and awk.
Can I use Docker on FreeBSD for language development?
Docker does not run natively on FreeBSD. FreeBSD has its own containerization mechanism called jails, which predates Docker by over a decade. Jails provide similar isolation with lower overhead. For workflows that specifically require Docker (e.g., Docker Compose stacks with multiple services), you would need a Linux VM running on FreeBSD via bhyve. For most development purposes, jails are a superior alternative on FreeBSD.
Is Rust well-supported on FreeBSD?
Yes. Rust has Tier 2 support for FreeBSD on x86_64 and aarch64. This means the Rust project guarantees that the standard library and compiler build on FreeBSD, and pre-built binaries are available via rustup. The vast majority of crates on crates.io compile without modification on FreeBSD. Crates that depend on Linux-specific syscalls are the exception, not the rule.
How do I manage multiple Python versions on FreeBSD?
You have two options. First, FreeBSD packages multiple Python versions simultaneously (e.g., python39, python310, python311), and you can install all of them. Second, you can use pyenv to build any Python version from source. In both cases, use virtual environments (python3 -m venv) to isolate project dependencies. Avoid modifying the system Python installation.
Does FreeBSD support Java development?
FreeBSD provides OpenJDK packages for Java 17 and Java 21 (both LTS releases). Maven, Gradle, and other Java build tools are available as packages. The main FreeBSD-specific requirement is mounting fdescfs and procfs, which are needed by the JVM. Once that is done, Java development on FreeBSD is identical to Linux in practice. IDEs like IntelliJ IDEA can connect to FreeBSD via remote development or SSH.
Why does FreeBSD use Clang instead of GCC?
FreeBSD switched to Clang/LLVM as the default compiler starting with FreeBSD 10 in 2014. The primary reasons were licensing (LLVM uses a permissive BSD-compatible license while GCC moved to GPLv3) and technical merit (Clang provides better error messages, faster compilation, and modular architecture). GCC is still available as a package for code that requires GCC-specific extensions or behavior.
Can I cross-compile from FreeBSD to Linux or other platforms?
Yes, with certain toolchains. Zig is particularly good at this -- zig cc can target Linux, macOS, and Windows from FreeBSD. Rust supports cross-compilation via rustup target add. Go supports cross-compilation natively with GOOS and GOARCH environment variables. For C/C++, you will need to install cross-compilation toolchains, which is more involved but possible through the Ports Collection.
Conclusion
FreeBSD provides a stable, well-engineered platform for software development across the full spectrum of programming languages. The combination of Clang in base, DTrace for profiling, jails for isolation, and a comprehensive package collection makes it competitive with any Linux distribution for development work.
The languages with the strongest FreeBSD support -- C/C++, Python, Perl, Rust, Go, PHP, and Erlang -- work with minimal friction. Languages like Java, Ruby, and Node.js require minor setup steps but function fully once configured. Even newer languages like Zig and toolchains like Haskell's GHC are available and functional.
Start with pkg install for your language of choice, set up a jail for isolation, and build from there.