As was briefly mentioned in Breaking Backwards Compatibility, I am launching a big iteration of php.js today. It includes so many breaking changes that it is safe to say that, after 9 years, php.js is dead. And, like a phoenix, Locutus has risen from its ashes.
Locutus will largely have the same mission:
Locutus will, however, also be different on a few key points. Locutus will focus on:
- Expanding to other languages, such as C, Go, Python and Ruby
- Hack-free porting, meaning we will only port individual functions from the standard libraries, while avoiding language features, environment, data-types and configuration
- The educational aspect and the intellectual challenge
- Using npm as the distribution platform of choice, so you can do
var strings = require('golang/strings')and, in case the browser is your target platform, bundle this via Browserify, rollup.js or webpack.
- Trying to deliver functions that are interoperable between browsers and Node.js, but also allowing to target just one platform when that saves us from writing overly wieldy code. These cases will be documented with a
note. An example of this would be opening a file from disk. We would then state it is Node.js-only.
While it is still very much a work in progress, I have already deprecated and updated many functions that did not adhere to this renewed focus. If you spot a function I overlooked, please let me know on GitHub.
I feel these changes were needed to regain the motivation required for leading this project. For a long time, I have struggled with php.js in its old form. I rarely did maintenance runs anymore and when I did, it was guilt-driven rather than out of curiosity or excitement - the things that led me to start this project.
There are several reasons why I had lost my intrinsic motivation:
- The things that could reasonably be ported, had already been ported. The things that probably should not have been ported, had been ported too - and were now mostly good for provoking purists and inducing maintenance load. Not very rewarding.
- I started a new company and protocol, which took much time by itself, but also meant I spent my time writing exclusively in other programming languages. You won’t find any bitterness about that here, but it did mean I had less time and use for PHP oriented projects
Knowing that I was beginning to fall short as a project lead, I tried to recruit fresh blood to replace me. However, even though there is still an active community of contributors, I couldn’t find any volunteers for taking the lead. For a while, I considered declaring
[UNMAINTAINED], but I felt - and still feel - too great a deal of duty and responsibility towards past and present contributors.
So instead, I started thinking about what it would take for me to get my mojo back. Having analyzed what had crippled it over the past 9 years, I decided to make the changes that would allow it to flow back again.
If you are interested in the nuts and bolts, these are a few things I have been secretly working on in order to clean up our codebase and breathe new life into this project. I have:
- Added (generated) Mocha tests for every function, instead of our own test framework
- Added a
$globalthat works in both Browsers and Node.js (we should try to avoid this when we can though)
- Added a CONTRIBUTORS guide as well as New Issue and Pull Request templates, so we can be more efficient using GitHub
- Added native JSON, base64, sha1 and md5 support where available
- Added npm versioning and releases
- Asked Troy Dodd if we could use his stunning Locutus artwork to be our avatar (and he said yes!)
- Deprecated/documented all functions using
new Functionand other bad practices
- Fixed around 50 failed tests that were previously marked as skipped (still a few to go)
- Made it so that all functions can be required individually via npm
- Made it so that dependencies between functions are now handled via CommonJS
- Moved the website from Jekyll to Hexo, so that we lose a Ruby dependency and everything needed to work on the website can be
- Refactored the utility class
_experimentalfolders. They are available for reference in 1.3.2, but making them harder to find for newcomers should help avoid complaints and confusion. If you want to experiment, we can use local files or branches when it’s time to collaborate.
I understand this all can feel like a radical shift, since functions have different locations and there is talk of deprecating functions. Perhaps you wrote these functions with your own blood, sweat and tears. To make matters worse, I will also be deprecating many GitHub Issues and Pull Requests that have become invalid due to this new major push.
As a contributor to this project, I hope Locutus brings the changes that can spark your interest again, just as it has for me. I hope you will join me on this new adventure to a magical land of standard libraries full of functions that are just screaming to be ported. I am looking at you, rainy Sunday afternoon..
This time we will be a little bit older, a little bit wiser, and hopefully have the resolve to steer clear of the darker areas. Nevertheless, we will have just as much fun in challenging ourselves and each other, as well as by learning other languages. I promise! : )
For those that can forgive me for my past mistakes and for deprecating some of our previous work in this new major release: you can try Locutus right now if you want:
$ npm init
var echo = require('locutus/php/strings/echo')
$ node index.js
If you want to help Locutus, our newly added languages don’t have much meat on the bones yet and it would be fantastic to see if you can think of ways to assimilate a function that Locutus currently does not harbor.
Also, there are plenty project-wide ideas in our Backlog that we would love help with, so I guess there is just one thing left to say..