Why do Golang and static file generators can be the future of the web?

People using touch screen interfaces, augmented reality and IOT devices: blockchain of things and networks concept

The days were gone when most of the application was developed on Visual Basic or C++ as a desktop application. Over the period, the web-based application has taken the place of legacy desktop application accessible from anywhere. You can see now how most of the critical desktop application has been changed to the web-based application.

Desktop ApplicationWeb Based Application
Microsoft WordGoogle Docs
Microsoft ExcelGoogle Sheet
Microsoft PowerPointGoogle Slide
Adobe PhotoshopAdobe Creative Cloud

Web 1.0 (1990-2000):

In this period, the internet was the collection of static informational websites. Here the owner of the website adds information-driven webpage on his web space and consumer (visitor) see the information on the site.

  • Website built on HTML, CSS and plain JavaScript.
  • It is required to have the technical skill to run the blog.
  • One-way communication from webmaster to visitor.
  • It is just a read-only web.
  • Products were displayed as a brochure without any add to cart functionality.
  • People were not able to comment or interact.
  • It was the era of static websites.

Web 2.0:( 2000-2010):

Many to many communication came into existence in this period. Now the website has become a platform to share information between users or their group. Developers have started using the ajax where user can now feel the web application as a desktop application.

  • People have control of data for reading and writing.
  • Now, the desktop application is visible as a web platform.
  • The different content type has started appearing such as
    • Audio
    • Video
    • Blog/Diary
    • Calander
    • E-learning
    • Games
    • Presentation
  • Applications such as facebook, youtube, twitter, SlideShare are the example of web 2.0.
  • A platform for information sharing, collaboration and participation as well as the solution for business such as Google Doc, Google Sheet, Google Slide etc.
  • People are now both producer and consumer of information.

Web 3.0 (2010-2020):

Most of the popular web application is now intelligent. Instead of a human, a machine learns and decide what to do with the customer. This way user can get what they are looking in real time while computer tracks and observe user behaviour on the website. If you are running the start-up, to compete with the big giant competitors, You have to implement web 3.0 in your organization.

  • Machine learning is part of web 3.0.
  • A machine can interpret the information of user behaviour data and history and can tailor the page for a specific user.
  • It may be decentralized. It means if one of the data nodes fails, data will be still accessible. Blockchain is an example of a decentralized system. This system is almost impossible to hack.
  • Web 3.0 application/websites can answer complex query such as:
    • I want to see the best action under 50 km range with a nearby restaurant.
    • I am a c++ developer with three years experience which company has such requirement under the 10km range of my current location with my LinkedIn reference.

But wait!!! Why I am talking about this!! This blog post is all about Golang and static file generator.

From Web 2.0 to 3.0, We need to understand the improvement which is required in our digital space.

  • Programming language through which we can create a distributed system: Go Lang is one of the best language for this. It has the best solution for concurrency management makes it suitable for a distributed system.
  • A Programming language for system software: Google has mentioned in his post.

“We’re hoping Go turns out to be a great language for systems programming with support for multi-processing and a fresh and lightweight take on object-oriented design, with some cool features like true closures and reflection. Go attempts to combine the development speed of working in a dynamic language like Python with the performance and safety of a compiled language like C or C++.” — Google

  • Scalable Programming language: Go language has go-routine better than multi-threaded architecture like Java.
  • Different areas where Golang can be best in use:
    • Golang is an excellent choice for a decentralized system such as blockchain.
    • Golang is the right choice for IOT (internet of things) which may be the part of web 4.0. Concurrency is the best feature of Golang which make it suitable for IOT projects.
    • Golang is also useful for robotics. There are many platforms available for Golang. Please check https://gobot.io/
    • You can create a web server in GO.
    • Mobile app development in the GO language is in the experimental phase, and the possibility is there for more support.

PHP VS Golang:

PHP has more than 60% market share in the world so it is important to compare Golang and PHP and understand what is the best choice for new project.

GolangPHP
Back ByGoogleZend
ScalabilityExcellentFair
For IOTVery good
https://gobot.io/
Fair
Decentralized SystemGood
https://golangcrypto.com
Fair
Big Data ManipulationExcellentGood
ConcurrencyExcellent through goroutineNo support
Non Blocking I/OYesNo
Package ManagementGoodNo direct package management
Learning curveMediumNo, since most of people knows it

Hugo:

I am also suggesting Hugo to create a static HTML file. Golang is very resource efficient language, but it still it need some server resource. When you look at the web, you will find that most of the websites don’t require a sophisticated content management system such as WordPress or Joomla. Hugo is the answer to these kinds of resource-related problem. I am going to move my blog from wordpress.com to, which is faster and cheaper. What I may miss could be comment and like features which can be replaced by some third-party services such as facebook comment widget etc.

I would recommend using Hugo static site generator if you are running a simple blog. If you have a complex system, you can go with Golang + Hugo.

Use case: e-commerce Website:

What solution I am giving you will work fine with the catalogue of 5000 product. Hugo can create one URL for one JSON file as data. So for 5000 products, you will have to write 5000 JSON file for Hugo to create a relevant static HTML file.

When you add the product, one JSON file needs to be created for one product. For 5000 product, 5000 JSON file needs to be created. Those JSON files need to be created using Golang. You can use the microservices implementation in Golang. You can use amazon elastic search for product search on the website.

Final Technology Selection:

Elastic search (serverless) + Golang using Microservices (serverless) + Static site generation using Hugo. ( Will be hosted on AWS S3: Serverless)

Why Golang?

Amazon microservices costs depend on memory and time to use. Golang is a very fast compiled language. If we use Golang, Our cost will reduce since it takes less time to execute the code compare to most of the language and less memory too.

JavaScript Approach:

Gatsby is a very popular static site generator and can be comparable to Hugo. Both approaches have their pros and cons, and you can select either based on your type of project:

Why should we choose Hugo over Gatsby?

  • Hugo is much faster than Gatsby to create a static files.
  • Less maintenance since no external library is required.
  • Less dependency on third party-tool.
  • More cost-effective as it has a git-based approach using markdown file as content.

Issues with Hugo over Gatsby:

  • No support for Graphql.
  • It cannot create multiple static pages using one data file.

Why Should we choose Gatsby over Hugo?

  • Integration between nodejs and Gatsby help to create multiple URL using a single source file.
  • Tons of extensions are freely available to speed up the development.
  • Graphql support out of the box.
  • Suited for both API based and git based content management system.
  • You can easily use Drupal or WordPress as backend.

Conclusion:

Now, more and more people are coming online, Server hardware has limit and cost is fixed. For the new website, it is advisable to use serverless approach. Using Gatsby or Hugo as a static site generator and dynamic part can be carried out by Golang using amazon lambda function. Session management can be done using JSON web token (JWT). I am going to transfer my blog from wordpress.com to Hugo static site and will update you. After moving my blog, I will write the blog post to teach you how to do it.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.