8 ms·
The worst codebase I've ever worked on was the Telegram client for Android. I mean just look at this file, it's so huge GitHub gives up rendering it: https://gi
by grishka 2y ago
The worst codebase I've ever worked on was the Telegram client for Android. I mean just look at this file, it's so huge GitHub gives up rendering it: https://github.com/DrKLO/Telegram/blob/master/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java https://github.com/DrKLO/Telegram/blob/master/TMessagesProj/...
Or this one, it implements EVERYTHING for rendering and interacting with a message in a single class, all non-service message types, all drawn manually on a canvas "for performance", and all input processed manually too: https://github.com/DrKLO/Telegram/blob/master/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java https://github.com/DrKLO/Telegram/blob/master/TMessagesProj/...
I even had the permission from the main developer to refactor some of it, but I never got around to actually doing it.
It's a miracle this app works at all.
- bartekpacia 2y agoIt’s even more crazy because Telegram is by far the smoothest messenger app on Android. BTW, would you mind sharing how you got that job?
- Klonoar 2y agoThey didn't specify it was their job, the project is open source after all.
- grishka 2y ago> BTW, would you mind sharing how you got that job? I started working with Pavel Durov in 2011 on the VKontakte Android app, after winning several of his developer contests, and it all just went from there. I was the last one of the "old" team to transfer to Telegram. My main job was actually the libtgvoip[1] library and its integration into the Android app (the other platforms were done by their corresponding devs). I got fired in 2019 because the calls weren't working satisfactorily for Pavel. He got furious when he was unable to call some journalist, cursed at me in front of the entire team and sent me a termination notice. In hindsight, I should've definitely not taken building a VoIP library from scratch alone upon myself. It's a massive undertaking. But at least I learned a lot, and many people say that my implementation performed noticeably better than the current WebRTC-based one ¯\_(ツ)_/¯ I'm now working on two fediverse projects at the same time — Smithereen[2], a VK-like ActivityPub server, and the Mastodon Android app[3]. [1] https://github.com/grishka/libtgvoip https://github.com/grishka/libtgvoip [2] https://github.com/grishka/Smithereen https://github.com/grishka/Smithereen [3] https://github.com/mastodon/mastodon-android https://github.com/mastodon/mastodon-android
- nar001 2y agoWhy did the call fail? What failed with your implementation/the code?
- grishka 2y agoWe'll never know. There are many things that could go wrong because VoIP over the public internet is inherently fragile. When I asked for logs so I could look into it, I got cursed at once again.
- danogentili 2y agoGrishka wrote very low quality code (an extremely buggy and segfaulty mess of C and C++), combined with little testing in not-so-edge case network conditions. I managed to improve the situation after weeks of refactoring and testing for my library, and thankfully now it was completely replaced by webrtc.
- Aeolun 2y ago> He got furious when he was unable to call some journalist, cursed at me in front of the entire team and sent me a termination notice. Honestly does not sound like a very healthy person to work for anyway.
- wood_spirit 2y agoThere are two sides to every story
- Aeolun 2y agoSure, but I do not feel like it’d really affect the broad strokes of ‘criticized in front of the entire team’.
- greenthrow 2y agoThere's no side where berating your subordinates in front of others is justified. That's unprofessional and childish. Always.
- hyperbolablabla 2y agoTelegram happens to be one of the smoothest app experiences on Android, both in terms of perf and UX, so they must be doing something right.
- heraldgeezer 2y agoWell, Telegram is faster/smoother than FB Messenger, Whatsapp, Discord (dog slow) etc... So it is not only working but working well.
- danogentili 2y agoThis dude has absolutely no right to say anything about the quality of the source code of the android app, because: 1) His libtgvoip code, previously used for audio calls, is the worst code I have ever had the displesaure of touching, it caused all kinds of issues ranging from instability to segfaults, and thankfully it was completely replaced by webrtc. 2) The android app is literally the smoothest and most responsive android app I've ever used. Grishka, please stop being so salty. VoIP is hard to do right, but not impossibly so. VoIP being hard is still not an excuse for writing garbage C/C++ code (and I don't mean to offend personally here, but the code was really a mess, please stick to Java development on your own personal projects).
- grishka 2y ago1) Which version are we talking about? Segfaults were exceedingly rare either way. Especially so when I stopped using raw pointers. But yes, to no one's surprise, early versions were a mess. I can agree with you on that. I can't agree about the same about the last versions though. It was replaced by WebRTC that would sometimes just suddenly disconnect your calls, right. > I managed to improve the situation after weeks of refactoring and testing Did you submit any PRs with your improvements? I used to review and merge those, unlike the Android app devs. 2) It might provide the best UX in the entire universe, but that still doesn't justify having a two-megabyte Java file with over a hundred anonymous inner classes that gaslight you because it's often a `new FrameLayout(activity){` that overrides onLayout and does something completely different. So you see a FrameLayout, you assume it behaves like one, you add views to it, then it doesn't work the way you expect. You start questioning your sanity and only then do you realize that it's one of these stupid things. Oh and did I mention that even just editing ChatActivity.java is an exercise in frustration? At the time, I had a 2012 MacBook Pro that worked fine for everything I did on it, except editing 2-megabyte Java sources in Android Studio. It would sometimes take a solid 10 seconds for keystrokes to register. In other words, it might be the best Android app in the world, but it blows up in your face nearly every time you try to add a new feature.
- nurumaik 2y ago> but that still doesn't justify No, that really justifies anything. Programs should be pleasant for users to use, not for developers to work on them