What is the difference between a code library and a code framework? Answer: The question really doesn’t make any sense because a “library” and a “framework” can mean whatever you want. There are no formal definitions of the two terms.
The terms library and framework just mean code modules that have been pre-written by you or someone else. However, it’s sometimes useful to think about how “library-ish” or how “framework-ish” some code is.
Most of my colleagues, and me too, generally think about library-ish code as being low level modules that are mostly independent of each other, where you usually edit/modify the code, and connect different library-ish modules with custom code.
We usually think about framework-ish code as being high level modules that are highly dependent on each other, where you rarely modify the code, and often use only the framework-ish code with little or no custom connecting code.
Functions in framework-ish code often have a large number of parameters because framework-ish functions aren’t easy to modify. Functions in library-ish code usually don’t have a lot of parameters — just the essentials, because you can add additional parameters and modify the code in library-ish functions relatively easily.
Here’s an example of what I’d call C# library-ish code, in a machine learning context:
double[][] trainX =
MatLoad(".\\testData.txt", new int[] { 0, 2, 4 }, '\t');
. . .
static double[][] MatLoad(string fn, int[] cols, char sep)
{
// custom code to load data into an array-of-arrays matrix
}
And here’s an example of what I’d call framework-ish code from ML.NET that does roughly the same thing:
using Microsoft.ML;
using Microsoft.ML.Data;
using EmpClassifier.Model.DataModels;
. . .
IDataView trainDataView =
mlContext.Data.LoadFromTextFile(
path: TRAIN_DATA_FILEPATH,
hasHeader: true,
separatorChar: '\t',
allowQuoting: true,
allowSparse: false);
. . .
namespace EmpClassifier.Model.DataModels
{
public class ModelInput
{
[ColumnName("hourly"), LoadColumn(0)]
public bool Hourly { get; set; }
. . .
}
Library-ish code uses mostly primitive data types such as int[] and double[][] while framework-ish code usually has many custom class and interface definitions. The ML.NET LoadFromTextFile() code has a hasHeader parameter. If you wanted to add such a parameter to the library-ish MatLoad() function you could do so.
Side effects of the complexity and high level of abstraction of the framework-ish approach are that framework-ish modules are often difficult or impossible to modify, and therefore framework-ish modules often force you into architecting a system in one particular way.
With library-ish code, you must have a greater knowledge of algorithms and greater coding skills.
The distinction between library-ish code and framework-ish code isn’t Boolean. Most pre-written code has various degrees of the factors I’ve described.
So, when I read or hear the question, “What’s the difference between a library and a framework?” I’m pretty sure the person who asked the question is an inexperienced developer.
The purpose of rigidly defining terms in computer science or in any field is to clarify communications. Slapping labels on concepts does not increase knowledge, and people who do so and proclaim themselves as experts are almost always egoists trying to make money. A good example of this is the computer science so-called SOLID principles — absolute meaningless nonsense.
In business, most of Six Sigma is nothing more than hilariously obscure terminology and acronyms like DMAIC which are designed to make people believe that Six Sigma is something more than just a few useful concepts that can be explained and learned in two hours. And “Agile” programming is just a few common-sense ideas but is typically surrounded by massive amounts of lame terminology intended to enable bogus training. (Wow! When did I become the cranky old programmer guy?)

.NET Test Automation Recipes
Software Testing
SciPy Programming Succinctly
Keras Succinctly
R Programming
2026 Visual Studio Live
2025 Summer MLADS Conference
2026 DevIntersection Conference
2025 Machine Learning Week
2025 Ai4 Conference
2026 G2E Conference
2026 iSC West Conference
You must be logged in to post a comment.