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


Follow Us

Join the New Zealand Reseller News newsletter!

Error: Please check your email address.

Tags Development toolsapplication developmentsoftwareFacebook

Featured

Slideshows

Sizing up the NZ security spectrum - Where's the channel sweet spot?

Sizing up the NZ security spectrum - Where's the channel sweet spot?

From new extortion schemes, outside threats and rising cyber attacks, the art of securing the enterprise has seldom been so complex or challenging. With distance no longer a viable defence, Kiwi businesses are fighting to stay ahead of the security curve. In total, 28 per cent of local businesses faced a cyber attack last year, with the number in New Zealand set to rise in 2017. Yet amidst the sensationalism, media headlines and ongoing high profile breaches, confusion floods the channel, as partners seek strategic methods to combat rising sophistication from attackers. In sizing up the security spectrum, this Reseller News roundtable - in association with F5 Networks, Kaspersky Lab, Tech Data, Sophos and SonicWall - assessed where the channel sweet spot is within the New Zealand channel. Photos by Maria Stefina.

Sizing up the NZ security spectrum - Where's the channel sweet spot?
Kiwi channel comes together for another round of After Hours

Kiwi channel comes together for another round of After Hours

The channel came together for another round of After Hours, with a bumper crowd of distributors, vendors and partners descending on The Jefferson in Auckland. Photos by Maria Stefina.​

Kiwi channel comes together for another round of After Hours
Consegna comes to town with AWS cloud offerings launch in Auckland

Consegna comes to town with AWS cloud offerings launch in Auckland

Emerging start-up Consegna has officially launched its cloud offerings in the New Zealand market, through a kick-off event held at Seafarers Building in Auckland.​ Founded in June 2016, the Auckland-based business is backed by AWS and supported by a global team of cloud specialists, leveraging global managed services partnerships with Rackspace locally.

Consegna comes to town with AWS cloud offerings launch in Auckland
Show Comments