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 newsletter!

Error: Please check your email address.
Rocket to Success - Your 10 Tips for Smarter ERP System Selection

Tags Development toolsapplication developmentsoftwareFacebook

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 Articles

Resources

PCW Evaluation Team

Ben Ramsden

Sharp PN-40TC1 Huddle Board

Brainstorming, innovation, problem solving, and negotiation have all become much more productive and valuable if people can easily collaborate in real time with minimal friction.

Sarah Ieroianni

Brother QL-820NWB Professional Label Printer

The print quality also does not disappoint, it’s clear, bold, doesn’t smudge and the text is perfectly sized.

Ratchada Dunn

Sharp PN-40TC1 Huddle Board

The Huddle Board’s built in program; Sharp Touch Viewing software allows us to easily manipulate and edit our documents (jpegs and PDFs) all at the same time on the dashboard.

George Khoury

Sharp PN-40TC1 Huddle Board

The biggest perks for me would be that it comes with easy to use and comprehensive programs that make the collaboration process a whole lot more intuitive and organic

David Coyle

Brother PocketJet PJ-773 A4 Portable Thermal Printer

I rate the printer as a 5 out of 5 stars as it has been able to fit seamlessly into my busy and mobile lifestyle.

Kurt Hegetschweiler

Brother PocketJet PJ-773 A4 Portable Thermal Printer

It’s perfect for mobile workers. Just take it out — it’s small enough to sit anywhere — turn it on, load a sheet of paper, and start printing.

Featured Content

Latest Jobs

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?