Facebook's Flow could help JavaScript programmers spot elusive bugs

Flow offers much-needed static type checking for the JavaScrtipt language

Easing what has traditionally been a difficult programming task, Facebook has released as open source a debugging tool for JavaScript, called Flow, designed to highlight problems caused by the misuse of data types.

"Flow improves speed and efficiency so developers can be more productive while using JavaScript," Facebook engineers said in a blog item posted Tuesday. Facebook has used Flow for many of its own projects.

Flow is a static type checker, one that ensures that when a program is run that its variables, functions and other elements of code will adhere to their original specifications. It can check to see if a value assigned to a variable is the correct type, for instance, a number rather than a string of characters. It can also check to see if a function is passed the correct number of inputs.

Such error checks could prevent program failures, and help secure the program against malicious misuse. Type checking can also aid in maintaining the program's code base.

JavaScript has grown increasingly popular in the past few years as a Web development tool, not only for adding functionality to Web pages, but also for creating full-scale Web applications. Unlike more traditional programming languages such as C++, JavaScript does not provide any native static typing capabilities. Because it is a very expressive language, JavaScript does not lend itself easily to type-checking systems, the Facebook engineers wrote.

Other companies have tackled the challenge of adding static type checking to JavaScript. Microsoft, for instance, developed TypeScript, a superset of JavaScript code that can be compiled so type checks can be conducted.

Unlike TypeScript, Flow allows the developer to check only portions of the code. JavaScript frameworks often use techniques, such as reflection, that make it difficult to use type checking.

Running Flow does not require the programmer to compile the program, or otherwise prepare the program for inspection. Instead, it works as a background process. Flow can check standard primitive types such as numbers, strings, and Boolean values as well as structured types such as functions, objects, and arrays.

Flow is initially available as a plug-in for both the Emacs and Vim code editors, and versions for other editors may be released in the future. It also offers a API (application programming interface) so it can be used by other code analysis tools.

Facebook will routinely release tools as open source that company engineers originally developed for internal use, in hopes that others will further develop the tools. The company has released a virtual machine for running programs written in PHP, called the Hip Hop Virtual Machine. It has also released a popular JavaScript library for building user interfaces, called React, and a database engine for querying distributed sets of data, called Presto.

Joab Jackson covers enterprise software and general technology breaking news for The IDG News Service. Follow Joab on Twitter at @Joab_Jackson. Joab's e-mail address is Joab_Jackson@idg.com

Join the Good Gear Guide newsletter!

Error: Please check your email address.

Tags Development toolsapplication developmentsoftwareFacebook

Our Back to Business guide highlights the best products for you to boost your productivity at home, on the road, at the office, or in the classroom.

Keep up with the latest tech news, reviews and previews by subscribing to the Good Gear Guide newsletter.

Joab Jackson

IDG News Service
Show Comments

Most Popular Reviews

Latest News Articles


GGG Evaluation Team

Kathy Cassidy


First impression on unpacking the Q702 test unit was the solid feel and clean, minimalist styling.

Anthony Grifoni


For work use, Microsoft Word and Excel programs pre-installed on the device are adequate for preparing short documents.

Steph Mundell


The Fujitsu LifeBook UH574 allowed for great mobility without being obnoxiously heavy or clunky. Its twelve hours of battery life did not disappoint.

Andrew Mitsi


The screen was particularly good. It is bright and visible from most angles, however heat is an issue, particularly around the Windows button on the front, and on the back where the battery housing is located.

Simon Harriott


My first impression after unboxing the Q702 is that it is a nice looking unit. Styling is somewhat minimalist but very effective. The tablet part, once detached, has a nice weight, and no buttons or switches are located in awkward or intrusive positions.

Featured Content

Latest Jobs

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?