Claudiu Persoiu

Blog-ul lui Claudiu Persoiu

Archive for 24 December 2013

Appcelerator Titanium – few impressions

without comments

Note: Titanium and PhoneGap are a couple of platforms for developing hybrid applications for mobile. These platforms are not written in the programming language that is native to the phone, but they can be distributed on a verity of mobile platforms.

Recently I’ve published on Github the newest and most extraordinary quizzing platform, named Just-Quizzing. I’ve build it for personal use, but because a few colleagues found it useful, I made it public.

In the initial version, for publishing the application to my Android phone, I used SL4A. I needed a way to use the application when I was on the move and didn’t have Internet access. Unfortunately it didn’t have automatic update for the quizzes. I’ve hoped that with time SL4A will have a clearer path, but the platform lost its initial momentum and I decided to write a mobile app.

I had to choose between PhoneGap and Titanium. In the past I’ve used PhoneGap because the app size was too big in Titanium, but I wanted to give it another go. In 2011, when I first wrote about Titanium, the initial app size was about 4M. Today it doesn’t seem that big, even though it isn’t small.

The perspective will be mostly about Android, even though the app was built to work also on iPhone.

I used SDK 3.1.3, without the Alloy framework.

Alloy has it’s own learning curb and I wanted to avoid it. The prupose of the application was to be a portable version for the quizzes from the server and I didn’t want to make a big time investment.

The total development time was a little more than a week.

First impression

Things don’t work as you expect them to, there isn’t a lot of flexibility. From the total allocated time, more then a quarter I was trying to do a “flyout menu”, like in applications such as: Facebook, Google Plus and Youtube. It was a total disaster! The only options that seemed to work were using an external module or using Alloy widgets.

It seems like when converting relative coordinates, where the user touched the current element, to the general coordinates on the screen there is a big discrepancy and it is impossible to do a sliding menu effect in a decent manner. In the end I totally abandoned this effect.

The speed is not that good when it comes to rendering elements. To be honest, I was expecting a better speed. There are some tricks that help, like pre-rendering the views before displaying them, but for this you must guess what the user will do next, which is not always possible.

Another thing that bothered me was that when the menu button is pressed on Android you can’t take a particular action, let’s say open the side menu that I’ve mentioned before. In PhoneGap for instance, no menu is opened, it must be built-using HTML from the ground up.

When Titanium came out, they were stating that you could develop once and distribute to multiple platforms. Now I was surprised to find that the approach had changed. In the Kitchen Sink, the application that showcases the features of the platform, each platform type initializes the application in it’s own file. One of the reasons is that the design is done dynamically if you are not using Alloy, not trough layout files.

One of the first things that I tried with Titanium was to see the size of a “Hello World” app. Packed, the application has about 8.5M, installed on the phone, it takes up about 16M. I don’t know what you think about that, but for me it is a lot! What is strange is that my final app occupies about 8.4M packed and installed about 16M, almost identical to the original application. The reason is simple, the images replaced by me are a few kb smaller, resulting in an application a little smaller than the one that I started with.

Why does a Titanium application take up so much space?

I had to do some searching before finding the answer. In 2011, when I first tried to research, I only found that all the libraries, needed or not, are packed inside and for this reason it takes up so much space. This wasn’t the cause! Meanwhile, I found the real reason. An application runs a “bridge” between Android and JavaScript. The source code is not “compiled”, as was the initial belief, but just interpreted.

The JavaScript code is interpreted using one of the available engines in the app (V8 and Rhino) and it calls other components that build the native graphing elements.

The issue is with the engines. They are quite big and are packed in every application. And, as if they weren’t large enough, there are 3 of them, each with its’ own purpose:

  • V8 – for newer Android version (after Gingerbread 2.3);
  • Rhino – for older Android versions (before Gingerbread 2.3);
  • x86 – for Intel processors.

These 3 engines occupy a total of 19M, unpacked on my computer. Thus, without eliminating some of them, we can’t get the app size to decrease.

One way Appcelerator is trying to tackle this size issue is to give up Rhino, breaking this way compatibility with older Android versions.


There is a very active community. On the forums and Q/A platforms it’s full of questions and answers! I must admit that I was impressed in this aspect. Some questions are relatively old, even from 3 years ago.

Learning curb

For a week and almost a half, out of which almost a quarter I searched how to do a view moving effect, which in the end didn’t work, I must say it went pretty fast!

I must admit, I’ve played with it 3-4 years ago for a few days and I remembered a few things, like elements of type window, view and label.

The fact that I was able to find answers fast on questions about Stackoverflow, gathered in a few years, but also that the documentation is pretty well organized, helped a lot.

Also on Youtube there are some useful tutorials.

Development environment

In the first versions there wasn’t an IDE, the applications were written with an editor of choice, then packaged and tested using the platform.

Now there is an IDE based on Eclipse. The name is Titanium Studio. It has a pretty nice autocomplete, which helps in a lot of cases. It also has some drawbacks, like in my case sometimes the syntax highlight didn’t work, without any clue were the problem was. Also, project management seems a little strange and it had some issues with import and export of the projects.

There isn’t a default visual tool for editing elements in the page. Both Xcode and ADT allow for editing elements with drag & drop. It turns out there are tools for this, but they are not free.

Emulators are not very configurable. The good part is that you don’t have to worry, you select the operating system and display type and Titanium will automatically configure an emulator. The bad part is that I might wish for a clearer resource management.

Another disadvantage is that sometimes the application will crash before the emulator starts and if you try again it will try to start a new emulator without any luck, case in which the emulator has to be closed. Run Project clean and try again, careful not to miss the moment when the screen can be unlocked, or the scenario will repeat.

For iPhone logs do not work when it comes to OS X Mavericks.

Good parts

It is easy to learn.

The documentation is well done and where something is not clear, surely somebody asked the question before.

There is a fairly large community.

The IDE is easy to use.

It’s easy to see what is possible to achieve with the Kitchen Sink app.

The app doesn’t look like a web page in a WebView!

Bad parts

The app size is quite big (16M on the phone).

The graphical elements are only a subset of the platform.

It isn’t very fast, because the code is interpreted and not compiled, to be able to interact directly with the OS.

There isn’t a visual editor.

There are some issues on integration with emulators, both for Android and iPhone.


If you are a JavaScript connoisseur and you need an application fast and also want to have native graphical elements, then probably Titanium is for you.

If you want performance, probably you need to look for something else.

I don’t have enough experience with the Android SDK to be able to build this application in the timeframe I had available, this was my compromise.

To be honest, I’m not sure wether PhoneGap was a better option or not, speaking for my case. Today there are a lot of JavaScript libraries out there built especially to emulate native graphical elements into a PhoneGap application. The difference is not necessarily visible and, in the end, maybe sometimes the app doesn’t really have to look like a standard app, maybe a completely different interface is more appropriate.

Written by Claudiu Persoiu

24 December 2013 at 1:13 PM

Posted in JavaScript

Tagged with , ,

Building a new generation of programmers in a consumers society

without comments

Motivated by Rober Martin’s article, Hoards Of Novices, I’ve decided to write an article on a similar subject.

I do not want to write about the need for employers to hire juniors, but about why these juniors are not up to the expectations and, in the end, what can be done to be better prepared.

The software market is continuously expanding. Software is the way we command a computer what to do. Today, devices around us have processors, software and applications, from phones, watches, TVs and up to washing machines and refrigerators. All these devices need programms and programmers to develop applications for them.

With this premises, we reach the Software crisis. It was concluded that we need to build software faster in order to solve this crisis. This was a popular subject in the ’60s, but in time it has become less important.

To solve this problem, high level languages and frameworks were built. High level languages made development and maintenance of an application much easier. This way, programmers are getting very far from the “metal” of the actual hardware, working with concepts much easier to deal with.

In a world of high level languages (Java, C#, PHP, Python, JavaScript etc.) it is much easier and faster to create an application.

Yet, although developing an application is becoming easier, the quality of the developers is falling.

A consumer society

We need school for a better job.

Because the need for studies is a general need, the school itself is diluting. The educational principles haven’t had significant changes since education became available to everybody. The result of the learning process is the exam, in order to determine the level of knowledge. And even more, a mediocre result allows us to move forward, without prove that the required base is present.

Moving to the next level is done with a partial evaluation, you don’t have to know 100% of the information, just 50-60%. It is not exactly clear if there are important notions in the remaining 40-50%.

This educational problem is more or less a general problem and there are few those who try different approaches.

In general, I don’t consider school a defining system for determining the knowledge, especially today, when we have access to such a large volume of alternatives for it.

When students finish school, they don’t have all the required knowledge to actually work in the industry, which is not abnormal. School must offer a general basis. For instance, during my higher education I can remember at least 8-9 programming languages that we studied. There were actually more, but I didn’t keep a detailed evidence of them. It is clear that you can’t possibly know all these programming languages in order to become productive using them. On the other hand, you have an idea on how to approach them, which may help you to find the one you’ll like to study in thoroughness.

That’s the key, to study in thoroughness! For this we each have our approach, here you can find your own way, either courses, books, practical projects or all of them. By thoroughly studying a subject, the employers will not only accept you, but they will hunt you!

Often, the passion will totally replace the studies from school. I’ve met a lot of people which, even though they haven’t studied informatics in school, they are now professionals in it.

The good part is that a lot of people are studying from pleasure and I advise anyone who is reading these lines to search for pleasure in what they do. This is the best motivation.

Alternative education in a consumer society

Because the traditional learning techniques are no exactly sufficient, let’s talk about a few alternative methods:

  • books
  • courses
  • tutorials
  • articles/blogs


Traditionally books are the best source of information (at least until the Internet became available). But there is no guaranty for the quality!

About 8-9 years ago I was trying to buy a JavaScript book. The selection wasn’t very big and so I tried to analyze each one.

In the end I was disappointed with my choice, because instead of teaching me JavaScript, the book was teaching how to make special effects on the page (very popular in that period).

In my particular case, I found the answer much later in a presentation by Douglas Crockford. He said that most JavaScript books are like that and he was recommending a single book, beside the book written by him, JavaScript: The Definitive Guide.

The reason is very simple, people tend to be more drawn by books that promise to teach a language or technology in a limited number of lessons or days. We want everything now, but studying takes time, you must understand the notions, not just a fast overview.

Generally, to determine the quality of a book you should look for reviews. These days it is very easy, I prefer and not only. This way you can determine if it is what you are looking for.

Sometimes a faster approach is useful, especially if you don’t have any previous experience on the subject, but generally this doesn’t offer a general perspective, only a gentile introduction.


There are a lot of courses, both in-class and on-line. Just like for the books, it is hard to determine the quality of the course.

Courses promise a lot, but a lot of the times they don’t treat the subjects in detail and in the end, even though you have the impression that you have learned a lot, when it comes to practice you realize that any variation from the course material is very difficult.

Just like for books, references are very important! Unfortunately, there aren’t as many reviews for course as there are for books.

Try to see what subjects the course is teaching and the detail of the approach. Sometimes, you can find more easily a reference for the teacher than for the course.


Especially on the Internet, there are a lot of tutorials that promise to teach a certain domain, but they only teach you how to create their example. In the end you can only create small variations of the initial example. Often, the creator of the tutorial has the best intentions, but it is hard to transfer information like this.

For the free ones it is very easy to determine if the approach is the right one for you and for your needs. Try to watch a few episodes and in the end see how much you’ve understood on how that particular component is working. If you can only replicate, maybe you need to search a little more.

The good part is that there are generally a lot of them to choose from. For instance, for a programming language you can first check the official reference to see what you should learn about, then in the tutorial you can see how many of the points from the reference were approached.

For the commercial ones it is a bit harder, because often you just have a small introspective preview, insufficient to form an opinion. For those particular cases you should search for reviews.

Blogs and articles

The good part here is that the time investment is relatively small. It is simpler to get a general idea.

The disadvantage is that some of the articles don’t update with time. You must make sure that the examples work on the version that you are using. From my own experience I can say that keeping an article up to date is hard an takes a lot of time. For instance some of the articles on this blog that still attract visitors are written a few years back and if I don’t use that particular technology anymore, I’m tempted not to keep them up to date.

How to learn better

Search for references and reviews for the materials that will require an investment in time and/or money: books, courses or tutorials.

When you’ve settled on a subject, try to see what materials others recommend. The Internet is full of materials of different levels of difficulty.

When you fell that you’ve mastered a subject, test your knowledge. Build an app, follow the subject on Q/A platforms or even write a tutorial for the others. You tend to understand much better a subject when you have to describe it to others.

Practice! It is very important to practice what you learn or you’ll forget much easier than you think. Contribute to open-source projects, try to do personal projects or try to adapt projects created by somebody else to your needs. Github is a very good tool for finding and publishing projects.

It is a bit harder at the beginning to understand somebody else’s code, but in the industry it is mandatory in order to be able to collaborate with others.

Learn new things all the time. Technology is changing, and so is the perspective over it. For instance, AJAX appeared in the late “90’s, but the perspective over it and how it can be used changed dramatically over the next few years, even though the technology itself didn’t change a lot during that time. The same for JavaScript, even though it appeared in the “90’s, only after 2000 it began to be considered an useful tool, previously it was mainly used for special effects on the page.

For a while, PHP was considered useful only for small projects. Today it is the language of choice for giants of the internet, like Facebook and Yahoo!. Along with the popularity, the best practices on the language itself changed for a better scalability and performance.


The educational system doesn’t offer the performance that employers are looking for. This creates a discrepancy between the expectations of the employers and those of the graduates, and this not restricted to informatics.

Unfortunately, the alternative materials sometimes also promise unrealistic things. Some study technologies and programming languages for months, while others promise results after only days or even hours.

Fortunately, we are living in an era dominated by information, and we can find not only materials, but also opinions about them.

Through better training, the changes of finding a job are rising considerably, resulting in satisfaction on both sides.

Written by Claudiu Persoiu

17 December 2013 at 11:18 PM

Posted in Diverse