Skip to content
Mino edited this page Nov 18, 2016 · 4 revisions

Why the rewrite?

The Python implementation has some design issues:

  • The way plugins send files down the chain forces the whole file to reside in memory. Usually not a big issue, but it does add limitations, especially if I wanted to implement a plugin for a file hosting service.
  • I wanted to implement a download speed monitor, but because of the fact that the plugin does the downloading itself, the implementation wouldn't be as clean as I would like it to.
  • Concurrency is currently done by threads on the plugin side, but again due to how it's all designed, it's hard to move concurrency out of the plugin and onto the framework. I'd much rather the plugin not have to worry about implementing concurrency.

A lot of these issues could be solved without having to rewrite the whole thing, but it wouldn't be nearly as clean as I'd like it to. I also ran into the issue with technologically retarded people using it not knowing how to make it work due to it not being like a single executable but a Python script. I tried making it work with various .py to .exe "converters" (e.g. cx_Freeze, py2exe, nuitka, etc.), but kept running into a bunch of issues.

With all that in mind, I considered rewriting the whole thing in another language. The first language that came to mind was Go because of its excellent portability and speed (for a GC'd language anyway). I have some issues with the language, but it also has a lot of good things going for itself. After implementing the BinB Reader image descrambling in Go to see how well it worked, I was pleasantly surprised by well suited the language was for something like mindl and decided to go with it.

Main pros of Go:

  • Speed. Descrambling images from BinB Reader turned out to be ~10 fucking times faster than Python. Seriously.
  • Easy, cheap, and effective concurrency.
  • Portability. A single executable without the need to install additional crap.
  • Statically typed, meaning fewer unexpected bugs.
  • Good standard library, including image processing which works very well with the stuff I do with mindl.
  • Both good and bad, but the constant bugging about even the slightest details it doesn't like makes the resulting code quite nice and clean.
  • Again, both good and bad, but Go has much less magic.

Main cons of Go:

  • I'm not nearly as productive in it compared to Python.
  • Doesn't have all the neat stuff Python can do to classes using special methods (e.g. __enter__(), __exit__(), etc.). Not to mention decorators.
  • I wish the compiler would just shut up and compile sometimes.
  • Not a fan of the error handling at all.
  • Cannot fully implement a proper plugin system that works as nicely as it does with Python. Official plugin support is being worked on, though, so maybe eventually.

I'm sure I'm forgetting stuff, but all in all, I think it's pretty much perfect for an application like mindl.

Clone this wiki locally