I’ve built a SaaS app in C++ using Drogon, despite being told that writing a web app in C++ is a bad idea.
Honestly, my experience has been surprisingly good. Drogon makes it easy to build HTTP request handlers, query databases asynchronously, and it can call external HTTP APIs with ease. Overall, it’s a solid web framework.
But after months of using it to build my SaaS MVP, there are two things that keep frustrating me.
Missing Functionality
First up, missing features. No surprise that there are things it can’t do yet. But what did surprise me was that it doesn’t have asynchronous file I/O built in. It’s got async database query capability, including with co-routines. But, unless I missed something, it doesn’t have an API to access files asynchronously. And integrating the asio library isn’t straightforward.
No big deal so far, because I haven’t needed async file I/O. I thought I needed it. But, in the end Drogon’s static file handler did everything I needed. All my async code has been running database queries.
But still, async file I/O is such a fundamental task that I’d expected it to be there, right out-of-the-box.
CSP Templates Suck
Lets move onto the most annoying part of Drogon: it’s CSP templating system. In theory it sounds great: mix C++ with HTML to dynamically generate HTML content. It gets compiled to native CPU machine code for maximum performance
And that does work great. What sucks is the process of tweaking and polishing the templates
Writing HTML templates is an iterative process. You write a template, run the server, look at the generated page. Then you tweak the template and reload, and tweak and reload, again and again until it looks the way you want it to. This allows you to rapidly experiment with UI design
This tweak and reload cycle is fast with all other frameworks I’ve used. With Drogon, you have to recompile the template and restart the server every time. Drogon does have the ability to detect template changes and dynamically rebuild them on-the fly. However, that process still takes about 5 seconds or so, after which it often crashes. At least, it crashes for me, unless I’m trying to record a screencast of it so that I can show you in a video. Then, it works flawlessly…
This process is so slow that I’ve seriously thought about switching to another templating library. I haven’t done that yet, because I’m working on an MVP, and replacing the templating system would delay the project right when I need to ship fast.
When you’re an entrepreneur building an app, your biggest unknown is whether anyone needs your app, or if you’re wasting your time building something nobody wants. You cannot afford to get caught up in polishing your code for months to years, while you have no idea if anyone would even want to use it let alone pay for it
Working with CSP templates is fast enough, that I’m better off sticking with it, and getting the MVP done and into the hands of potential customers
I might still switch later. If you know of a C++ HTML templating library that is flexible, expressive, and achieves near native performance, then let me know in the comments below.
For now, though, I’m sticking with what the Drogon framework has to offer. Despite my complaints, it’s working very well for me.