Choosing JavaScript Technologies in 2017
The past
I come from a classic Java background with Struts 1, Struts 2, some experience in JSF and a couple of projects with Google Web Toolkit.
In 2014 I shifted to Angular 1, used it in my own projects and introduced the technology to teams I am coaching. It was a very good choice at the time.
- very fast reloading
- nice GUI components
- it is a full stack and included everything you needed to build a GUI
It carries a couple of tradeoffs.
There are many options for build environments like grunt, gulp, bower, brunch. We needed to learn a lot about those.
Testing is not trivial, depending on what you test controller, directives, filters, services you stumbled upon different problems.
Custom components are quite complex.
But as a summary, it it a good technology and once you learned the tradeoffs, you could work with it.
Choosing something new
In 2017 I needed to answer the question if we stay with Angular or pick something new. The natural candidate was Angular 2.
I explored Angular 2 alias 4. It provides a lot of improvements, learned from ReactJS when it comes
to performance. Components are a core concept and easy to implemenent.
The tradeoffs I found are non trivial error messages if something breaks, verbose code and testing was not trivial.
A couple of times the error messages when something breaks are hard to track down to the cause. Angular and on another dimension TypeScript causes complex problems requiring experience to understand a problem.
TypeScript brings types to JavaScript. Typed and untyped languages have both very strong advantages over each other. It is about type safety versus verboseness. You can see and validate your types across your code or you have 3 times less code to understand.
In my humble opinion, if the code can be split into small independent modules then types harm more as they help. In the context of JavaScript GUI, I feel that types are not helpfull.
But pick your poison. This is all about preferences. At least, we can hopefully agree that typed code is more verbose.
In addition I evaluated testing. In that area I was a slightly disappointed because complexity is still very high. I am not sure if this is caused by Angular being a full stack solution providing injection and
solution for as well.
In addition to not being perfectly happy with my exploration, a team member challenged the idea to switch to Angular. So we started to evaluate major players in the JavaScript world: ReactJS, Angular 4 and VueJS.
Evaluating ReactJS, Angular 4, VueJS
The approach choosen was to identify a handful of usage scenarios like forms, validation, tests, integration with GUI components like Bootstrap and building custom components. Those scenarios are mostly driven
from the projects we are working on.
Then we worked with the frameworks as much as possible and tried out the scenarios.
None of the frameworks failed in our tests. Each of them had its tradeoffs and a first setup could easily be achieved with the provided cli tools.
Angular 4
- Good support for components
- Typed JavaScript as default
- Slower reload time after code changes (probably caused by TypeScript compilation)
- Error messages sometimes difficult
- Provides injection
ReactJS
- Setup was a charm
- Inline templates as default, which are not as well supported in IDEs
- Cleaner structure compared to Angular but more complex compared to VueJS
- Fast reloading after code changes
- Long term player
VueJS
- Clean structure in components but they easily become quite long
- Good testing support with vue-test-utils
- Less complexity
- You need to explore solutions for Ajax requests, testing libs etc.
- Fast reloading after code changes
- Very new and libraries for testing, Bootstrap integration were still beta when we started
- Easy to test
We ended up choosing VueJS as we valuated simplicity higher than the at the time still heavily changing related libraries. But I believe that a different team with different experience would have come easily to different conclusions.
Best Regards / Viele Grüße
Sebastian Hennebrueder