I Tried to Write a Decent Desktop App
Idea
The starting point for me was learning Go and writing a simple app, and I thought about operations on PDF files: merge, split, etc. pdf24 is one of the most popular apps for Windows, so I reviewed its functions and UI/UX as a baseline. The idea was to program 3% of the most useful functions. Does pdf24 do the job? Sure. Would I use it on Windows if I needed to transform PDFs? Yes, it’s just not worth looking for viruses. Linux has a number of desktop apps for PDF manipulation, by the way, but let’s just have another one. And I have some very specific ideas about UI/UX, but as I’m scratching my own itch here, it’s useful to write two sets of requirements: user requirements and dev requirements. You can check the GitHub page for the result with screenshots.
User requirements
Most users may not care about the size of the app or some aspects of UI/UX if it gets the job done. Still, there are some nice things to have:
- Hotkeys, because any app is faster with a keyboard
- Fast, because nobody likes waiting
- Modern UI, which includes 'looking nice', but also being humble and similar to native UI
- Open multiple files at once for the merge operation; otherwise it’s unnerving
- Handle user input errors
- Intuitive in terms of simplicity, but also not allowing users to engage functions when it’s useless
- UI doesn’t freeze while performing the task, which happens with some programs and the operating system can suggest closing the app
- Simple or (better) no installation procedure, which is especially relevant for Windows with limited permissions
- The same program for Linux, Windows, and Mac – because users can get used to an app on one platform
- Small download size is arguable now, but let it be
Dev requirements
As a (lazy and novice) developer, I’d like to have the following:
- Writing less code (I mean, not like Java or GTK+)
- Threads for UI and tasks (Python and JS can only emulate them)
- Compile to Linux, Windows, and Mac without hassle
- Small app size matters for easy distribution as well
- Convenient syntax for error handling
- Declarative UI
- Mature UI toolkit with all the functions a GUI app needs
Design choices
Regarding the language, Go ticks the boxes:
- Less code
- Threads
- It’s natural to write error handling
- Cross-compilation
- Fast
For the GUI toolkit, Tk9.0 ticks the boxes as well:
- Declarative
- Works on Linux, Windows, and Mac
- All the functions for a GUI app included
- A modern Azure theme
- Hotkeys support
- A file dialog to open multiple files
- Disabling buttons is easy
- Compact and fast
Regarding the UI/UX itself, I decided to have a menu with buttons, and for each operation to have three sections in one window:
- Instructions with brief text
- User input to open files and specify pages
- Messages about success or failure
So no pop-up messages, just one logically organized window, and Tk allows me to do it.
Statistics
I’m too lazy to measure how fast the app is; it actually uses the pdfcpu library, also written in Go. But it seems fast enough. :)
The only statistics I have are file sizes and lines of code. The pdf24 distribution is 600 MB, being a lot more functional and with fancy stuff like PDF previews. My app is 29 MB for Windows and 46 MB for Linux, which includes debugging info. Without debugging info, the Linux app is 36 MB, which can be further reduced with upx to 20 MB.
For the lines of code, it’s 1004 lines, which is relatively small.
For the learning experience, I rewrote parts of the app multiple times and learned to prioritize clarity and trust the compiler. For Tk, it’s better to look at examples for guidelines, but what’s important for me is that it’s stable and doesn’t bring new bugs. One could complain about the absence of HTML: you need to emulate it with the included markup language and generate tags, but it was fun.