Development of cross-platform mobile applications in Delphi # 1

    Delphi for AndroidAs you probably know, in September of this year, Embarcadero Technologies introduced the next release of RAD Studio , a set of development tools including Delphi , C ++ Builder , HTML5 Builder and a number of related products. The main innovation of RAD Studio XE5 is that with the help of Delphi it has become possible to develop native applications for Android - the most popular mobile platform at the moment.

    Previous versions of Delphi already supported development for Mac OS (XE2, XE3, XE4) and for iOS(XE4). Therefore, now we are not talking about the fact that cross-platform development has become the "highlight" of the new version of Delphi. However, with respect to application developers, Android is a truly democratic system. It does not require expensive equipment (as is the case with iOS) or the purchase of developer certificates (the ability to publish applications on GooglePlay costs only $ 25, the ability to debug on your Android device is absolutely free).

    Thus, if you have some skills in Delphi , then right now you have a great opportunity to try yourself in mobile development.

    Speaking about Delphi , we should mention C ++ Builder. Typically, both of these products develop in parallel. However, this time Delphi, in sports language, “got ahead a bit” and C ++ Builder users have to wait for a while until their development tool “pulls itself towards the leader”.

    Many experienced Delphi developers associate Delphi with VCL, a powerful, extensible library of classes designed to create a wide range of Windows applications. However, as you know, or managed to guess, to create cross-platform applications, it is not VCL that is used, but the FM application platform, formerly known as FireMonkey .

    From the point of view of IDE FM, this is, first of all, a new library of visual classes (controls). With its help, you can create high-quality user interfaces for almost any kind of program. Moreover, among other things, objects for working with 3D graphics are also delivered “in the box,” which allows you to use FM to solve a number of specific tasks, such as modeling physical processes, creating visual training aids, etc. Many of the components presented in FM have their own VCL counterparts. However, far from all.

    Unlike VCL, FM is an "abstract" application platform. Previously, visual class libraries processed the corresponding elements of the operating system. In VCL, for example, the TButton component is the shell of a Windows Button control (button). Instead, FireMonkey introduced the abstract concept of a button to which different styles can be applied to make it look native across different platforms, or to use a fully customizable user interface style.

    While other libraries abstract away the user interface, FM is tied directly to the native graphics library, offering the best solution in terms of using the GPU on the target platform.

    Another point that should be mentioned is the term “cross-platform” in the context of mobile applications. It is clear that mobile platforms use a specific set of controls to organize the user interface. And for this reason, the principles of building classic desktop applications in most cases are not applicable in mobile development.

    Of course, the principle of abstracting the interface described above in many cases solves the problem. However, far from always. And, speaking of a cross-platform application, we do not mean a single application for various platforms. We are talking about a single code base in different applications. And here, the correct construction of the application architecture, namely, the maximum separation of the interface and logical parts, becomes very important.

    To date, the FM platform supports the following operating systems: Windows ( Win32 and Win64 ), OSX , iOS and Android .

    imageTo develop mobile applications (for iOS and Android ), Delphi uses the so-called LLVM modular compiler. In the context of cross-platform development, this gives an undeniable advantage. The modular compiler is divided into two parts: front-end and back-end. The front-end compiler translates the source code of a specific program into a universal platform-independent virtual code (byte code). The back-end processes the received bytecode and converts it directly to the machine code of a specific platform. Back-end LLVM supports a number of different platforms, which in the future will enable RAD Studio to expand the list of supported platforms.

    In the context of developing business applications, database access mechanisms should also be mentioned. Indeed, working with databases has always been Delphi's strong point, and it would be logical to expect mobile Delphi applications to work with databases as well as desktop ones.

    More recently, in the spring of this year, the delivery package for senior editions of Delphi / RAD Studio was replenished with a new data access library - FireDAC, created on the basis of the well-known AnyDAC solution, created and developed by Dmitry Arefiev for a long time. Firedacis a universal set of components that supports access to a very impressive list of DBMSs. And if we are talking about desktop applications, then the FM platform using FireDAC supports almost all popular DBMSs. As for mobile applications, there are certain limitations associated primarily with the lack of access libraries to most DBMSs. So mobile Delphi applications will support SQLite (native DBMS for both iOS and Android) and IBLite / IB ToGo . But to connect directly, for example, to Oracle is no longer possible.
    Firedac
    However, it is possible to create mobile clients using the multi-tier DataSnap technology. This technology is not new and has proven itself pretty well among developers.

    And, since we touched on the topic of working with databases, we should mention one of the key differences between FM and VCL applications. To display data in VCL, special controls, the so-called DB controls, are usually used. For FM, such controls are not implemented and conventional controls are used to display data. Communication between data and controls is made using the Live Binding mechanism . Although Live Binding is intuitive, easy to learn and fully visualized, working with this technology still requires some skills.
    image

    From the foregoing, it follows that mobile development in Delphi is quite significantly different from the "classic" one. And now there is a shortage of technical information devoted specifically to mobile development in Delphi.

    Although this situation, in principle, is characteristic of any rapidly developing technology.

    This article opens a series of publications devoted to the creation of mobile applications in Delphi . We hope that this cycle will help you not only to get acquainted with the capabilities of the new development environment, but also to understand the basic technical issues that can cause complexity.

    In the next part, we will move from words to deeds. An absolutely real task will be chosen for consideration, and we will try to step by step consider the process of creating FM applications for different platforms.

    Part # 2
    Part # 3

    Also popular now: