Can you Grunt something better?

Written by: Matic
Published on: 15.9.2016

As we said in one of our previous blog posts, Grunt and Gulp get, accidentally or not, mixed up very often. The confusion is therefore present on more occasions that we would have liked or cared to admit. To avoid any misconceptions we promised that we will present you the differences between the two. And our promise lies here, in front of you.

As both are built scripts, some like to call it a battle of Built Scripts. Both automate our tasks, both use Node and they both require you to create tasks and install plugins of some sort. But what are the differences? Which one is better? Which one is friendlier to the user? Which one is faster? And after all, which one will satisfy you the most?

Battling all the way down


Grunt against Gulp


The main difference between the two is that in contrast to Grunt, Gulp relies on coding over configuration, with the goal of making things simpler as the configuration gets more complex. As a result, Gulp code usually looks cleaner and it is easier to read, which really helps, when configuration gets confusing. Gulp also makes it extremely easy to fit other code within a task definition, besides streaming from one plugin to another. However, everything at the beginning can be confusing and will get more understandable through practice and time, so it is actually up to the user to decide, on which side he or she thinks more closely.

Gulp has cleaner API. With it tasks might run in parallel compared to Grunt, where tasks run sequentially. For similar tasks, Gulp is faster than Grunt. Before 0.5 version of Grunt (not the latest version) came out, a speed comparison showed that most tasks were at least twice as fast on Gulp. This is due to the fact that in Gulp tasks are stored in memory without the need of temporary files or folders. On the other hand Grunt tasks are stored in a temporary folder, which means more configuration and more on I/O (intermediary files are disk I/O operations). So, compared to in-memory operations, disk writes are slow, which means that Gulp, despite all the improvements from Grunt, still has a speed advantage, although it decreased rapidly in recent years. Nevertheless, speed does not really matter, when it comes to small projects. Even when you deal with bigger ones, differences are measured in seconds.

Many web designers and other users of both build scripts like to point out that both communities are nice and friendly. Grunt has a larger community than Gulp, with a lot more plugins available for it, although Gulp is catching up fast. That is understandable, knowing that Grunt has been here for a longer period of time. Some even think that on a long run Gulp will have even more user base than Grunt, because according to Google Trends searches for Gulp related things increased rapidly over a past year in contrast to Grunt's searches, who fell drastically. But to be fair we never know, what the future holds (for us). Maybe we should even consider stop using them both.