# Category:Phix

**Phix**

This

**programming language**may be used to instruct a computer to perform a task.

Official website |
---|

Execution method: | Interpreted or compiled |
---|---|

Garbage collected: | Yes |

Parameter passing methods: | By reference, By value |

Type expression: | Explicit |

Type checking: | Dynamic, Static |

Lang tag(s): | phix, Phix |

See Also: |

Phix is a self-hosted hybrid interpreter/compiler, developed by Pete Lomax. It is very easy to use, and similar to Euphoria.

On 26th December 2021, Phix became the first programming language on this site to have submissions for 100% of all tasks.

(On 20th June 2022 Wren became the second, albeit with 13+63 of those embedded that I, for one, have been unable to run.)

A simple 30MB download contains a pre-compiled executable, all the sources, and* everything *needed to recompile them, in under 20 seconds. The download also contains a full-featured programmer's editor and about 1000 demo programs.

You can also run Phix on replit here, and several manually transpiled and uploaded entries here

Perhaps the most striking feature of Phix is that it has just five builtin data types:

<-------- object ---------> | | +-atom +-sequence | | +-integer +-string

Despite such apparent simplicity, or perhaps precisely because of it, Phix programs are pretty fast - not quite achieving the runtime performance of C or assembly, but making up for it with a very fast edit/run cycle and proper human-readable messages should anything go wrong (even in shipped pre-compiled executables). Sequences are the real powerhouse of Phix. The one type covers lists, queues, tables, trees, and arrays, with strings being the subset that is array of character. They can grow and shrink automatically without any memory management overhead. For example if `s="food"` then `s[2..3]="e"` makes `s` "fed", and then `s[2..1]="east"` makes `s` "feasted".

Phix applies the principle of least surprise, for instance in some languages `myproc(list)` or `res = myfunc(list)` can mangle list, whereas in Phix if you actually want that to happen you would code `list = myproc(list)` (and myproc would need to become a function) or `{res,list} = myfunc(list)`. Likewise 1/2 is 0.5 (not 0, unless you explicitly ask for the floor()) and 0-1 is -1 (not +MAXINT). A core tenet is that for any line of code there is one and only one possible interpretation of it, and said meaning is utterly intuitive. True fact: the given answer for the question "describe what f(a++) does" in "More Exceptional C++" lists 4 possibilities for f, and 3 for a (so 12 in total) and uses the phrase "could mean just about anything" not once but twice - shudder.

Phix supports object orientation, but does not enforce it, and can achieve many of the claimed benefits in a much simpler way. In fact I have been looking for * proof* that object orientation actually improves productivity compared to other paradigms for decades, and never found it. One other thing I have never found is a "good object orientated design", and reached the conclusion that mythical creature simply does not exist, at least not as a separate entity as opposed to some ethereal quality of the finished code. Feel free to argue that one on User_talk:Petelomax. Phix offers perfectly decent encapsulation at the file level, proving that is not the sole purview of oo, implements polymorphism far more elegantly than C-based languages and far safer than duck-typed languages, and as for the third pillar of oop, inheritance, well isn't the current mantra "favour composition over inheritance"?

Technically Phix does not have a garbage collector, instead it is reference counted, so memory is automatically reclaimed whenever a reference count drops to zero, and hence there are no sudden pauses, although the reference counting can itself reduce performance.

The fundamental goal of Phix is to make debugging easier, a whole subject area that does not seem to get the attention it deserves, despite several studies finding that most programmers actually spend between 70 and 90% of their time debugging. Most of us tend to think that getting just-written code to work is somehow not debugging, but that clipboard-toting researcher stood behind you would disagree.

Since 1.0.0 you can also run (many/most) Phix programs in a browser, by using pwa/p2js (as included in the distro) to transpile the program to JavaScript (plus a bit of standard HTML and CSS). If you see "**with javascript_semantics**" it means the program has been tested and works fine, both on the (Windows/Linux) desktop/Phix and in a browser via pwa/p2js, and in fact unix_dict() has been added to avoid reading unixdict.txt. Conversely, "without js" being present on a rosettacode entry means that (for instance) it uses the local file system, and is therefore desktop/Phix only. It is worth pointing out that "with js" and deep_copy() have proved *staggeringly* effective and nowhere near as painful as first feared. In just a few months (1.0.0 was released in July 2021) I have tested, fixed where necessary, and marked as javascript compatible *over 1,100 rosettacode entries* for Phix, and only *one seventh* of that have as yet been marked incompatible, despite things like file i/o being prohibited within a web browser. The Phix/online subcategory currently lists 78 entries deemed interesting enough to bother (manually) uploading to the Phix website (ping me should any stop working), and the next goal is to get pwa/p2js itself runnning online, but obviously without using file i/o directly.

## See also[edit]

## Subcategories

This category has the following 7 subcategories, out of 7 total.

### @

- Phix User (5 P)

### P

- Phix/basics (123 P)
- Phix/Class (23 P)
- Phix/libcurl (19 P)
- Phix/mpfr (72 P)
- Phix/online (98 P)
- Phix/pGUI (116 P)

## Pages in category "Phix"

The following 200 pages are in this category, out of 1,591 total.

(previous page) (next page)### C

- Cheryl's birthday
- Chess player
- Chinese remainder theorem
- Chinese zodiac
- Cholesky decomposition
- Chowla numbers
- Church numerals
- Cipolla's algorithm
- Circles of given radius through two points
- Circular primes
- Cistercian numerals
- Classes
- CLI-based maze-game
- Closest-pair problem
- Closures/Value capture
- Code Golf: Code Golf
- Code segment unload
- Collect and sort square numbers in ascending order from three lists
- Collections
- Color of a screen pixel
- Color quantization
- Color wheel
- Colorful numbers
- Colour bars/Display
- Colour pinstripe/Display
- Colour pinstripe/Printer
- Combinations
- Combinations and permutations
- Combinations with repetitions
- Combinations with repetitions/Square digit chain
- Comma quibbling
- Command-line arguments
- Commatizing numbers
- Comments
- Common list elements
- Common sorted list
- Compare a list of strings
- Compare length of two strings
- Compare sorting algorithms' performance
- Compile-time calculation
- Compiler/AST interpreter
- Compiler/code generator
- Compiler/lexical analyzer
- Compiler/Preprocessor
- Compiler/Simple file inclusion pre processor
- Compiler/syntax analyzer
- Compiler/Verifying syntax
- Compiler/virtual machine interpreter
- Composite numbers k with no single digit factors whose factors are all substrings of k
- Compound data type
- Concatenate two primes is also prime
- Concurrent computing
- Conditional structures
- Conjugate a Latin verb
- Conjugate transpose
- Consecutive primes with ascending or descending differences
- Constrained genericity
- Constrained random points on a circle
- Continued fraction
- Continued fraction/Arithmetic/Construct from rational number
- Continued fraction/Arithmetic/G(matrix ng, continued fraction n)
- Continued fraction/Arithmetic/G(matrix ng, continued fraction n1, continued fraction n2)
- Convert CSV records to TSV
- Convert decimal number to rational
- Convert seconds to compound duration
- Convex hull
- Conway's Game of Life
- Coprime triplets
- Coprimes
- Copy a string
- Copy stdin to stdout
- Count how many vowels and consonants occur in a string
- Count in factors
- Count in octal
- Count occurrences of a substring
- Count the coins
- Count the coins/0-1
- Countdown
- Cousin primes
- Cramer's rule
- CRC-32
- Create a file
- Create a file on magnetic tape
- Create a two-dimensional array at runtime
- Create an executable for a program in an interpreted language
- Create an HTML table
- Create an object at a given address
- Create an object/Native demonstration
- Create your own text control codes
- Cross compilation
- CSV data manipulation
- CSV to HTML translation
- Cuban primes
- Cubic special primes
- Cullen and Woodall numbers
- Cumulative standard deviation
- Currency
- Currying
- Curve that touches three points
- Curzon numbers
- CUSIP
- Cut a rectangle
- Cycle detection
- Cycles of a permutation
- Cyclops numbers
- Cyclotomic polynomial

### D

- Damm algorithm
- Data Encryption Standard
- Date format
- Date manipulation
- Dating agency
- Day of the week
- Day of the week of Christmas and New Year
- Days between dates
- De Bruijn sequences
- De Polignac numbers
- Deal cards for FreeCell
- Death Star
- Deceptive numbers
- Decimal floating point number to binary
- Decision tables
- Deconvolution/1D
- Deconvolution/2D+
- Deepcopy
- Define a primitive data type
- Delegates
- Delete a file
- Deming's funnel
- Department numbers
- Descending primes
- Detect division by zero
- Determinant and permanent
- Determine if a string has all the same characters
- Determine if a string has all unique characters
- Determine if a string is collapsible
- Determine if a string is numeric
- Determine if a string is squeezable
- Determine if only one instance is running
- Determine if two triangles overlap
- Determine sentence type
- Dice game probabilities
- Digit fifth powers
- Digital root
- Digital root/Multiplicative digital root
- Dijkstra's algorithm
- Dinesman's multiple-dwelling problem
- Dining philosophers
- Diophantine linear system solving
- Disarium numbers
- Discordian date
- Discrete Fourier transform
- Display a linear combination
- Display an outline as a nested table
- Distance and Bearing
- Distinct palindromes within decimal numbers
- Distinct power numbers
- Distributed programming
- Distribution of 0 digits in factorial series
- Diversity prediction theorem
- Divide a rectangle into a number of unequal triangles
- DNS query
- Documentation
- Dominoes
- Doomsday rule
- Dot product
- Doubly-linked list/Definition
- Doubly-linked list/Element definition
- Doubly-linked list/Element insertion
- Doubly-linked list/Element removal
- Doubly-linked list/Traversal
- Dragon curve
- Draw a clock
- Draw a cuboid
- Draw a pixel
- Draw a rotating cube
- Draw a sphere
- Draw pixel 2
- Duffinian numbers
- Dutch national flag problem
- Dynamic variable names

### E

- Earliest difference between prime gaps
- Eban numbers
- Echo server
- Eertree
- Egyptian division
- Egyptian fractions
- EKG sequence convergence
- Element-wise operations
- Elementary cellular automaton
- Elementary cellular automaton/Infinite length
- Elementary cellular automaton/Random number generator
- Elevator simulation
- Elliptic curve arithmetic
- Elliptic Curve Digital Signature Algorithm
- Emirp primes
- Empty directory
- Empty program
- Empty string
- Enforced immutability
- Engel expansion

- Execution method/Interpreted
- Execution method/Compiled
- Garbage collection/Yes
- Parameter passing/By reference
- Parameter passing/By value
- Typing/Expression/Explicit
- Typing/Checking/Dynamic
- Typing/Checking/Static
- Programming Languages
- Programming paradigm/Generic
- Programming paradigm/Imperative
- Programming paradigm/Object-oriented