What's Wrong With Open Source Telegram?

Everything about Telegram is cool. No, seriously. It’s free, heavily encrypted, cloud-based, and powerful. The only thing which might confuse app developers is the messaging app saying it’s open source.

I investigated their source code and wrote this post because one of our clients asked me to clarify whether he could use it to develop his messaging application. My response was “You can, but we don’t recommend it.” Telegram source code is indeed free and open, but that will barely help app developers build their own messaging apps. Here is why:

You can’t use Telegram API to build an independent messaging app

In order to use their API, you will have to register an app here. All you need to do is enter your phone number, and then you will receive a password in your app account. After you have received the password, you can register an app on the website. You will receive a unique api_id and api_hash that are necessary to work with their API.

When I entered my phone number in the messaging app I created, I got all the messages I previously sent in the Telegram app (both desktop and Android). In other words, all the data associated with a user is tied to their phone number, which they enter when they authorize with Telegram.

My conclusion is that the Telegram API allows you to work with their data only. In other words, it’s impossible to store your data on a separate server or a database. The API will let you create an app that interacts with the Telegram messaging app, but this app won't be able to live a life of its own.

A lot of apps have open APIs and let other developers use them. Take TweetCaster, for example. The service uses open Twitter APIs. All the tweets published to TweetCaster are published to Twitter as well.

Telegram open source code isn’t reusable

Telegram’s source code is notan SDK or a library. Using it will likely expand your development time, rather than speed it up. I looked at their code and found some terrifying issues. It has lots of hardcode and no constants. There are no system constants, nor constants in the app itself. Other major issues include:

1. Strange pieces of code, such as setTextColor(0xff757575).

Developers normally make a separate XML called “color”. When you need to change the main color of the action bar title, for example, you can do it in one place – color.xml– and it will change the color everywhere else in the code. But in the Telegram’s case you’ll have to search for that exact place in the code defined as setTextColor(0xff757575) and only there can you change the color. Honestly, you don’t need this headache unless you want to boost the development time and love to complicate your life for no reason.

2. Magic numbers for int values such as “42540” which are passed as flag values. This made me think their code is obfuscated, but most likely, this isn’t the case.

3. “If-Else” statements are too long and there are really long methods (i.e. 300 lines of code in one method). This made me curious what sort of a Telegram developer wrote this.

5. There are only three Activities in this huge project. There are also many classes *activity that extend BaseFragment which is not actually a Fragment. Sounds crazy, right? BaseFragment is a custom layout with custom methods. According to common sense, *Activity should extend Activity to which you add Fragments.

But to be fair, the messaging app doesn’t state they have an SDK. All they did is put their source code in the open.

If you develop an app with Telegram license, it should go to GitHub

Even if you make an app based on Telegram, you have to publish your source code. Their license says: “Please remember to publish your code as well in order to comply with the License.” (Telegram Github)

If you commit your time and money on developing a messaging app using Telegram source code, you probably won’t be happy about having to publish your code for everyone else to use.

As you can see, Telegram isn't the best option for building messaging applications. They provide neither an SDK nor comprehensible source code. All the elements in the app are custom. I have no idea why they decided to make it like that, but from my developer's point of view, their source code is no good for building similar projects.

At the end of the day, it’s not a big deal that the Telegram source code can’t help you much in your app development. Yalantis has plenty of experience designing and building messaging services. We will make sure you get the best product!

3.3/ 5.0

Article rating

245

Reviews

Remember those Facebook reactions? Well, we aren't Facebook but we love reactions too. They can give us valuable insights on how to improve what we're doing. Would you tell us how you feel about this article?