What Is a Programming Framework?
One of the reasons that learning to program might feel like an overwhelming task is the sheer number of new words, terms, and expressions you come across. Today, we’re here to make your life easier by explaining one such term: programming frameworks. Specifically, we’re going to tell you everything you need to know in response to the question “what is a programming framework?”
You can think of a programming framework as a tool—or a set of tools—you use to make your life easier when performing common programming tasks. I know that might sound a little vague, but it’s hard to offer a more complete definition without going deeper into the topic. Luckily for you, “going deep into a topic” is our thing here at Make Me a Programmer.
What Is a Programming Framework In Simple Terms?
Here’s my definition of a framework:
A programming framework is a prepackaged set of solutions that solves common development problems.
Why do people use frameworks? We’ll go into that in the next section, but I can say that the No. 1 reason for using a framework is probably saving time. But as you’ll soon see, there are several other benefits you can get by leveraging frameworks.
And who creates frameworks? Nothing prevents a team or company from creating their own frameworks—and many do just that. Sometimes, companies create frameworks for their internal use and then release it publicly afterward (Ruby On Rails is an example of this that comes to mind).
However, most of the time, people use the word framework to describe a tool created by a third party. Programming frameworks can be commercial, but there are many popular programming frameworks that are open-source projects.
What we’ve just read above was a simple definition of programming frameworks. However, there’s no way to really understand what programming frameworks are without fully grokking the problems they solve. So, that’s what’s we’re doing in the next section.
What Is the Purpose of a Programming Framework?
When non-programmers try to imagine what programming is like, they often picture programmers wrestling with intellectual challenges, trying to come up with creative solutions to problems they have never faced before. And they’re right: Programming is indeed like that, just not all of the time.
Or even most of the time.
Save Time
The answer most people would give to the question “what’s the purpose of a programming framework?” would be “to save time.” And that’s fair: Frameworks help developers save time by not having to solve common or recurring problems.
Software development is riddled with common tasks that all—or at least most—applications of a given type must solve. Let’s take web applications for example.
Web apps have to solve the problem of routing. Imagine you have an e-commerce application. When someone points their browser to <your-awesome-domain-name>/products/categories/clothes, the app has to resolve that URL and perform the necessary actions. “Performing the necessary actions” includes displaying the expected results. So, web applications must also solve the problem of templating. What’s that?
Well, a web application typically has many elements—a header, the main navigation menu, a footer, and so on—that are displayed on most, if not all, pages. Let’s say that, after publishing the app, you realize one of the navigation items contains a typo.
Changing dozens or even hundreds of pages would be no fun, but fortunately, that’s not how it’s typically done. What you’d typically do is have one file containing the common parts—the logo, the header, the footer, and so on—which is called the template. A typical web application would have at least one template, and possibly many. Then, you’d use programming to include or inject the variable bits into the templates. That’s templating in a nutshell.
Routing and templating are two of the most common problems that web applications need to solve. And these are solved problems. Solving them again amounts to what is called “reinventing the wheel” in software circles. By leveraging web frameworks, developers save time.
Ensure Best Practices Are Followed
However, saving time isn’t the only use case for a programming framework. Frameworks can also make a difference when it comes to a crucial area: security. Security is a super tricky part of software development. It’s crucial for developers to get it right, but it’s so easy for them to get wrong.
The solution to this dilemma is to not implement your own security solutions most of the time. Instead, developers should learn what the state-of-the-art solution is and use that.
Programming frameworks make this easier by offering built-in security features. For instance, the Laravel framework makes it easy for developers to implement functionality such as authentication and authorization, email verification, and more. Many other frameworks offer similar capabilities as well.
Types of Programming Frameworks
In the same way that there are many programming languages, there are also many programming frameworks. Those frameworks cater to a huge variety of different purposes and solve a plethora of different problems. We’ll now briefly cover some of the main categories of frameworks out there. You’ll also know about some examples of frameworks belonging to each category. That way, you’ll get an appreciation of the diverse needs that exist in the programming world.
Web Frameworks
Nowadays, when most people hear the word framework, they think of web frameworks, and there’s a reason for that. Such frameworks changed the way web development is done, making it easier for millions of developers to build useful applications. So, what are web frameworks and how do they work?
Web frameworks—more specifically, back-end web frameworks—help developers create web applications, also called dynamic websites. These are websites that you don’t build with just HTML, JavaScript, and CSS. Instead, they use a programming language to interact with a database and then generate the final content. The web frameworks make this process way easier. Many of them—such as the successful and influential Ruby On Rails framework—rely on conventions to spare developers from having to write a lot of code or create complex configurations files in order to get basic functionality working.
Many of the most popular web frameworks adopt a pattern known as MVC, which stands for model-view-controller. The MVC pattern intends to make development easier by clearly separating the concerns in an application into three well-defined layers. Frameworks that use the MVC pattern include Django, ASP.NET MVC, CakePHP, and the already mentioned Ruby on Rails.
Front-End Frameworks
Web frameworks can also be front-end frameworks. “Front-end” here means the client-side part of the application. In other words, it’s what’s executed in the user’s browser, as opposed to the back end, which is executed in a server.
Front-end frameworks allow developers to leverage technologies such as HTML, CSS, and, most importantly, JavaScript to create applications that feel as rich as desktop apps.
The most famous front-end frameworks are definitely Angular and React. Google released Angular in 2010 as AngularJS. In 2016, the framework was rewritten from scratch and released as simply Angular. React was released by Facebook in 2013 and since then has surpassed Angular as the most popular front-end framework.
Mobile Development Frameworks
Mobile application development is a gigantic market, and its growth shows no signs of slowing down. So, the creation of frameworks to help in this area shouldn’t come as a big surprise.
Flutter, Xamarin, Ionic, and React Native are some of the best known names in this space.
Common Misconceptions About Programming Frameworks
Before parting ways, let’s clarify some misconceptions or doubts people sometimes have about frameworks.
Frameworks vs. Programming Languages
Beginners might find it confusing to distinguish between programming languages and frameworks. After all, you use both to write software. To make things worse, people use the two terms in a somewhat interchangeable way. For instance, people will sometimes argue about whether to write an application using PHP (a language) or Django (a framework).
One easy way to know the difference between a language and a framework is to remember that, while the former is typically multipurpose, the latter is targeted to a specific end. So, while you can use the C# language for many different purposes, you’d only create web apps with ASP.NET MVC.
Also, keep in mind that languages are used to write frameworks. So, David Heinemeier Hanson used the Ruby language to write the Ruby on Rails framework. Similarly, the PHP and Python languages are the foundations of the Laravel and Django frameworks, respectively.
Frameworks vs. Libraries
Another common misconception is to mix up frameworks and libraries, and that’s understandable. After all, they’re both pieces of software you didn’t write that can make your life easier. So, what’s the difference? First, understand that both terms might have different meanings in different contexts. So, the line between libraries and frameworks is often a thin one. Also, keep in mind that there’s an overlap between the two concepts.
A common saying people use to explain the difference between libraries and frameworks is this: Your code calls the library, but the framework calls your code.
In other words, you can think of libraries as modules that you can call from your code to solve specific problems. Frameworks, on the other hand, are structures that serve as the foundation for your application. They usually even come with a predefined folder and file structure, and there are specific spots in which your code goes in.
Programming Frameworks: Understand Them and Stop Reinventing The Wheel
Application frameworks are ubiquitous in today’s software development industry. From mobile to web development, passing through desktops and APIs, there are frameworks to cater for pretty much any development needs.
Even though you’re not required to use programming frameworks, doing so will make your life easier. You’ll spend less time reinventing the wheel and more time being creative and solving the problems you’re good at solving. Your application will be more secure and adhere to widespread conventions and best practices. Getting help will also be easier: Developers who have experience with that framework will feel immediately at home when starting to work with your application.
This post was written by Carlos Schults. Carlos is a .NET software developer with experience in both desktop and web development, and he’s now trying his hand at mobile. He has a passion for writing clean and concise code, and he’s interested in practices that help you improve app health, such as code review, automated testing, and continuous build.