Huseyn Gasimov
Huseyn Gasimov
Creator of this blog.
Dec 23, 2017 5 min read

Shiny for large scale web development

thumbnail for this post

R is a very powerful programming language for data analytics and has a lot of useful packages. Shiny framework enables R developers to build web based data analytics reports and tools. I personally find Shiny as a perfect framework for developing small web applications. But is it a good idea to develop a large scale web application (for example, BlurAdmin) with Shiny? I will give my opinion about this in this blog post.

Advantages of Shiny

Main advantages of using Shiny are:

  • Access to the powerful R packages to do data analytics and create nice visualisation. R has a lot of amazing packages. Since Shiny is built on R, it can readily make a use of those packages. One should admit that Shiny might not be a reasonable choice for developing web applications which are not going to utilize the functionalities, which are provided by R and its packages. For example, I wouldn’t choose R and Shiny for a general purpose web development (personal or news website, blogs, e-commerce, etc).
  • Seamless interaction between server and UI (User Interface). This is what it makes Shiny so attractive to the people who has little or no web development experience, like most of data scientists and statisticians. Using only one programming language, R, and never caring about REST web services and Ajax calls, one can build a simple web application in an hour. This fact can blow any full-stack web developer’s mind.
  • Ready to use html templates (for example, shinydashboard and AdminLTE). Shinydashboard has helped me a lot so far to develop good looking web applications in short time. Though, unfortunately, there are not so many templates like shinydashboard so far. That’s why, if you look at the web applications, which were developed in Shiny, most of them look like one another.

Costs of high level programming framework

As one would expect, having so high level programming framework comes with its costs.

  • Can not easily interact with JavaScript. Developing a big web application only in Shiny without writing any Javascript code, from my experience, is often not possible. There doesn’t exist a R package for every little thing that you would like to do in your web application. Hence we need some help from Javascript – native language of web UI development. The problem is that UI of a Shiny application is written in R and integration with Javascript is not intuitive and can get fairly complex. One can use shinyjs to perform some common Javascript operations (enable/disable, show/hide an element) and execute own Javascript function from R. But it will make you hassle before it works properly. How about calling R functions from Javascript? One can do it using openCPU, though, as you’ve already guessed, it will not be easy. Yes, having 2 different programming languages talk to each other smoothly sounds far from reality.
  • Reactive programming might not be easy to understand and implement. R programmers all witnessed the steep learning curve of R language. Learning reactive programming for Shiny app development is the same type of experience. Reactive programming usually helps one avoid duplicate calculations but it’s difficult to learn and cumbersome to implement. It just sometimes is not what you want.
  • Some part of the UI is in Javascript, some part is in R. This will be your next problem after you’ve found a way to use Javascript in your Shiny app. Code readability and maintainability is very important aspect of large scale software development. If the user interface of your web application was developed in two different languages, it automatically makes your code less readable and less maintainable. It, in turn, will increase software development time and open a door to more bugs.
  • No web service. Shiny handles all client-server interactions for you. Hence you don’t have to write REST web services yourself. I have listed this as an advantage of Shiny. However, in large scale software projects, you might also need to develop a mobile application for your software platform. For example, you would like to have a mobile app to view your data analytics reports. In this case, you will probably need to have a web service to serve your data to the mobile app. Therefore you’ll eventually have to develop a web service.

More points to discuss

  • UI rooting and deep links. Sometimes it’s nice to have separate URLs for each page in your web application. It’s especially vital if you want your web pages to be listed in web search results. Or maybe you want to give a direct link of one of the pages in your web app to your customer. Either way, if you want to have page addresses or deep links, you might struggle to implement it in Shiny.
  • One step behind. One often needs help of frameworks and libraries while developing a large scale application. Some of the well-known javascript libraries have already been ported to Shiny so far. For example, shiny semantic, shinyWidgets, d3R, etc. Obviously, Shiny developers get access to these libraries later than Javascript developers. Moreover, as you can guess, not all of the nice javascript and CSS libraries are ported to Shiny.

Summary

I listed main advantages of Shiny framework and what problems you might face when you develop a large scale web application with it. I find Shiny as a perfect framework for developing small data analytics tools. However, it’s not a silver bullet for building all types of web applications.