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 the 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_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.
Well, you can actually create your own secure chat to be used inside the company only, using an open source client and building your own server instead of the cloud Telegram servers. Though, your backend specialists will surely need some time to conduct a deep research on how to create such a server, then build it, and fix possible bugs. Most definitely, creating your own server will be risky, as you’ll also need to hire experts in encryption and data security.
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.
Read also: How to develop a social app
Telegram open source code isn’t reusable
Telegram’s source code is not an 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. Old version of the client in the open source. I don’t really know why, but Telegram usually waits for about 4 to 5 month after the client release and only then it gets to the open source. This means you can only find the outdated version of the client. Weird, huh?
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). Moreover, you can’t find the documentation for the methods and can’t support such code anyhow. If you decide to change or add a new feature, you might spend up to a month doing that. This made me curious what sort of a Telegram developer wrote this.
4. Spaghetti code. It’s complicated and can make you spend days to simply understand the code architecture. I haven’t met anyone who likes spaghetti in their code. Maybe Italians?
5. A lot of pure C code used for high performance. For developers, this means difficulties in code maintaining and development. More than that, only senior expert developers will be able to deal with such code.
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 do 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!