Experiments

XP On Android

at 2013-05-04 in Experiments5.9-SERIES by friebe

Does XP run on different platforms? Yes! But usually, when we say that, we think about Windows PCs, Macs, your Ubuntu workstation or Un*x servers. The XP Framework contains code to make this possible, and cover as many details of the underlying platform for you as possibe.

ScreenshotBut what about tablets (or even smartphones)? Yes, we actually have been there a while ago. The most recent experiment in the row of platform adaption is XP on Android. To the right, see xp -v running on my GalaxyTab 2.

How was it done?
I used the APK provided by the PHP for Android project, which is a plugin for the Android-Scripting infrastructure. Both were installed using direct APK downloads, for which I needed to enable the "Install APKs from other sources" option. That gave me PHP (version 5.3.3) on Android. Unfortunately, this PHP binary comes without ext/tokenizer, a normally built-in PHP extension we rely on in parsing the annotations. Without this, the XP Framework won't work, so I started out handcrafting it. Once that was done, at least the framework's test suite would start. As expected, it was showing some errors, though.

Debugging
The process of editing on my Windows machine, then copying the file to the tablet, and then starting it by tapping the file inside the SL4A file list and choosing the "run in shell" option became a bit time-consuming. To my rescue, I found SSHDroid, which conveniently gave me SFTP and SSH shell access, something which can be better automated.

Status
With the new and more efficient setup I was able to make the XP Framework's core test suite pass completely on the tablet, yielding a green bar with OK: 931/1006 run (75 skipped), 931 succeeded, 0 failed inside. The changes in the framework and its test suite have already been committed and pushed.

The next steps would be to put up the necessary patches somewhere on GitHub:-)



PHP 5.5 Generators

at 2012-12-20 in PHP5Experiments5.9-SERIES by friebe

I started playing around with PHP's new generator functionality today now that 5.5.0 alpha2 has been released, trying to find out what they can be used for, and what real-life role they will play in a future XP Framework.

While they'll make some portions of code easier to write (and less code is always better!), they do come at the disadvantage that they're not 100% BC break free: As long as you iterate, you're fine, once you start using stuff as arrays, you're out of luck and will start seeing "Cannot use object of type Generator as array" fatals.

Where they'll come in handy is where we implement IteratorAggregate - its getIterator() implementation will become much easier; instead of having to construct an object with current, key, next, rewind and valid methods, we can simply yield the elements. One example is the util.collections.Vector class, which will be changed to contain just this:

  public function getIterator() {
foreach
($this->elements as $element) {
yield
$element;
}
}

Follow the code @ https://github.com/thekid/xp-experiments/tree/master/generators - note that this will require PHP 5.5.0+ (of course) and XP 5.9.0+ to run!



XP on NodeJS: Class constants, annotations, stacktraces

at 2012-03-21 in LanguageExperiments by friebe

More work has been put into the XP on NodeJS experiment: The compiler now knows how to correctly emit class constants and annotations, and a couple of minor bugs have been fixed. The bigger efforts have gone into stabilizing the XP "Microkernel" (which is what I've decied to call the miniature XP Framework implementation written in JavaScript and adopted to NodeJS as well as Windows Scripting Host):

  • We're finally getting inheritance right (or are we ? - :-))?
  • Class path is now assembled via class.pth files
  • Classes can reside freely inside any of the class path elements
  • Stack traces are now shown, including method names and arguments
  • Parent class reflection now works
  • The entry point scripts (tools/node.js and tools/cscript.js) are now generated from a common base
  • When these are invoked without arguments, they show version and classpath info
Here's something for you visually oriented people:

Screenshot

Finally, now, also the emitter dictates the file extension instead of it being hardcoded, so compiling is now completely hassle-free, no more moving the generated .class.php files around.

To get started, visit https://github.com/thekid/xp-js !



XP on NodeJS: Flow control, exceptions, loops

at 2012-03-11 in ExperimentsLanguage by friebe

The XP on NodeJS experiment continues to grow, with the following now implemented:

  • Flow control, via if / else
  • Exceptions, try, catch, throw and finally
  • Loops - foreach, for, do and while
  • ARM blocks

A full list of changes can be seen in the compare view.



XP on NodeJS

at 2012-02-26 in LanguageExperiments by friebe

Following discussions with Claus and Alex, with the XP compiler's long-thought-about strategy of enabling us to decouple the framework and the platform in mind, and based on the "JSXP" experiment I had started about a year ago, I created a first draft of a write-once, compile, run-multiple approach.

This is the starting point, the XP language in a file called Greet.xp.

public class Greet {
protected string
$greeting = 'Hello';

public void printGreeting
(string? $name) {
util.cmd.Console::writeLine
($this.greeting, ' ', $name);
}

public
static void main(string[] $args) {
new self().printGreeting($args[0]);
}
}


(more)

Userland database driver implementations

at 2010-07-09 in ExperimentsDatabases by friebe

Following a discussion we had about software packaging for our test, qa and live clusters (most of which run Debian Lenny, meaning it brings PHP 5.2.6 with the mssql extension, unfortunately unsuitable for ASE 15 / univarchar fields), we decided two things:

  1. We need to compile a more recent PHP version with sybase_ct ourselves
  2. We should investigate in more independence from installed system libraries and PHP extensions
The second point is really not a new decision, the XP Framework has a long history of userland implementations, reflection without the reflection library in PHP4 times, XML builders without ext/dom, the HTTP protocol without ext/curl or http_build_query or JSON without ext/json, to name just a few, and - more recently, FTP without ext/ftp, partially due to the fact that PHP didn't provide these functionalities at the time we implemented them and partially due to the fact that we couldn't count on the extensions being available everywhere we wanted to install and run the XP Framework.


(more)

Extension methods: Swiss army knives without the anti-pattern

at 2009-08-29 in Experiments5.8-SERIESRFCs by friebe

Swiss Army KnifeThe following calls a method called "sorted" on an instance of the lang.types.ArrayList class. The ArrayList class doesn't have such a method, and we'll thus get a nice "call to undefined method" error shortly before our program is terminated.

  $array= new ArrayList(3, 1, 2);
$sorted= $array->sorted();

We could add this method to the class, but the next request would be to have filter(), map(), join(), collect(), partition(), and whatever else methods in this class, which would turn it into the "swiss army knife" anti-pattern.


(more)

GUI API redesign

at 2008-12-07 in Experiments by friebe

The XP Framework's GUI apis date back to the PHP4 / GTK1 days and have not been touched since then. In desparate need of an overhaul, and following the PHP-GTK2 releases and the stability provided by its PHP5 backing, I began an experiment to redesign the API from scratch.

Watch the experiments' arena/gnome directory for more!



XP Runners in C#

at 2008-11-02 in Experiments by friebe

C# iconThe XP runner infrastructure (as described in RFC #0166) provides a flexible way to run the XP framework without having to configure PHP's system-wide include_path. Besides the already existing implementation in /bin/sh, there's now an implementation in C# (using the .NET framework 3.5). Apart from being a training project for my C# skills, it's also five times faster than using shell scripts on Windows via Cygwin:

http://experiments.xp-forge.net/xml/browse?arena,xprt,csharp



PHP 5.3 Experiments

at 2008-08-23 in PHP5Experiments by friebe

PHP Version 5All the experiments with the newest PHP version can be found at the XP Forge's 5.3 experiments.



Subscribe

You can subscribe to the XP framework's news by using RSS syndication.


Categories

News
General
PHP5
Announcements
RFCs
Further reading
Examples
Editorial
EASC
Experiments
Unittests
Databases
5.8-SERIES
Unicode
Language
5.9-SERIES