LibSlack: The C++ Library at the Foundation of Our Client Application Architecture

Slack ships its client application on many different platforms — we currently support Mac, Windows, Linux, iOS, Android, and Windows Phone. Initially these different platform applications were developed independently at Slack, with separate teams and codebases for each of the mobile platforms and the desktop. About a year ago, Slack formed a new team, LibSlack, to develop…

Tracy Stampfli
10 min readintermediate
--
View Original

Overview

LibSlack is a cross-platform C++ library developed by Slack to streamline the client application architecture across multiple platforms, including iOS and Android. The article discusses the challenges faced during its development, the architectural decisions made, and the benefits of using LibSlack for code consistency and efficiency.

What You'll Learn

1

How to integrate a cross-platform C++ library into native applications

2

Why lazy loading improves application performance in large teams

3

How to manage caching strategies for offline functionality

Prerequisites & Requirements

  • Understanding of C++ and cross-platform development concepts
  • Experience in mobile application development(optional)

Key Questions Answered

What are the main benefits of using LibSlack for Slack's client applications?
LibSlack allows Slack to share common code across multiple platforms, reducing development effort and improving consistency. It addresses issues like inconsistent feature behavior and multiple bug fixes across platforms, ultimately enhancing the user experience.
How does LibSlack handle data caching for improved performance?
LibSlack implements lazy loading to fetch only necessary data for the current view, which significantly enhances startup times and functionality during poor network conditions. This proactive data fetching strategy ensures that users can still interact with the app even when offline.
What programming language was chosen for LibSlack and why?
Modern C++ was chosen for LibSlack due to its support across all major platforms and performance-enhancing features. The team initially used C++ 11 but plans to upgrade to C++ 14 to leverage newer language capabilities.
What challenges did the LibSlack team face during development?
The team encountered difficulties in debugging and integrating the C++ library with native code. They initially used a reference client for testing but later transitioned to debugging directly within Slack clients, improving their development process.

Key Statistics & Figures

Code coverage with unit tests
70%
LibSlack maintains around 70% code coverage with unit tests, which are run on five platforms for every pull request.

Technologies & Tools

Some links below are affiliate links. We may earn a commission if you make a purchase.

Programming Language
C++
Used as the core language for developing the LibSlack library.
Header Generation Tool
Djinni
Used to generate headers for LibSlack APIs in different languages for integration with Slack client applications.
Build Tool
Ccache
Utilized to cache compilation outputs and reduce build times for LibSlack.

Key Actionable Insights

1
Implement lazy loading in your applications to enhance performance, especially for large datasets.
Lazy loading allows applications to load only the data necessary for the current view, which can significantly reduce startup times and improve user experience in environments with unreliable network connections.
2
Utilize a cross-platform library like LibSlack to unify business logic across multiple platforms.
By centralizing common functionality, you can reduce the redundancy of implementing features across different platforms, leading to more consistent behavior and easier maintenance.
3
Adopt modern C++ features to improve memory management and performance in your applications.
Using features like smart pointers and move semantics can help prevent memory leaks and improve the efficiency of your code, making it easier to manage complex applications.

Common Pitfalls

1
Failing to manage dependencies between C++ and native code can lead to integration issues.
This often results in debugging challenges and increased complexity in the development process. To avoid this, ensure that the integration process is well-defined and that proper testing is conducted throughout development.

Related Concepts

Cross-platform Development
Caching Strategies
Mobile Application Architecture