Procats

This is follow up code to the «a conversation about Go» talk in a meetup organized by Front End Coders Mauritius, where Gophers.mu was announced.

GoLang is a terrific language; with great emphasis on simplicity and practical applications. However it is often difficult to appraise its value without understanding the problems it is able to fix.

I have implemented a very simple website to highlight the differences between PHP, NodeJS and Go. Many comments are included in the code. I hope it is a fun read.

Notes: I have kept all code in 1 single file, and deliberately so, for simplicity. This may change in the future.

The project is on Github: https://github.com/fluxynet/procats

Scenario

A simple website with 2 pages:

Implementations

PHP

The PHP stack was the hardest to set up. This complexity is usually hidden from developers and moved to system administration team. I have included the Dockerfiles with instructions how to build the server, so that developers can understand how an actual server is built - time to grow up from XAMP, MAMP, WAMP…etc.

The PHP syntax can be very pleasant when PSR is respected, assuming you have a powerful IDE. The best PHP IDE is neither free nor light. Imagine working on 2 websites with 2 browsers. The load can easily add up. As for the older part of the language, it feels more like a C/Unix wrapper - e.g. the curl code.

PHP as a templating language is a joy to use - but it cannot do multi-threading; at least not easily. Both these features come as no surprise from a language originally designed to be a templating language to C/C++ programs.

NodeJS

Getting started with nodejs is super easy. No doubt it would have been easier if I were able to use axios and express because the core library itself is limited. Moreover the asynchronous paradigm is heavily embedded in the language. For example, we have fs.ReadFile and fs.ReadFileSync rather than fs.ReadFile and fs.ReadFileAsync; the norm is asynchronous.

There are many ways of writing the same thing - e.g. defining a function; such that the code can become unreadable for less experienced programmers, whereas it is those very less experienced programmers who may have to take on maintenance of the codebase as the latter ages.

Go

The language is very verbose and looks simplistic; however its apparent, and well intended, simplicity belies its true power. While there are new concepts, like defer function() and go function(), the code itself is straight-forward to understand.

Go comes with a code formatter and is easy to debug using simply vscode with the go extension installed. This is a highly underrated feature whose value can only be understood in absentia.

Check the code on github: https://github.com/fluxynet/procats - it is well commented. Let me know how you feel about it ツ

//TODO Add more application scenarii and 1-2 programming languages.