Menu
Facebook's Flow could help JavaScript programmers spot elusive bugs

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

Subscribe here for up-to-date channel news

Follow Us

Join the New Zealand Reseller News newsletter!

Error: Please check your email address.

Tags Development toolsapplication developmentsoftwareFacebook

Featured

Slideshows

StorageCraft celebrates high achievers at its inaugural A/NZ Partner Awards

StorageCraft celebrates high achievers at its inaugural A/NZ Partner Awards

Revealed at a glitzy bash in Sydney at the Ivy Penthouse, the first StorageCraft Partner Awards locally saw the vendor honour its top-performing partners with ASI Solutions, SMBiT Pro, Webroot, ACA Pacific and Soft Solutions New Zealand taking home the top awards. Photos by Maria Stefina.

StorageCraft celebrates high achievers at its inaugural A/NZ Partner Awards
Kiwi resellers make a splash on Synnex and Lenovo RotoVegas road trip

Kiwi resellers make a splash on Synnex and Lenovo RotoVegas road trip

​Synnex and Lenovo hosted 18 resellers for an action-packed weekend adventure in RotoVegas, taking in white water rafting on the Kaituna River, as well as quad biking and dinner at Stratosfare​, overlooking Lake Rotorua at the top of Mount Ngongotaha​. Photos by Synnex.

Kiwi resellers make a splash on Synnex and Lenovo RotoVegas road trip
Show Comments