Behind the Scenes: The Rewrite (Also code release!)
Behind the scenes is a series used to discuss progress within FreeTube along with my personal thoughts on the subject. Today's article will be about the FreeTube rewrite that has been ongoing along with a public code release. If you're interested in helping with this rewrite, please read on as I would love to have your help!
Why a Rewrite?
Some of you might be thinking, “I've had (mostly) no issues with the latest release with FreeTube. Why would you want to rewrite it?”. The answer to this has multiple parts as to why I feel like a rewrite was very much needed.
The Code is Pretty Bad
And I take almost all the blame for this. Sure, the code works pretty well and for the most part is bug free, but it's organized in a way that makes it unsustainable. As more features get included, things become more difficult to work with. The code has become a jumbled mess at times and certain code for certain functionality is scattered around the project. I've been able to deal with this personally though it becomes difficult to be motivated to continue working in this way when I know it's bad and when it's likely one of the biggest reasons this project has a lack of contributors.
The Vue.js Implementation is Worse
Vue.js is a very good framework in my opinion. It allows for small bits of an application to live in it's own world with it's own code that doesn't have to be affected by the other bits of code in the application. This turns the code into portable blocks that can be reused in other locations of the application. It also encourages the developer to be more generic in your code to allow each component to be as portable as possible, increasing usability.
At least, that's how it's supposed to be done. FreeTube currently uses Vue.js in the most technical sense you could imagine. I've been able to learn so much more on how a Vue.js application is supposed to be structured and well...I did it wrong, very wrong. Sure, it “works”, but the current state of FreeTube is probably the furthest away from how a Vue.js application is supposed to be done. It's a great example of what not to do and it's entirely my fault.
I Almost Implemented Hacky Solutions for Extremely Simple Problems
One of the biggest requests as of recent was a way “to go back”. It sounds simple on paper, however it simply wasn't the case. I've taken so long to implement this because I wasn't sure on how to do it with the current code base. The way state worked was that everything was destroyed as you navigate and no data is saved along the way. This meant that there was no such way as “back”, only “forward”. I would have to save every copy of data from every page manually and keep track of where you're at in your navigation history to make this happen. This would have taken ages to do and even at the end of the day it still probably wouldn't have worked the way you would have expected it to.
That's when I needed to take a step back. While FreeTube is considered a desktop application, it runs on top of a browser, Electron. Back / forward navigation comes standard in every web browser and is literally one of the most basic functionalities in a browser. Why was I not using this? This ended up being the final straw as I'm not here to reinvent the wheel. I want to make a functional application that includes key privacy features.
So Now What?
It's time for FreeTube to have a fresh start. There are clearly much better ways of putting together an application like this and I'm not taking advantage of that. I've taken some time to start over with FreeTube. I still plan on using Electron, but I'm going to be smarter about how I put it together. It also means I've been taking some time to look at old designs (both code and aesthetically) and change them to be more efficient and more pleasing to use.
The above pictures is a showcase of the rewrite so far. The design has been refreshed to be more similar to the YouTube layout that'll be removed soon. I hope you like it! Things like back / forward navigation is already supported and working in this rewrite, since a feature like that is standard within Electron / web browsers. Basic features like searching are also already implemented.
Next Steps: Releasing the Code
So far, this rewrite has been done behind closed doors. The reason for this is because my decision making tends to change quickly during the early stages of development and I don't want to overwrite someone else's changes because of it. I also wanted to make sure that enough of the rewrite was done so that anyone who wants to contribute has an idea on how I'd like to layout the code moving forward. I'm at the stage where there should be plenty of examples to look at, while at the same time there are still a lot of things to work on.
Along side this blog post, I'm releasing the code for the new rewrite. This code will be released under the GPLv3 just like the old code base. The new code base is different enough to the point where it will live in a separate repository from the main FreeTube one until it is ready to replace it. This will allow us to create issues solely about the rewrite and not mix issues about the live release. This also allows us to structure things like Wiki pages a bit differently as we can focus on articles more about development instead of general usage.
I encourage anyone and everyone interested in contributing to check out the new code base and poke around. I will be creating issues in the new repository with a high level list of things that still need to be completed. Feel free to pick out what you would like to work on and let me know which one you take.
Goals and Status
For a quick list, the following things have been completed:
- General Videos list (What displays videos and channels from search results or subscription lists)
- Search (Along with filters)
- Trending Page
- Most Popular Page
- Viewing a playlist
- Viewing a channel (Including channel playlists and searching a channel for videos)
The following is actively being worked on
- The Video Watch Page
Everything else not listed is something that needs to be completed. My goal for this rewrite is to reach feature parity with the old code base before a new release. That means that things such as subscriptions and settings have not been started yet. I will be reusing code from the old code base whenever possible, however new logic for features will be made whenever appropriate. I will also be including extra features that were not implemented / finished from the old code (like comments and local playlists).
What Will Happen to the Current Release?
The current code base of FreeTube will likely be deprecated. I may transfer the code over to an archived repository for reference and preservation once I'm finished. Until the rewrite has replaced the current code base, FreeTube will be under maintenance mode. This means that I have no plans on adding more features to the current release. I will however make a new release if something breaks. It may take a while before the new rewrite is ready, but I promise it will be worth the wait. Even in it's current state, it's already written so much better than the current release. It's a night a day difference.
I hope this helps shed some light on my thought process of why I've been working on a rewrite for FreeTube. I have a break within my work and will be working on FreeTube full time (more or less) for the next 2 weeks. This means that a lot of work will be done here very soon. If you would like to help out with this rewrite I will be active on our Matrix server to chat. As I mentioned above, the repository will also include some articles and issues to help you get started. It also lists out what still needs to be done with this rewrite. I hope to hear from some of you soon about the rewrite. If you're interested in helping out, please check out the links below.
The FreeTube Rewrite Repository Our Matrix Server (To chat about the rewrite)
See you next time!