Imagine a bacon-wrapped Ferrari. Still not better than our free technical reports.
See all our reports

Microlibraries: the next small thing in software development!

Microlibraries

The Microlibraries Architecture

In computing, microlibraries is a software architecture style in which complex applications are composed of small, independent libraries communicating with each other using language-specific APIs. These libraries are small building blocks, that are tightly coupled and focused on doing a small task well, facilitating a modular approach to system-building.

How did we get here?

The world is becoming more and more modular every day. With the pressure of existing systems to be modularised under the hype of microservices, architects want to compose their system architecture of bite sized modules with well defined edges. The microservices architecture is the first software architecture style that has begun to make use of microlibraries.

Microlibraries Philosophy

The philosophy of the microlibraries architecture is similar to the Unix philosophy of “Do one thing and do it well”. It is described as follows

The libraries are small – fine-grained to perform a single function, literally.
The organization culture should blindly embrace automation of deployment and testing. This eases the burden on management and operations.

The culture and design principles should embrace failure and faults, similar to anti-fragile systems.
Each library is elastic, resilient, composable, minimal, and complete.

Examples

Microlibraries have particularly taken off in the JavaScript space with some hugely popular microlibraries that have even been hosted on the popular NPM website.

  • isArray — With 18M downloads last month this is the most popular microlibrary on NPM. It provides one function and it really delivers on it. More information at https://www.npmjs.com/package/isarray

  • Left pad — With over 2M downloads last month this is another great example how a single function has been packaged into a microlibrary. See the examples at https://www.npmjs.com/package/left-pad

  • isPositiveInteger — This is a new, up and coming library with only 86 downloads last month but shows great potential. The author has succeeded in packaging a very important necessity of checking whether a integer (almost every number will do!) is positive. See https://www.npmjs.com/package/is-positive-integer for examples

  • Is-thirteen — This microlibrary is still on github and hasn’t quite made it to npmjs.com yet, but sources say it is going through the review process. Already with hundreds of stars, tens of forks this project enables developer to check if the number is equal to 13.

However until now, this was other people’s problem, mostly affecting JavaScript developers.
But now even the slowly moving world of Java is finally onto this microgoodness. One fantastic microlibrary that anyone should check out is isJRebel.

isJRebela microlibrary available on Github, that is looking for a permanent home in your code. It has the simple task of determining whether or not a String is equal to the String “JRebel”.

It’s extremely simple to make use of microlibraries from your code. Here’s an example in which I invoke my isJRebel microlibrary from a simple microapp that runs on the JVM.

@GrabResolver(name='jitpack', root='https://jitpack.io')
@Grab('com.github.zeroturnaround:isjrebel:-SNAPSHOT')
import org.zeroturnaround.isjrebel.IsJRebel
println "Hello ${IsJRebel.isJRebel('JRebel') ? 'mad-mad' : ''} world"

If you tend to support the myth that Java is verbose, you might think this is a revolution! Well, in fact, the code above is actually a Groovy example. However, it is a working app, and you can save this snippet into a file, say, isJRebelTest.groovy and execute: groovy isJRebelTest.groovy to check if the world has truly gone mad.

isJRebelLogo

Even now isJRebel has fairly advanced functional capabilities! It is aware of the common practices of including typos, l33t slang, and even can perform a case insensitive comparison. On top of that, isJRebel follows the best trends of microlibraries and pulls some wonderful dependencies into your code like the Apache commons library. Less advanced developers would consider it a massive overkill for such a simplistic task. However, it allows isJRebel to perform the task at hands in a very flexible manner and expands its capabilities to previously unimaginable depth.

Note isJRebel is a microlibrary in active development and the team are accepting contributions to some of the future features enhancements planned. If you want to help, fork the project and send the team a pull request!

Criticism

The microlibraries architecture has been subject to criticism for a number of issues:

  • libraries form information barriers as they are highly coupled
  • the architecture introduces additional complexity and new problems to deal with, such as dependency management with deep transitive dependency version hell, load balancing and fault tolerance
  • testing and deployment are more complicated
  • the complexity of a monolithic application is only shifted into the dependencies, so persists.

Nanoservices

Too-fine-grained microlibraries have been criticized as an anti-pattern, dubbed a nanoservice by Samoot Remor Nomis:

A nanolibrary is an anti-pattern where a library is too fine grained. A nanolibrary is a library whose overhead (project README, logo etc.) outweighs its utility.

Problems include the code overhead (constants being in separate projects), compilation overhead (pulling in the dependencies, network traffic), and fragmented logic (useful functionality not implemented in one place, instead requiring combining many libraries). Many call for the functionality in a nanolibrary to be packaged as part of a microlibrary.

More information

If you’d like to learn more about microlibraries and nanolibraries you can read all the documentation in microbook format, available on Amazon. Whereas traditional books tend to write too much fluff on a topic, bloating out concepts with information on edge cases, microbooks focus on being concise, only talking about key aspects of the subject matter. They achieve this by restricting their physical form to a post-it pad. This ensures authors cannot write too much, forcing them into documenting the key points only. As post-it note pads work well as flipbooks, they can also be used to produce off-line how-to videos, showing you microlibraries in action.

  • Damnit you beat me to this insightful analysis. I had the same impression when I read about leftPad and isArray – this must be a new trend in IT.

    I have to be faster in order to be the first to coin new terms in the future!

  • Abhijith T N

    Guys, you are just too good on normal days and when it is April 1st you are even good than ever. Still remember the ZipRebel of last year reducing everything to 1 bit.

    You beat every satire websites in the world on April 1st. Luckily today is Friday, so can stay relaxed. Good trend in IT with even google joining the fool’s day https://www.youtube.com/watch?v=VkOuShXpoKc&app=desktop

  • Any similar trends happening in SQL world? I’m sure there is more useful stuff in the JavaScript land that one can borrow!

  • Yes, there are a couple of free PL/SQL functions, like the IS_NULL function:


    CREATE OR REPLACE FUNCTION is_null(v NUMBER) RETURNS NUMBER IS
    BEGIN
    RETURN CASE WHEN v IS NULL THEN 1 ELSE 0 END;
    END is_null;

    I’ve found this very useful every now and then, when I didn’t know how to check for NULL

  • This is a SQL microlibrary right there! Now if you could only dynamically load it from your disqus comment to make it really easy to distribute!

  • Heck, excellent idea right there! I could use the PL/SQL HTTP package to download the scriptlet from the internet (https://docs.oracle.com/database/121/ARPLS/u_http.htm), install and compile it with EXECUTE IMMEDIATE, and I’m all set!

  • Oleg Šelajev

    You really want your microlibrary repository to be immutable-ish at least. That’s why disqus comments are a poor choice. Twitter on the other hand doesn’t allow to edit tweets, so it’s a much safer choice. Require from Twitter is already a thing in JavaScript and it can be a thing ins the SQL world.

    * Require from Twitter: https://gist.github.com/rauchg/5b032c2c2166e4e36713

  • Hey, excellent idea! The 140 character limit also enforces the micro paradigm

  • Roy

    We specialize in Clarity Enhanced and Non Enhanced diamonds as well. We provide Large diamonds at HALF the price of Non Enhanced diamonds. Family owned and operated over 40 years. Please contact us for details.
    Xender Download Free
    xender apk download