Dart Frog: A Frontend Language Moves to the Backend
Dart is best known for its use in Flutter and its deployment in mobile apps, but a new framework called Dart Frog allows developers to leverage Dart on the backend. It’s the creation of Very Good Ventures, a consulting firm that specializes in Flutter applications. VGV is best known for the Hamilton app — yes, the musical — which was one of the first commercial apps built with Flutter outside of Google.
Ultimately, problems at the backend can impact a mobile app, so it’s important that developers manage the backend as well as the frontend, said Felix Angelov, a former principal engineer at VGV (Angelov recently left to help found Shorebird Development).
“If you have a really slow backend or a backend that’s not well documented, developers struggle [with] interfacing with that backend, it does ruin the user experience or it reflects in the end product that you ship,” Angelov told The New Stack. “Dart Frog was our way of exploring, can we basically use the exact same programming language and technology stack that we use to build mobile applications — with Flutter on the backend.”
Why Dart for the Backend?
Dart is a versatile language, optimized to create fast apps on any platform. Google already uses Dart on the backend: its package manager, pub.dev, which allows developers to upload packages that can be pulled into projects, is built in Dart on the backend, Angelov said. The problem with broader use in the backend is that the tooling just “wasn’t there,” he said.
“It’s not that the language wasn’t capable. It was just that there wasn’t enough tooling and abstraction on top of all the low-level components to make it more appealing for people,” Angelov said.
“Dart is really cool because it’s really a flexible language that can be used for many, many targets, which I think is what makes it special,” Angelov said.
Additionally, as Flutter grows in popularity, there will be more developers who want to use Dart on the backend, he said.
Dart Frog: Frontend Moves to Backend
Dart Frog is still in its infancy. Although the open source framework is stable now, according to Angelov, the team at VGV is working towards a 1.0 release sometime this year, but aiming for the third quarter. VGV has a roadmap of features it wants to add as part of the V1.0 release. The goal is to make the developer experience as simple as possible and keep the framework lightweight, Angelov said. That’s how he differentiated Dart Frog from offerings such as ServerPod, which is an open source, scalable app server that can be used to build APIs in Dart. ServerPod incorporates Redis for caching, Postgres for a database, and migration support for “all kinds of stuff that you may or may not need,” Angelov said.
“Whereas our philosophy with Dart Frog has been: here’s a really simple core, a set of functionality that everyone will need no matter what, and then we’re developing separate modules for things that you may want to add on later on,” he said. “Dark Frog is mainly just, how can I quickly create endpoints really fast with Dart and then some other utilities for developers that make it easy to have your code be testable, giving you hot reload.”
Hot reloading is one of the most popular features of Flutter. It ensures that any changes made are updated in real time. That’s important for teams working collaboratively on an app.
Dart Frog also makes it easy for developers to deploy an API in the cloud to talk to a frontend application, Angelov said.
“You can basically, in a matter of a few minutes, generate a new Dart Frog project, define a couple of endpoints that a frontend application can communicate with, and then deploy it” he told The New Stack. “We have some deployment guides for existing popular cloud providers like Google Cloud, AWS, or Digital Ocean.”
One way VGV has used Dart Frog is to integrate with legacy systems that were developed and/or are maintained by a client company. This approach allows companies to also phase out legacy systems without having to break the frontend, which can be a real problem. When Angelov worked at BMW, they migrated to Flutter and as part of the migration, they had to redo APIs.
“If we use something like Dart Frog, we can create the mobile application and then we can create a backend for [the] frontends layer, like a middleware layer, that then communicates to the legacy systems and then we can do all kinds of things like optimizations [and] caching,” Angelov said. “We have full control over basically the communication channels between the mobile app and the backend. The frontend doesn’t know — it’s all just like hidden behind a black box — and doesn’t care about the implementation details of the legacy APIs.”
Ultimately, Dart Frog could deploy a proxy, like “middleware that normalizes and does some transformation of the data,” he said. Such a layer will also support a lot of other optimizations, he added. VGV uses this approach because often clients won’t allow the consultancy access to change legacy systems, which would require large scale changes and high risk.
“By having this pattern, where you put in this middleware that sits in-between the client and the legacy systems, it gives us a lot more control as developers and it allows us to share a lot of code between the frontend and the backend,” he said. “Then we don’t have to push new releases to the App Store every time we make changes to the legacy systems. We can just fix those changes in the middleware. And the client doesn’t really care at the end of the day — as long as we maintain the same contract, everyone’s happy.”
“That’s really one of the biggest benefits, is allowing our developers to be in control of that contract,” he added.
Additionally, Dart Frog will generate a Docker file that can be deployed anywhere that supports containers, he said.
Coming Soon to Dart Frog
There are plans to support more clouds, with requests coming in specifically for Heroku and Vercel. One option that’s being bandied about is adding a deploy command to make it easier to deploy to whichever cloud provider a user wants.
“That’s kind of the point where there’s the most friction right now. Not everyone knows how Docker works and not everyone knows how to upload a Docker container to Google Cloud,” he said. “So there’s potentially a lot of room to optimize the deployment process and just make it a one-click or one command to deploy to some of these cloud providers.”
One of the things VGV wants to do is provide tools directly for IDEs, such as Visual Studio Code and Android Studio.
“We want to provide tools directly from your IDE, where you can create a new endpoint in Dart Frog, or you can attach the debugger straight from your IDE, or you can generate a new project right from your IDE,” he said. “You don’t have to open a new terminal and run some commands or whatever.”
Dart Frog is MIT-licensed, and Angelov encouraged others to try it ahead of the v1.0 release.
“That’s kind of been our goal: lightweight fast and modular so you can add whatever you need,” he said. “We try to take care of as much of the complexity for you with Dart Frog and give you try to give you as similar a developer experience to Flutter as possible. All the goodies that you get with Flutter — like debugging, dev tools, all the stuff that Flutter offers — we tried to provide the same thing with Dart Frog.”