Computer languages are like their real-life counterparts: They constantly evolve. But unique to the evolution of programming languages is the ability to expressly fork them -- to publicly announce a desire to branch off and deviate from the lineage. Sometimes the forks are temporary, with the new branch rejoining and influencing its parent. Other times, a useful variation of an existing language arises and is sustained. Or the mutation takes off, and an entirely new language is born.
The desire to tinker and innovate is only one reason to change a computer language. Another major impetus is that any programming language will in time show its limits, whether in the language itself or in its implementation. Those evolutionary pressures drive users to either change it for the better or to leave it behind for another option.
Most language forks evolve in one of three ways:
- As an entirely new, potentially incompatible branch of the language
- As a new language that compiles down to the original
- As a superset or subset of the original language, with features added or removed
Here we explore some of the more vibrant examples of each approach currently evolving today.
A new language: PHP and Hack
PHP's sheer popularity is both its blessing and its curse. The upside: Applications developed in the language are all but guaranteed to run anywhere. The curse? PHP's curious quirks and internal inconsistencies won't likely be ironed out soon, lest the changes break backward compatibility with much existing PHP code.
The changes Hack brought to PHP demonstrate why a language fork can be appealing. Major changes to the language can be implemented without having to wait for approval from a steering committee or governing body. A proposal to add type hinting to PHP recently passed, but it might be a while before it lands in the actual language, let alone be used in production code. With Hack, those features can be used right now.
The downside of any fork is that it's likely to be backward-incompatible, meaning any code using the original language might not work. Hack provides a partial solution to this limitation by running on a virtual machine, HHVM, which also supports PHP -- allowing both languages to be deployed side by side on the same interpreter. In this way, an existing PHP codebase can be deployed alongside a newly minted Hack codebase, with the old deprecated over time in favor of the new.
Sign up for Computerworld eNewsletters.