Subscribe / Unsubscribe Enewsletters | Login | Register

Pencil Banner

Language forks bring new power to programming

Serdar Yegulalp | April 10, 2015
From Hack to Cython, inventive forks are pushing popular programming languages in new directions.

Language Forks

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:

  1. As an entirely new, potentially incompatible branch of the language
  2. As a new language that compiles down to the original
  3. 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.

Enter Facebook's Hack language. Hack is a variant of PHP, hatched from Facebook's use of the language at massive scale. It's designed to interoperate with PHP, but bristles with features that PHP doesn't offer, such as type annotations, JavaScript-like lambdas, Java- and C#-like generics, and much more.

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.


1  2  3  Next Page 

Sign up for CIO Asia eNewsletters.