The Phix Programming Language Reference Manual

Version 1.0.2



Phix has several advantages over other programming languages:
  • A remarkably simple, yet flexible and powerful language definition that is easy to learn and use.
  • A high-performance interpreter/compiler/transpiler much faster than most.
  • Fully managed dynamic data storage with no requirement to allocate or free memory.
  • Variables can grow or shrink to any size without any manual housekeeping.
  • Extensive run-time checking for: out-of-bounds subscripts, uninitialized variables, bad parameter and variable assignments and many more. There are no mysterious machine exceptions -- you always get a full English description of any problem that occurs within your program at run-time, with the exact source line it occurs on, along with a full call-stack listing and a dump of all of your variable values. Programs can be debugged quickly, easily, and more thoroughly.
  • A source level debugger allows execution of programs line-by-line. Tracing can begin (or end) on any line or for any condition, under full programmer control.
  • A built-in execution profiler identifies which lines of code take up the highest percentage of execution time, or are executed the most often.
  • Features of the underlying hardware are usually hidden. Programs are not typically aware of word-lengths, bit-representations, byte-order etc.
  • However, Phix also satisfies anyone with a deeper curiosity. There is no hidden wall between the language and the operating system to fully understand how things actually work. Phix can create low-level listing files which show the exact addresses and assembly instructions generated, and also includes a program (filedump.exw) that shows every bit and byte in full detail (within reason, for example icons and other such data are shown in raw hex), for Windows PE, Linux ELF, and other format files.
  • Self-hosted so there is no need to know another language, or obtain any other development tools, to enhance or fix the language itself. You can easily download, install, and recompile Phix in less than two minutes! (See the short webcast at, and also Recommended Tools.)
  • Standalone executables can be created simply by adding a "-c" flag to the normal interpret command (or via Ctrl F5 if using Edita). (The detailed assembly listing mentioned above is likewise just a "-d".) There are no complicated compiler options to remember and there is no separate linking phase. A simple format directive in the source allows for easy cross-compilation to any other supported system.
  • Phix programs are naturally generic. The example program shows a single routine that will sort any type of data -- integers, floating-point numbers, strings etc. Phix achieves many of the benefits of object-oriented programming (which it has too, in an entirely optional fashion), yet in a much simpler way.
  • Phix programs are naturally cross-platform, as long as you are not doing something obviously operating-system-specific such as reading the Windows registry, most programs should run unaltered on Windows, Linux, in a Web Browser [albeit not file i/o etc for the latter], and, hopefully soon, on a Raspberry Pi.
  • It is not permitted to override builtins (at least not globally) or (re)define operators in Phix. While there are a few neat little tricks that sort of thing can achieve, the mental drain of always having to worry whether some builtin routine or operator is doing what you expect becomes significantly reduced, besides the superior and far friendlier compile-time and run-time error messages make modifying several files far less terrifying in Phix than it is in other programming languages.
  • The Edita programmers editor is freely available, and written in Phix with everything you might expect, including multiple and user-definable syntax colouring, multilingual support, intellisense, autocompletion, code folding, integrated help, window painter, full source code, and more.
  • Complete with around five hundred(!) demo programs, some of which are trivial learing aids and several dozen of which are production-quality full-blown GUI applications. Even wi#th all that, it’s still only a 30MB download, with virtually no other dependencies [full disclosure: you almost certainly will want IUP on Linux, and maybe twenty-something of those demos do need some other bits ’n pieces installing].