Is Fuel an Alternative for Retrofit?

Alfred
Alfred
Sep 11, 2020 · 4 min read

Fuel is not an alternative for Retrofit because both the libraries offer a different experience for developers. Retrofit is currently the market standard so let us look into Fuel.

Android Network profiler
Android Network profiler

What is Fuel ? ⛽

  • The easiest HTTP networking library for Kotlin/Android by Kittinun Vantasin

Is Fuel a 🆕 Library in the market ?

I had a quick look at the release tags in Github and the first tag 0.6 was dated 11 Aug 2015. Its been around for quite some time now. With the domination of Retrofit and Volley, it’s quite a struggle for Fuel to stand out

Retofit tag 0.6.0RC1 — 31 Aug 2013

Lets talk Fuel

Fuel is built to be kotlin-esque. Fuel tries to fill in a different role which is to be the easiest or the most kotlin-esque to the project that already Kotlin as the main language.

“We used to care on how the usage on the Java would be that that is no longer because we know entirely that if the Java users want to depend on the networking library, there are much better choices than us out there to use (and we don’t try to compete that)” — Vantasin

Fuel aims to be on the easy-to-use side but not on the fast side. They believe that Fuel will not win a race of performance but at the same time, it will not be a bottleneck in the application.

Making Requests

Fuel provides a String extension to make a request. In addition and as an alternative, we can use the Fuel class that has a method for each HTTP verb.

Fuel supports all HTTP verbs except for PATCH. It’s obvious as Fuel’s HttpClient is a wrapper over HttpUrlConnection which doesn’t support PATCH.

The extensions and functions in the core package

Fuel supported functions and extensions
Fuel supported functions and extensions
Fuel supported functions and extensions

Configuration

FuelManager.instance is the singleton object used by Fuel to manage global configuration. This makes it possible to configure a base path, headers, common params and interceptors.

Code Complexity

Retrofit is easy to understand but Fuel is simpler. Check out their documentation for a better understanding.

Is Fuel better than Retrofit ?

Definition by the creators:
Retrofit:
A type-safe HTTP client for Android and Java.
Fuel: The easiest HTTP networking library for Kotlin/Android.
By definition, Fuel is Kotlin first and they offer a different experience.

Making an apple to apple comparison between Retrofit and Fuel is out of the question. Fuel clearly states that they don’t wish to compete with any of the other libraries out there.

We don’t have to compare something which does not want to be compared.
I would say comparing Fuel with Retrofit is like comparing a Polaroid camera with a Professional camera. They both give us different experiences, even though both are used for photography.

Similarly, Fuel and Retrofit have different objectives. Fuel clearly mentions that it does not benchmark any stats for comparisons. They are clear in their objectives.

Worthy Mention

The Result from kittinunf is a functional style data structure that represents data that contains result of Success or Failure but not both. It represents the result of an action that can be success (with result) or error.

Working with result is easy. You could fold, destructure as because it is just a data class or do a simple when checking whether it is Success or Failure.

TL;DR

Fuel networking library is not a game-changer and not a competitor to Retrofit. Fuel believes that it can do the best on the goal that they aim and provide something different in the market for developers to use. It’s up to us to try it out and evaluate what works best for our use case.

Personal Note: ✍️
I started using Fuel in a small project to check what it has to offer. It was easy to get started. It was almost zero learning curve for someone who loves Kotlin and Functional programming.

The Startup

Medium's largest active publication, followed by +771K people. Follow to join our community.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store