0

Phel Lang, a native LISP for PHP

 1 year ago
source link: https://24daysindecember.net/2022/12/17/introduction-phel-lang-a-native-lisp-for-php/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
Posted on 17th of December 202216th of December 2022 by Jose Maria Valera Reales

Phel Lang, a native LISP for PHP

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)

Why Phel?

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.

Features

– Built on PHP’s ecosystem

– Good error reporting

– Lists, Vectors, Maps and Sets

– Macros

– Recursive functions

– Powerful but simple Syntax

– REPL

Want to know more?

Visit the website at https://phel-lang.org and check out the GitHub repository.

Posted in 2022, PHPamily

Post navigation

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Comment *

Name *

Email *

Website

Save my name, email, and website in this browser for the next time I comment.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK