📜 ⬆️ ⬇️

Objective-C on the web: server side view

This time, the ObjC theme is covered by me on the server side. Unfortunately, the specifics are smaller, more philosophy, but I hope someone will find this essay interesting.

And so, what's the point of trying the Objective-C from the server side, is there any at all, and what advantages does it give.


In terms of speed of operation (hereinafter, measurements are confirmed only by the apache benchmark, and may not reflect the whole essence of things) Objective-C lags behind the fully compiled C ++ code, but bypasses Python (represented by Django) and PHP. Bypasses in the synthetic test ab, where only the rate of return of the uncached material is actually measured, so your mileage may vary .
')
On the other hand, web-oriented languages ​​(PHP) and web frameworks (Django, Ruby on Rails) provide the developer with a wide built-in functionality for solving typical web tasks. With the help of the same Django, you can quickly write code for a web-based system, taking into account slender MVC-logic.

Let's look at this question from the other side of the server environment. If the OS is OSX Server (on hardware or virtualized), then runtime comes into the hands of the developer with many ready-made solutions, as if for desktop, but many of them can be used for server applications. For example, you can use Core Data to store data and ORM access to it, to work with any other processes (for example, a separate comet server, or even a remote OSX or iPhoneOS client) you can use Distributed Objects .

Of course, the cost of using server-side OSX is several orders of magnitude higher than the cost of hosting on Linux. "Cheap and angry" on this platform will reach Cocotron. The degree of API coverage here is less than that of Cocoa, but the general approach is preserved. And third-party libraries will help in the missing places, because ObjC is well linked with C and C ++. Google CTemplate will cope with the output of the final result, data access will be through SQLite Persistent Objects , or direct link to mysql / pgsql. All the delights of dynamic runtime remain.

Some time ago I tried to make a basic web framework for solving typical tasks on Objective-C. Much time has passed since I wrote the first line of code in this direction, and it is already possible to draw any conclusions.

Writing simple web systems on ObjC is expensive (in terms of the time spent by the developer). A noticeable gain is achieved only in the speed of work and consumed by the OP (for example, on OpenVZ several django processes and mysql can eat everything together, tugging OOM for nothing).

Interesting results are obtained when writing common systems for the iPhone and the web . Then the reuse of the code increases, you can greatly save on data transfer and synchronization tasks (for example, the web system and the iPhone application paired to it). Of course, you can make a web application for the iPhone, with the use of new buns from HTML5, but a full-fledged program has an advantage in the simplicity of development-debugging and in a functional API.

Even more interesting results - when using ObjC on the server and the rich Cappuccino application on the client . The advantages are almost the same, only the code needs to be brushed a little under the objj-view (which cpp does well with c preprocessor and a few # define). You can store the same object model on the server and the web client (as well as, potentially, on desktop clients).

Sometime ChromeOS will be the only one used, all data will be in the cloud. In the meantime, many desktop applications are more convenient and functional than web analogs, and some tasks are easier to transfer from the web interface to the desktop. For example, several IPB forums are easier to moderate through the native OSX client, which can quickly view the necessary branches, do auto-moderation on keywords, and will economically consume OPs. Tidy, libxml and libxslt are all represented in Cocoa, and allow you to write customized desktop versions of sites with minimal cost. And the use of common logic for the server and client in many cases is convenient, which can justify the use of Objective-C from the server side.

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


All Articles