Libraries vs SDKs vs Frameworks
The terms library, SDK, and framework are tossed around a lot in the programming space. They all play a role in the development process and there's overlap between the three, but there seems to be a lot of ambiguity around what makes each one unique. I've certainly been confused before!
Libraries
Libraries have the smallest scope of the three tools. A library is a reusable chunk of code wrapped in a package and published online. Often libraries can be found on version-controlled code platforms like Github or GitLab, and hosted on package manager repositories like npm (for JavaScript) and PyPI (for Python). You can download libraries into your project to perform some specific functionality that saves you the time and effort of writing that logic yourself.
Some popular functions developers commonly use libraries for:
- UI components (React, Bootstrap)
- State management (Redux, MobX)
- API calls or HTTP requests (Axios, SuperAgent)
- Form handling (Formik, Yup)
- Routing/Navigation (React Router, Vue Router)
- Data viz (Chart.js, D3.js, Highcharts)
- Animations (Anime.js, Framer Motion)
- Auth (Firebase Auth, Passport.js)
- Styling (Styled Components, Tailwind CSS)
Take Chart.js, a popular JavaScript library used to create responsive charts and graphs. It's totally possible for you to build charts from scratch by accessing the 2D rendering context of the HTML <canvas>
element and drawing shapes, lines, and text to create line, bar, or pie charts, then track mouse events on the canvas and dynamically update the chart's rendering. But if your time would be better spent elsewhere on more unique aspect of your application, why reinvent the wheel?
A word of caution: Libraries are great, but each one you bring into your application adds lines of code to your app's total bundle size. Including an excessive number of libraries (especially large, multi-functional ones) will lead to a bloated app, which negatively impacts its performance, maintainability, and overall user experience.
SDKs
SDKs, or Software Development Kits, have a wider scope than libraries do. All SDKs will have at least one library, but they also contain a lot more—an SDK is a collection of libraries, APIs, utilities, starter code, and documentation that help you implement a specific feature/functionality into your code without having to do it from scratch.
Here's an analogy. If you're building a log cabin, a library would be a like a chainsaw. It's a specific tool that saves you from having to somehow cut or break the wood manually. An SDK would be more like an entire shed worth of tools and resources.
Some popular SDK examples:
- The Google Maps SDK provides developers with the APIs, libraries, docs, and tools needed to add interactive maps and geolocation features into their mobile and web applications.
- The AWS SDK is a set of SDKs in various programming languages that enable developers to integrate and interact with Amazon Web Services in their application.
- The Stripe SDK provides the APIs and tools to integrate payment processing functionality into apps.
- The Twilio SDK allows developers to integrates communication features like SMS, voice, and video into their apps.
- Apple's SDK for building apps for iOS devices, Xcode, includes frameworks like UIKit, Swift libraries, native API access for camera, photos, and push notifications, and tools for interface design and testing.
Just like libraries, SDKs are not a necessity, but they do make development a lot easier when you're trying to implement functionality like interactive maps, financial transactions, SMS texting, or cloud storage. It's worth noting that the iOS SDK (and Android SDK too) operate slightly different; these SDKs are essential, since each one provides the necessary components, native APIs, emulators, and other tools required to access the device's underlying operating system functionality needed to build and run apps. I would not recommend trying to build an iOS or Android app without its respective SDK.
Frameworks
Like SDKs, frameworks are also made up of a collection of libraries, APIs, utilities, and documentation to save you from the time and effort of starting an application from scratch. However, frameworks are like a half-built foundation that you drop your code into, rather than receiving building blocks to drop into your code. They're essentially the inverse of an SDK. With frameworks, getting up and running is faster and more streamlined, but that comes with the tradeoff of losing the freedom to structure your project how you wish. With libraries, you insert and call them from your code; with frameworks, you insert your code and the frameworks call your code when directed.
To continue the log cabin analogy, a framework would be like hiring a construction service. You're still there working with them and giving input, but you're not making all of the decisions yourself.
Some popular frameworks:
- Next.js: A framework that utilizes server-side rendering, static site generation, and code splitting to build fast and scalable web applications in React/JavaScript.
- Django: A framework for building backend web apps in Python
- Ruby on Rails: A full-stack development framework for building web apps in Ruby
- TensorFlow: A cross-language machine learning framework for building AI models
- Electron: A framework for building cross-platform desktop apps using JavaScript
Libraries, SDKs, and frameworks are all great tools to understand when building software applications, each with their own benefits and tradeoffs. It's worth mentioning that while all of these tools speed up development, they bring in abstractions that allow the developer to gloss over how the code is actually working under the hood. For example, the Next.js framework implements a filesystem-based routing mechanism. To a newer developer who isn't familiar with module bundling and doesn't know better, they might assume that this is how web browsers route to various parts of the application, rather than realizing it's a framework-specific abstraction. My advice is to use these tools when it makes sense, but not to be dependent on them—a well-rounded engineer understands how code runs without all the bells and whistles.
TLDR;
- Libraries add specific functionalities to your app
- SDKs provide a comprehensive toolkit for implementing complex features
- Frameworks offer structured blueprints that streamline development but constrain architectural choices
- Build from scratch to to solidify fundamentals and understand what's going on under the hood