⬆️ ⬇️

Development of cross-platform mobile applications in Delphi # 1

Delphi for Android As 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 lead the development of native Android applications - the most popular mobile platform at the moment.



Previous versions of Delphi have already supported development for Mac OS (XE2, XE3, XE4) and for iOS (XE4). So now we are not saying that cross-platform development has become the "highlight" of the new version of Delphi. However, in relation to application developers, Android is a truly democratic system. It does not require expensive equipment (as in the case of iOS), nor 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).



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

')

Speaking of Delphi , we should also mention C ++ Builder . Usually both of these products develop in parallel. However, this time Delphi, to put it in a sporting language, “took the lead a little” and C ++ Builder users have to wait for a while until their development tool “pulls themselves towards the leader”.



Many Delphi developers with experience associate Delphi with VCL, a powerful extensible class library designed to create the widest range of applications for Windows. However, as you know, or managed to guess, to create cross-platform applications, not the VCL 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 it, you can create high-quality user interfaces for virtually any kind of program. At the same time, among other things, “in a box” also supplies objects for working with 3D graphics, which allows FM to be used to solve a number of specific tasks, such as modeling physical processes, creating visual teaching aids, etc. Many of the components presented in FM have their VCL counterparts. However, not all.



Unlike VCL, FM is an “abstract” application platform. Previously, visual class libraries processed the corresponding elements of the operating system. In the VCL, for example, the TButton component is a wrapper for the 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 to different platforms, or to use a fully customizable user interface style.



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



Another point to be touched is the term “cross-platform” in the context of mobile applications. It is clear that mobile platforms use a specific set of controls for organizing 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 abstraction of the interface described above in many cases solves the problem. However, not always. And, speaking of cross-platform applications, we do not mean a single application for different platforms. We are talking about a single code base in different applications. And here it becomes very important to correctly build the architecture of the application, namely, the maximum separation of the interface and logical parts.



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



image For the development of mobile applications (for iOS and Android ) Delphi uses the so-called modular compiler LLVM . In the context of cross-platform development, this gives a distinct advantage. The modular compiler is divided into two parts: the front-end and the 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 into 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, we should also mention database access mechanisms. Indeed, working with the database has always been a strong point of Delphi, and it would be logical to expect that mobile Delphi applications will work with databases as well as desktop ones.



More recently, in the spring of this year, the Delphi / RAD Studio package of older editions has been updated with a new data access library, FireDAC, based on the well-known AnyDAC solution, developed and developed by Dmitry Arefyev for a long time. FireDAC is 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 technology DataSnap. This technology is not new and has proven itself quite well among developers.



And, since we have already touched upon the topic of working with databases, we should mention one of the key differences between FM and VCL applications. To display the data in the VCL, special controls are commonly used, the so-called DB controls. For FM, such controls are not implemented and ordinary controls are used to display data. Communication between data and controls is done using the Live Binding mechanism. And 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 “classic”. And now there is some lack of technical information about mobile development in Delphi



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



This article opens the cycle 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 deal with the main technical issues that may cause complexity.



In the next part we will move from words to deeds. An absolutely realistic 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

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



All Articles