Porting alien software to Plan 9

Plan 9's C dialect (for the most part) consists of a less sophisticated pre-processor and a few extensions to the language proper. The extensions are described briefly on the 2c(1) man page and in more detail in the paper "How to Use the Plan 9 C Compiler" (/sys/doc/comp.ps).

Plan 9 also includes a compatibility subsystem called APE, the ANSI/POSIX Environment, which includes a complete ANSI pre-preprocessor.

The biggest differences you're likely to run into on this level are the libraries. Plan 9 provides different libraries for many of the standard functions. And obviously many things - such as networking - are done completely differently. Again, APE provides the ANSI/POSIX libraries and many common extensions.

As suggested here a few times before, APE may actually be a more exactly conforming ANSI/POSIX environment than many Unix systems. But the preferred development environment is still Plan 9's native environment, which provides access to the native libraries, compiles faster, and results in faster executables. Nearly all the C code in the system as distributed (gs and troff are the only exceptions I can think of) are written in Plan 9's C dialect.

As far as other languages, people have ported Perl, Python, and MosML with some success. They are not distributed with the system, but see the links at the bottom of this page for pointers. There was a C++ compiler in the 2nd edition, but not in the 3rd edition. rc(1), the shell, is excellent, with many improvements over the Bourne shell that make it well-suited to scripting. If you _need_ it, APE provides a mostly-ksh shell (minus the editing modes and history). There's also awk(1).

If you're doing applications-level work, and you're willing to learn something new, it'd be worth your time to learn Limbo, the programming language in Inferno. Inferno runs on Plan 9, and lots of other platforms too (various Unixes, Win-32, raw hardware). Limbo is a new language in the C lineage, with great facilities for inter-process communication, multi-threaded, multi-process development, and a very nice syntax. Definitely worth your investigation.

mk(1) is used extensively in Plan 9 for keeping binaries up to date from source. Mk is described in more detail in the paper "Maintaining Files on Plan 9 with Mk" (/sys/doc/mk.ps). Its function is similar to make (which, again, APE provides), but it's simpler and, consequently, more powerful. The paper "Plan 9 Mkfiles" gives some examples of how mk and mkfiles are used in the system. For an example of using mk outside of its normal role of building binaries, see /sys/doc/mkfile.

The common development environment (in the IDE sense of the term) is acme, a sort of combination shell, windowing system, and development environment. It's described in the acme(1) man page, and in the paper "Acme: A User Interface for Programmers" (/sys/doc/acme/acme.ps). Acme is available in both the Plan 9 and Inferno distributions. The name of the paper is somewhat misleading - it's quite useful for lots of non-programming tasks, as well. For example, my preferred email client runs in Acme, and I use Acme as my text editor.

Andrew Pochinsky partially ported SXM to Plan 9, take a look at http://www.malgil.com/sxm/ There are still missing things in the Plan 9 version, the most conspicuous being the lack of Unicode support. It could probably be fixed without changing the SXM character model, though.

David Gordon Hogan made the Plan 9 port of GCC 3.0(and related utilities) available to the public. There are three gzipped tar files:

The first one should be unpacked in the root of your Plan 9 system in order to install the various binaries, libraries etc in the required system locations. It's 386 only, that's all that works at this stage.

The second contains the sources of a port of the APE libraries which works with GCC. APE is distributed under the terms of the Plan 9 License. It should be unpacked into /sys/src/gnu/ape.

The third archive is a snapshot of the sources used to build GCC et al. It's in a slightly unkempt state. Consult the README file for more details. It should be unpacked into /sys/src/gnu. GCC, Binutils, and the other files in the third archive are distributed in accordance with the GPL.

The two archives are also linked from http://plan9.bell-labs.com/plan9/addons.html.

From: Latchesar Ionkov (lucho@gmx.net)
Subject: Re: [9fans] Java for Plan 9?
Newsgroups: comp.os.plan9 Date: 2001-10-24 07:19:08 PST

On Wed, Oct 24, 2001 at 08:44:28AM +0000, Matt Senecal said:
> Not to raise the spectre of Java over Plan 9, but has there been any attempt
> to create a Plan 9 JVM that adheres to the Java specs 100%?

I am porting CVM virtual machine
http://java.sun.com/products/cdc/cvm
to Plan9. CVM is J2EE compliant
and its source looks much better than the JVM one. I don't have much
free time and my interest on the port is not consistent, so there is
nothing to show. So far I ported the most difficult parts of the HPI
(threads, locks and JNI). My current excuse are the restrictions of
the filenames. I am waiting for 9P2000 :)

Lucho

The Kaffe Java implementation has now been ported to Plan 9. Kaffe for Plan 9 was originally created by the Bela Lugosi team as part of their undergraduate studies at the Helsinki University of Technology. In addition to the java interpreter, Kaffe distribution package contains a just-in-time compiler implementation. But it is incomplete and not fully functional. This port is for Intel 386 compliant platforms only.

LINKS