Products

Solutions

Resources

Partners

Community

About

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

The Community Blog is a personal opinion of community members and by no means the official standpoint of DNN Corp or DNN Platform. This is a place to express personal thoughts about DNNPlatform, the community and its ecosystem. Do you have useful information that you would like to share with the DNN Community in a featured article or blog? If so, please contact .

The use of the Community Blog is covered by our Community Blog Guidelines - please read before commenting or posting.


3 Reasons why We're Moving from Grunt to Gulp

We've been working with JS-Automation for about a year now, specializing more and more on Grunt. But the more we relied on it, the more we had to go out of our way to get around problems inherent to Grunt. With Gulp, this changed. 

Just to be clear: we started out with Grunt because we believed that it's better to use a stable, proven system than to risk jumping onto the newest fad. And a year ago, where were also much more plugins in Grunt than in Gulp. And we can testify that everything we needed to do could be done in Grunt, and we were very grateful for that. I even wrote some blogs about grunting. But IRL (in real life) we kept on running into issues which hurt our productivity and introduced unnecessary chaos and risks. Because of this, we are now continuously moving all our automation to Gulp. Not in one big gulp, but sip-by-sip (yes, the word-play is also better with gulp :)).

Reason 1 - it's about 100x - 1'000x faster IRL

Now these are in-real-life numbers, and it surprised me as well. The reason is fairly complicated and certain factors make it worse. So a job that took Grunt 5-20 seconds was completed within milliseconds. This means a lot when you're trying and tweaking some values. With Gulp, we can now save the original file (like making a change in a CSS) and by the time we were able to Alt-Tab-Switch to the browser, everything in the background had already completed. With Grunt we were always forced to wait for the logger to show completion, which breaks the flow you're in. The core issues are:

Speed on each File Change: 100-1000 times faster

When using grunt/gulp, you will often have a watcher-task which monitors file changes. When using grunt, every file-change will trigger a new grunt-task, which will then load thousands of tiny JavaScript files into memory to start running the program. This happens on each file change and is already fairly slow when everything is on your PC. On a complex grunt-job with files on the network, this can easily take 10 seconds. Every time. Gulp is much better at this - it only loads the program once, and re-uses it on file-changes. In our case this gave us a factor of about 100 on local dev-projects, and factor of about 1'000 on local network projects.

Reason 2 - Grunt-Configuration becomes unmanageable IRL

Again an in-real-life experience which surprised us. Basically Grunt rules are configured in a JSON-style syntax, and then you define commands (called tasks) which run the automation on this configuration bit. This seems simple and straightforward but results in chaos in large systems. Here's why:

Take for example the configuration of a copy-job, something that you need a lot in Grunt, because each step in grunt starts with files lying in a folder. So you often have to copy some files to another temp-folder, to then do further processing. Now imagine that you have various automations, each needing a different copy-task. Here's the tree of configurations in Grunt just for various copy-actions (without the actual configuration):

  • copy (this is the root configuration node for copying
    • mainPart (a sub-configuration for some actions)
    • mainPartDist (another sub-configuration)
    • import-languages (another sub-config)
    • import-icons (another sub-config)
    • publish-dist (another sub-config)

This is all fairly clear. Now in a real grunt-job you will have to list which steps to perform, like

  1. Copy files from src to tmp
  2. Generate some more files from other file into the same tmp (from SCSS, Typescript, HTML-files, etc.)
  3. Do some checking
  4. Copy something again
  5. Merge / rename
  6. Compress
  7. Etc.

So you'll have many such processes, each of them should only use certain parts of the copy-job at the right time. And it's easy to accidentally use the whole copy-job (which causes loads of issues and takes long) or to confuse certain parts because the entire grunt-file gets so long, that you start making mistakes. There are also cases where one configuration can overwrite the other, causing really nasty surprises. In our EAV-UI project which is a foundation of 2sxc, we ended up with about 1'000 lines of grunt code and every change we had to make was scary.

Reason 3 - Low-CPU File-Watchers on the Network

As we noted in the speed-issue, these task-engines need to continuously monitor file-changes to then start a process once the file has changed. Gulp has a built-in watcher called gulp.watch(…), which works very, very well over the network. It does exactly what you expect.

Not so with grunt. Watching is a plugin, and the ones we were able to use somehow were not able to really hook into the windows-file-change-API. This meant that the grunt-watchers we used, ended up performing the watch manually by continuously checking each file. This just burned the CPU of the dev-machine, causing a normal load of 30-80% just because it was watching the files. In addition, the change-recognition time was of course much worse than with gulp.

tl;dr

These are just three reasons why we're making the move. In general I can say that if you've figured out the concept of JavaScript task runners, you'll feel fairly comfortable with either one; and as your needs get more advanced, you'll feel more comfortable with Gulp. Since Gulp has been so popular for a while now, there are enough plugins now for every need. And if you do run into a need for which there is no gulp-plugin, there is always gulp-grunt, a bridge component which lets you run grunt-tasks from inside gulp. Or you can use both Gulp and Grunt side-by-side. So have fun :)

 

Love from Switzerland,
iJungleboy


Daniel Mettler grew up in the jungles of Indonesia and is founder and CEO of 2sic internet solutions in Switzerland and Liechtenstein, an 20-head web specialist with over 800 DNN projects since 1999. He is also chief architect of 2sxc (see forge), an open source module for creating attractive content and DNN Apps.



Read more posts by Daniel Mettler

Comments

There are currently no comments, be the first to post one.

Comment Form

Only registered users may post comments.

NewsArchives


Aderson Oliveira (22)
Alec Whittington (11)
Alessandra Daniels (3)
Alex Shirley (10)
Andrew Hoefling (3)
Andrew Nurse (30)
Andy Tryba (1)
Anthony Glenwright (5)
Antonio Chagoury (28)
Ash Prasad (37)
Ben Schmidt (1)
Benjamin Hermann (25)
Benoit Sarton (9)
Beth Firebaugh (12)
Bill Walker (36)
Bob Kruger (5)
Bogdan Litescu (1)
Brian Dukes (2)
Brice Snow (1)
Bruce Chapman (20)
Bryan Andrews (1)
cathal connolly (55)
Charles Nurse (163)
Chris Hammond (213)
Chris Paterra (55)
Clint Patterson (108)
Cuong Dang (21)
Daniel Bartholomew (2)
Daniel Mettler (181)
Daniel Valadas (48)
Dave Buckner (2)
David Poindexter (12)
David Rodriguez (3)
Dennis Shiao (1)
Doug Howell (11)
Erik van Ballegoij (30)
Ernst Peter Tamminga (80)
Francisco Perez Andres (17)
Geoff Barlow (12)
George Alatrash (12)
Gifford Watkins (3)
Gilles Le Pigocher (3)
Ian Robinson (7)
Israel Martinez (17)
Jan Blomquist (2)
Jan Jonas (3)
Jaspreet Bhatia (1)
Jenni Merrifield (6)
Joe Brinkman (274)
John Mitchell (1)
Jon Henning (14)
Jonathan Sheely (4)
Jordan Coopersmith (1)
Joseph Craig (2)
Kan Ma (1)
Keivan Beigi (3)
Kelly Ford (4)
Ken Grierson (10)
Kevin Schreiner (6)
Leigh Pointer (31)
Lorraine Young (60)
Malik Khan (1)
Matt Rutledge (2)
Matthias Schlomann (16)
Mauricio Márquez (5)
Michael Doxsey (7)
Michael Tobisch (3)
Michael Washington (202)
Miguel Gatmaytan (3)
Mike Horton (19)
Mitchel Sellers (40)
Nathan Rover (3)
Navin V Nagiah (14)
Néstor Sánchez (31)
Nik Kalyani (14)
Oliver Hine (1)
Patricio F. Salinas (1)
Patrick Ryan (1)
Peter Donker (54)
Philip Beadle (135)
Philipp Becker (4)
Richard Dumas (22)
Robert J Collins (5)
Roger Selwyn (8)
Ruben Lopez (1)
Ryan Martinez (1)
Sacha Trauwaen (1)
Salar Golestanian (4)
Sanjay Mehrotra (9)
Scott McCulloch (1)
Scott Schlesier (11)
Scott Wilkinson (3)
Scott Willhite (97)
Sebastian Leupold (80)
Shaun Walker (237)
Shawn Mehaffie (17)
Stefan Cullmann (12)
Stefan Kamphuis (12)
Steve Fabian (31)
Steven Fisher (1)
Tony Henrich (3)
Torsten Weggen (3)
Tycho de Waard (4)
Vicenç Masanas (27)
Vincent Nguyen (3)
Vitaly Kozadayev (6)
Will Morgenweck (40)
Will Strohl (180)
William Severance (5)
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out