Skip to main content

React-Native Apps: With or Without Scala?

Anton Spöck Anton Spöck 4 min read
React-Native Apps: With or Without Scala?

For our product innCart, we needed a mobile app for Android and iOS. Due to our good experiences with React-Native, we decided on this framework. Since our backend service is programmed in Scala, we needed to evaluate whether to use Scala with ScalaJS for programming. This article presents our findings.

React-Native

Facebook’s JavaScript framework “React” is, alongside Angular, one of the most popular and exciting frameworks for web applications currently available in the JavaScript world.

React also offers the option to write mobile apps in JavaScript with “React-Native” – and cross-platform at that! This works so well in practice that numerous companies implement their apps with this technology. Facebook, Instagram, Airbnb, and MieterCast are just some of the more well-known examples. The community around React-Native is also growing strongly. There are now libraries and examples for almost all needs. And if a problem does arise, the React-Native Usergroup in Munich can help.

Actually everything is great – if only there wasn’t JavaScript! With ES6, JavaScript has moved a big step in the right direction, but for larger projects, one desires the advantages of a typed language, which will be discussed in more detail below.

Scala

As an alternative to TypeScript, we took a closer look at Scala. Both languages enable typed development. The TypeScript or Scala source code is transcompiled to JavaScript and is thus interpretable by any browser and, in combination with React-Native, also usable as a smartphone app. As mentioned at the beginning, we’ll leave TypeScript aside and only deal with the question of whether it makes sense for us to use Scala for app development in React-Native or to develop directly in JavaScript instead.

To translate Scala code to JavaScript, the transcompiler Scala.js is required. To use React-Native in Scala, we used the framework SRI (Scala React Interface). The following graphic shows the technology stack with Scala (left) and without Scala (right):

ScalaJS vs JavaScript React-Native Stack

ScalaJS vs JavaScript React-Native Stack

After extensive experimentation with using Scala in combination with React-Native, the following advantages and disadvantages crystallized:

Advantages

Strong Typing

Support for types, classes, and interfaces (or traits) has a particularly positive effect on larger projects in the form of more robust and maintainable software. Furthermore, typing enables better IDE integration, which significantly contributes to development comfort and is a factor not to be underestimated.

Optimized JavaScript Code

The Scala.js compiler optimizes the JavaScript output during translation. This generally results in better performance.

Scala as Language for Backend and Frontend

Especially at innFactory, we increasingly rely on Scala for cloud and server applications. With Scala and React-Native, we could use part of this know-how in frontend development of mobile clients as well.

Disadvantages

Many Dependencies

As the above graphic shows, in addition to React-Native, there are two additional dependencies, Scala and SRI. External libraries that need to be adapted for Scala also add up. A new version of just one component in the stack can cause conflicts with the other dependencies. Finding error sources is only easy when dealing with a lean architecture with few external libraries.

Small Community

Since the technologies have only a few supporters on github so far, discontinuation of support would be a much greater risk. Apart from Scala.js, there is no professional support behind the stack, only very good hobby projects. With SRI in particular, there is great uncertainty here, as there are only a few developers.

Required Knowledge in Both Technologies (Scala and React-Native)

Good Scala developers are hard to find. For React, there are somewhat more. But finding programmers who master both technologies is almost impossible.

While the onboarding time for a JavaScript developer in React-Native is only a few days to weeks, it increases to several months when combined with Scala. For Scala programmers, the time to build up know-how is not quite as long, but even here, the concepts of React, such as the Redux architecture, must first be internalized.

Conclusion

For us, Scala has a firm place when it comes to backend and cloud development. The idea of generating JavaScript with Scala is very exciting. But for the upcoming project, the disadvantages clearly outweigh in our case. The technology stack is unfortunately still too shaky. Expanding the development team could also prove extremely difficult. The latter point alone would be sufficient as a knockout criterion for us.

We think the Scala.js project is moving in the right direction and will watch it very closely. For our product development, however, we will rely on pure React-Native for the app and use Scala as the primary technology in the backend.

Anton Spöck
Written by Anton Spöck CTO

Leitet das Entwicklerteam und verantwortet die technische Qualitätssicherung nach ISO 9001.

LinkedIn