📜 ⬆️ ⬇️

One application for three platforms



We are now very pleased with the internal device of the Aword application: it is easy to maintain, develop and test, and the deployment of new versions occurs simultaneously on all platforms. But it was not always so. Today we will talk about how we followed the path of universalization, stepping on a rake and gaining experience.

In the beginning was the word


Initially, our mobile application was conceived as a simple auxiliary tool for students of the school. Most lessons contain a set of vocabulary to learn, and both the student and the teacher can add words directly during the lesson, and all this is supposed to be learned to the next class. It is clear that doing it on the phone or tablet is convenient. Thus, the first version of the iOS application appeared, accessible to our students, containing only four simple learning mechanics (dictionary card, “I remember, I don’t remember” and two checks with the choice of the correct answer from four options). There were no “smart” algorithms there, there was a simple cramming, and the program decided that the word was learned when the student had chosen the translation correctly a certain number of times. Later, the same application was written from scratch for Android.

We looked at our application, looked at the feedback from students, and saw that it was good. That this business should be brought outside the school and offered to third-party users. But not in the form of a primitive tool for memorizing, but in the form of a smart, effective, adaptable application . Which should not only be written again from scratch, but also thoroughly tested at the level of algorithms.
')
For testing, we wrote a new web application in PHP, because it is easier, and testers do not need beautiful interfaces. Hone algorithms, optimized recruitment mechanic. And they saw that it was good too.

But here's the idea to write from scratch two more versions of the application (for iOS and Android), and then support and develop all three in parallel, we didn’t like at all. Therefore, it was decided to issue the kernel as a C ++ library, which is the same for all versions of the application, and continue working with it.

Therefore, we, in fact, once again rewrote everything from scratch. But one and hopefully the last time.

One library


Why C ++? Because C ++ is a cross-platform language, it compiles perfectly for iOS, is well supported on Android, and can be used with PHP on the web by compiling C ++ code in a PHP extension. Other languages ​​can not boast such support. For example, if you selected Java, it would be easier to make an application for Android, but for porting to iOS, you would have to use unpopular tools (jvm like RoboVM), but it would have worked much worse. Plus, more complex than with C ++, Java integration with PHP.

As a result, we got the following picture: interfaces (client programs) written separately for each platform in their native languages ​​(Objective C, Java and PHP backend) address the common for all versions of the application core (C ++ library) that performs the main work . The application also has a connection with the server (authorization, storage of shared resources, a catalog of static sets, a dictionary, a potential connection with third-party applications) and a local data storage ( Realm ).

Thus, porting to iOS turned out to be the simplest and most trivial task due to good compatibility between Objective C and C ++. Everything is built in without problems, it works very quickly, it is a convenient platform for debugging new functionality.

With Android, the situation is slightly worse, because there you have to interact with the Java virtual machine, which affects the speed of work: the data transfer speed between the library and the application is low. But for our needs it is not critical.

For the web version, the PHP-CPP framework is used. The choice was due to convenience, the presence of more or less complete documentation and support for C ++, and not C. The disadvantages include problems with debugging: watching the logs is not the most convenient way, and the official site does not offer others.

By deducing the working functions of the application into a single library for all versions, we got rid of the need to write, test, and maintain three separate branches of development, as well as the inevitable problems associated with it. All engine updates are made in one place, tested and become available simultaneously to all users, regardless of platform.

And we see that it is good!

You can see how it works by downloading the Aword mobile app for iOS or for Android . The web version will be available later.

We remind you that we still have a lot of good and interesting work for talented specialists.

Source: https://habr.com/ru/post/314662/


All Articles