Setting Up Your Linux Machine for Google’s Carbon Programming Language

And printing “Hello World”

Photo by Safar Safarov on Unsplash

Prerequisites

Local Installation

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> /home/"user"/.profileeval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
# Ubuntu 16.04 (LTS) uses OpenJDK 8 by default:
sudo apt install openjdk-8-jdk

# Ubuntu 18.04 (LTS) uses OpenJDK 11 by default:
sudo apt install openjdk-11-jdk
# Install bazelisk using Homebrew.
$ brew install bazelisk
# Install Clang/LLVM using Homebrew.
# Many Clang/LLVM releases aren't built with options we rely on.
$ brew install llvm
$ export PATH="$(brew --prefix llvm)/bin:${PATH}"
# Download Carbon's code.
$ git clone https://github.com/carbon-language/carbon-lang
$ cd carbon-lang
# Build and run the explorer.
$ bazel run //explorer -- ./explorer/testdata/print/format_only.carbon
package ExplorerTest api;fn Main() -> i32 {
var s: auto = "Hello world!";
Print(s);
return 0;
}
Hello World! by author

Note:

--

--

Writer. Techie. History buff. If it changes the world I’m on its case. Open for gigs… freddynjagi@gmail.com! Published by the Writing Cooperative.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Mwanikii

Writer. Techie. History buff. If it changes the world I’m on its case. Open for gigs… freddynjagi@gmail.com! Published by the Writing Cooperative.