For more than two years, Jens and Chema have worked hard to create what Phel is today. Phel is a Functional Programming language that compiles to PHP. It is a dialect of Lisp inspired by Clojure and Janet.
What does Phel look like?
Here is an example of some Phel code from the website.
# Define a namespace (ns my\example) # Define a variable with name "my-name" and value "world" (def my-name "world") # Define a function with name "print-name" and one argument "your-name" (defn print-name [your-name] (print "hello" your-name)) # Call the function (print-name my-name)
It is the result of many failed attempts to do functional programming in PHP.
We wanted to write a Lisp-inspired (Functional Programming) that runs on cheap hosting providers, and it’s easy to write and debug.
Object-Oriented vs Functional Programming
In OOP you manipulate objects (with methods), and they have a mutable state (as properties).
– Focus on “how you are doing”, mutable data, imperative programming, side effects, looping, …
In FP you have type structures that hold information, and everything else are functions.
– Focus on “how you are doing”, uses immutable data, declarative programming, no-side effects, recursion, …
How different is Phel from others?
Phel is highly inspired by Clojure, which runs on the JVM, and therefore it’s compatible with Java.
So, Phel is a dialect of Lisp that “compiles” to PHP, and therefore it’s 100% interoperable with PHP.
– Built on PHP’s ecosystem
– Good error reporting
– Lists, Vectors, Maps and Sets
– Recursive functions
– Powerful but simple Syntax
Want to know more?
Visit the website at https://phel-lang.org and check out the GitHub repository.