What is Fuel ? ⛽
- The easiest HTTP networking library for Kotlin/Android by Kittinun Vantasin
- Offers maven and jitpack installation
- Has a wide range of extension modules for every possible tool
httpUrlConnection(No Okhttp support; yet)
- Kotlin- first library
The easiest HTTP networking library for Kotlin/Android. You are looking at the documentation for 2.x.y.. If you are…
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.
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
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.
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.
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.
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.