Wednesday, 2 November 2016

Expanding Horizons

Fig 1. My view of the horizon this morning.

Recently I have been working on a new extension. It is a wrapper around libui, which is a cross platform user interface development library, that allows the creation of native look and feel interfaces in the environments it supports.

The gravitas of this may not hit you in the face, until you see something like this:


 That's a few hundred lines of PHP 7 code, moulded into an imitation of the snake game we all used to have on our phones.

We've seen other user interface extensions before in PHP, there's even a modified PHP runtime that will allow you to write GTK+ applications.

I don't know anyone that ever deployed any of those extensions, and for very good reasons; PHP5 can barely do anything without allocating a bunch of memory, and doing a bunch of other extremely inefficient things, almost everything it does is inefficient. Beyond a basic forms like application, PHP5 is close to useless.

The snake game runs on my machine using a tiny amount of CPU, and a tiny amount of RAM, while more complex things can take up more resources, they can also achieve very decent frame rates.

PHP 7 is not just fast, it's efficient; It's not unreasonable to expect it to achieve 60 frames per second.

(Note: download the video above from github, streaming it in a browser may not work).

libui is in it's infancy, and is not complete, however there is nothing that is out of bounds for us in PHP, when libui supports it.

The UI extension is documented in the PHP manual, and is already on v2. It will move forward about as quickly as libui.

I'm not a game or UI designer, I don't like to do anything you look at normally.

I wrote this extension to expand our horizons, so that you can create things I cannot imagine ... enjoy it ...

5 comments:

  1. 3D graphics and you got something man. Cool stuff though.

    ReplyDelete
  2. How this is different from https://github.com/gabrielrcouto/php-gui ?

    ReplyDelete
  3. Joe, thank god people like you exist!

    ReplyDelete