Why Sharing Code is Benevolent and Sustainable

Posted by in Business Strategy, Software Development, Sustainability, Web Development tagged with

Shared libraries offer quick access to solutions for common development problems. Incorporating shared libraries vetted by the developer community makes your entire codebase easier for other developers to understand and, ultimately, more sustainable. Why do the developers at Mightybyes use shared libraries whenever we can? It might have something to do with our dedication to sustainable web design.

Shared Libraries Mean You Do Less Work

How far along would society be if discoveries like a spherical earth or the tensile strength of steel had to be constantly rediscovered? Fortunately for society, we don’t have to rediscover either of these things: Someone has done the discovery work and shared it with us so that we can build skyscrapers and not fall off the earth when sailing west.

Let’s define what we mean by shared libraries. They are any kind of code that already exists and, due to an open source license, can be freely included in your project. Most popular languages have repositories of libraries that solve common problems for that language: PHP has PEAR, Ruby has RubyGems and Javascript has jQuery or MooTools. Shared libraries can also include modules for existing software, like WordPress plugins or Drupal modules.

Using shared libraries can also mean that you do less development operations (DevOps) work. Using Bower to include libraries in your application means you can execute a single command to install a library to your codebase rather than find the URL, download the library, unpack it and move it to your codebase. Security updates to shared libraries are as easy as changing the URL from which the library is pulled or changing a version number in your Rails Gemfile or Bower’s component.js file.

Faster Loading

Shared Javascript libraries on a Content Delivery Network (CDN) can mean your digital product loads faster. If you’re a web developer and you use jQuery, jQueryUI, AngularJS, Dojo or other Javascript libraries, there are several CDNs that host copies of many libraries. Google’s list of available libraries is rather limited, but CDNJS and jsDelivr are exhaustive.

The upside of using a Javascript library hosted at a CDN is that a CDN’s main function is to serve your files as fast as possible from the closest server possible using custom DNS configurations and URL patterns. An additional upside is that the browser will be making a request to a different domain. The HTTP 1.1 standard states that browsers should make no more than 2 concurrent connections to the same domain to retrieve assets. Loading assets from another domain can potentially load your site faster, though as Steve Souders points out, most browsers are flouting this standard, anyway.

The downside of using Javascript loaded from a CDN is that you are not in control of what is being served from the CDN. If the CDN goes away or cannot serve your Javascript, your app may be rendered inoperable until you can update it.

On the sustainability side of things, common libraries are often cached in browsers, which means they don’t have to be called from another server at all. They are, in effect, the virtual equivalent of ‘buying local’. For more information on CDNs and sustainability, check out my post Server-Level Sustainability: Green Up Your Hosting.

The Sharing Community

Open source software is based on the principle of sharing knowledge. If you have to solve something with code, chances are that someone else will need to solve the same thing with code too. Consider sharing your solution with the developer community. Read up on how to correctly contribute to your language’s package repository and give back to the community whose work you are already using.

Also, making your code open source is similar to putting it out to hundreds of QA staffers at once. Developers can poke and prod the internals and, if supported, use Git to submit fixes or features for faster inclusion into the codebase.

Shared libraries are not only a great resource for fellow developers in the community, but a practice in sustainability. You are helping people not recreate the wheel and leading to a better development ecosystem for other people, which ultimately enriches the developer community overall.

Digital Carbon Ratings, now in Ecograder.

Understand how your website stacks up against industry carbon averages with this new feature.

Try Ecograder
Mightybytes is a Chicago-based digital agency and Certified B Corporation. Connect with us on LinkedIn or get in touch via our contact form.