Introduction
If you're a macOS or iOS developer, you've probably heard the mantra: "Stay native as much as possible." But what happens when you need to integrate text, especially with advanced features like Markdown? Artem Loenko, a veteran in the field, shared eye-opening experiences on this topic. In this article, we'll explore the challenges of integrating text in native applications and why some are turning to Electron.
The Dream of Going Fully Native
Native development is often seen as the Holy Grail for mobile and desktop applications. Swift and SwiftUI offer impressive performance for simple and intuitive user interfaces. However, once you venture into more complex features, like handling Markdown documents, limitations become apparent. For instance, selecting an entire Markdown document built from SwiftUI primitives is simply not possible by design.
The Limitations Encountered
Artem Loenko tried to create a chat application with Markdown support using only Swift and SwiftUI. Very quickly, he encountered major obstacles. Switching to NSTextView, which supports TextKit 2, resulted in losing compatibility with the tests and performance developed around SwiftUI. Even attempting to integrate text streams led to CPU spikes. AppKit and NSCollectionView, while robust, introduced other issues, such as cell blinking.
The Electron Alternative
Faced with these challenges, Loenko explored WebKit for Markdown rendering but found even more satisfaction with Electron. With Electron, text operations and Markdown rendering work smoothly right out of the box. macOS integrations are also supported, and adding features like Git diffs is a breeze.
Why Electron Attracts
As of 2023, Electron has become an attractive solution for many developers. According to a Stack Overflow survey, 9.5% of developers use Electron for its cross-platform capabilities and ease of integrating third-party modules. Furthermore, Electron offers flexibility that native solutions struggle to match.
Conclusion
Native development has its merits, but when advanced text features come into play, Electron's simplicity and efficiency become undeniable. If you're facing similar challenges in your project, it might be time to reconsider your options and explore what frameworks like Electron can offer.
Let's discuss your project in 15 minutes.