Quick thoughts on the Dart language.

This repository holds the code for an OpenFaaS function I built using the Dart language. I think Dart has a ton of potential, but sadly it has some things that I consider big problems that have prevented me from using it in production:

  1. JSON serialization and deserialization is hard and I've been completely unable to get it to work with both first-party packages and third-party packages. The Dart devs tell you to add a toJson function that maps properties to JSON prop names for every class you want to serialize. Not only is that error prone, it creates a ton of boilerplate. One of the primary goals of Dart is to run in the browser as an alternative to JavaScript, so it baffles me that they've chosen to keep JSON interop such a difficult thing to do. This is honestly the only showstopper I've had for working with Dart. It completely stopped my application development dead in its tracks and I strongly urge the Dart team to make JSON much easier to work with for the sake of the language and the devs using it.
  2. Nullables and mutability, yuck! Okay, this is pretty petty and isn't really a knock against the language -- and I know most languages (even the ones that I really love like C# and TypeScript) have nullables -- but after working in functional languages like F# it just feels icky to never be 100% sure that a value hasn't changed or isn't null.
  3. POSTing some data to a URL with the built in HttpClient is surprisingly unintuitive. I spent a good 45 minutes debugging why a server I was posting JSON to was telling me it received malformed data. Turns out the default HttpClient opens a stream to the URL and then posts data, but the server I was posting to wasn't expecting a continuous stream, it wanted the data right meow. I worked around this by moving to the http package built by the Dart team.
  4. There's no easy way to format a DateTime string without installing the intl package from pub. Again, petty and not a real knock against the language since you can quickly get this functionality by installing that package, but coming from dotnet and even JavaScript it's weird that there's no built-in way to format a DateTime string.

That said, I really enjoyed working with Dart and if it were easier to work with JSON -- almost all the apps I build use JSON APIs -- I'd probably use it a lot more in production. Some of the good things it has going for it:

  1. It works not only on the browser, and the server thanks to Dart VM, it also runs on mobile with Flutter! Server + browser support for a language is like my Holy Grail, so adding mobile in there too makes for a language that I really really really want to use.
  2. Dart has a pretty boring, Java/C#-y syntax (which can certainly be a good thing when you just want to get things done) but the cascade notation is really neat. I'm surprised that I don't see it in other languages; F# comes to mind as one that could really benefit from it.
  3. I touched on this in the first point, but I think it's really neat that Dart compiles to JavaScript in the browser but runs natively on the server in its own VM. Running a server app is as simple as dart file.dart.
  4. The tooling is surprisingly good. Since Dart is a language backed largely by Google I was expecting it to really only work well in Android Studio. Turns out there's a Dart plugin for many popular editors! I used the plugin for VS Code and the performance is top notch, far faster than the tooling I'm used to with F# where I often find myself waiting for 5+ seconds to get intellisense suggestions or error warnings.

Learn how to build rock solid Shopify apps with C# and ASP.NET!

Did you enjoy this article? I wrote a premium course for C# and ASP.NET developers, and it's all about building rock-solid Shopify apps from day one.

Enter your email here and I'll send you a free sample from The Shopify Development Handbook. It'll help you get started with integrating your users' Shopify stores and charging them with the Shopify billing API.

We won't send you spam. Unsubscribe at any time.