On Dart

When developing a small command-line app, I’ve tried to develop it in Dart, to get the feel of the language and its ecosystem. I liked Dart quite much - it’s very close to Kotlin in focusing on usability and producing readable code, and not bringing every fancy feature just because. The library ecosystem is also very rich, you can find library for anything. The library may be 0.0.2 created by some unknown dude, but it will work.

Dart is also WORA - you only test the library/app on one platform, then compile with Dart to any native target and don’t have to worry about portability. Non-web Dart ints are always 64bit which is simple.

I don’t really need threading and the event/async model is more than enough for my needs; however I have access to other Isolates should I need it. There’s no unified API for databases like JDBC in Dart unfortunately, but that’s not a problem since there are clients for PostgreSQL and other databases as well. I’m loving Dart the language as well - it comes from the place of simplicity but offers much of the functionality. My personal highlight - Dart testing system offers the same group{}/test{} mechanism as DynaTest. I also kind of like the idea of the event loop keeping the main() thread alive until there are no further events to process - this quite simplifies the periodically executed actions from the main() thread.

That being said, even on a small project, dart bin/renogy_client takes 4 seconds to start, which is just crazy (compared to 1-second JVM startup). It takes 21 seconds to dart compile exe bin/renogy_client.dart on my AMD Ryzen 7 PRO 4750U, and at least 2 minutes on Raspberry PI (dart compile can not cross-compile and must be run on the target platform). The native binary then consumes 25-50mb of memory, which is somewhat to a running JVM. Therefore, Dart doesn’t seem to offer many advantages, except perhaps for the instantaneous startup time of the precompiled binary.

Written on April 14, 2023