BT

Gulp Aiming to Dethrone Grunt

by João Paulo Marques on Jan 31, 2014 |

Fractal, a company who has been actively involved in the development of several popular Node.js modules has just released gulp, a new building system which is trying to replace Grunt as the most popular JavaScript task-runner.

According to gulp's documentation, the main characteristics this tool is trying to achieve are:

  • Easy to use: by preferring code over configuration, gulp keeps simple things simple and makes complex tasks manageable.
  • Efficient: by harnessing the power of node's streams you get fast builds that don't write intermediary files to disk.
  • High Quality: gulp's strict plugin guidelines assure plugins stay simple and work the way you expect.
  • Easy to Learn: with a minimal API surface, you can pick up gulp in no time. Your build works just like you envision it: a series of streaming pipes.

Gulp tries to simplify the writing of tasks using streams and code-over-configuration which can be seen as a "jQuery like" approach for chaining actions and creating build tasks. Streams have been around since the earliest days of UNIX and are a very important part of Node.js ecosystem, so writing in gulp can be seen as writing in Node.js. While making use of streams, gulp gets rid of intermediary files and only the final output is written to disk which makes the whole process faster. By preferring code-over-configuration, gulp keeps simple things simple and makes complex tasks manageable.

Just as any task-runner, every task can be a simple unit-of-work:

var gulp = require('gulp');
var uglify = require('gulp-uglify');

gulp.task('scripts', function() {  
   return gulp
      .src(['src/js/**/*.js'])
      .pipe(uglify())
      .pipe(gulp.dest('build/js'));    
});

Or have dependencies from other tasks:

gulp.task('default-task', function(){
   gulp.run('scripts');
   // watch files and run scripts if they change
   gulp.watch("./src/**/*.js", function(event {
      gulp.run('scripts');
   });
);

Besides being more verbose, other complaints about Grunt refers to the fact that a lot of plugins do more than they should. On a blog post, Mark Goodyear shows the example of Grunt’s imagemin, which not only compress images but also uses caching. According to him, with gulp the cache is an extra plugin that can be used by other plugins and this promotes reusability.

Checking gulp’s code repository activity and the number of stargazers on github, one can see this build system is starting to gain momentum. It also has already received a lot of interest from the JavaScript community: Addy Osmani, lead developer at Yeoman, opened an issued for the Yeoman team to review gulp as a replacer for the current build system. Sindre Sorhus, part of the Yeoman team and leading NPM contributor, wrote a blog post about gulp and as referred to it on Twitter as “Think Grunt, but faster and less config”.

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2014 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT