How is Golang so far ahead in some areas

In my job, I switch between using Golang and Dart/Flutter, and I would love to use Dart all the time. However, I run into limitations in Dart that are easily solved when I use Golang instead. For example:

  • Embedded systems and cross-compilation. We build applications for embedded systems, Linux, and bare metal. I can sit on my Mac and compile for Embedded Linux instead of transferring the code to the device and compiling it there.
    There’s even TinyGo for building firmware for chips that lack a modern operating system.

  • Networking. A simple thing like ARP scanning can’t be done in Dart. In Golang, it’s just another Tuesday. And not to mention HTTP/2 like you’d expect from a mature SDK from a company like Google :man_shrugging:.

These are small examples, but I run into things like this quite often where I realize that using Dart alone isn’t feasible without calling C code via FFI or similar workarounds.
I’ve even considered writing parts of the code in Go and calling it from Dart.

Sometimes it feels like the team behind Golang has infinite resources. And the community makes it shine even more with quality libraries like go.bug.st/serial.

I might be working in a niche sector, but I keep hitting these limits with Dart all the time, and it saddens me.

Maybe Golang is more suited for the things you need. I can imagine there’s a separate list of everything the Dart and Flutter ecosystem is better at than Golang. No one language can beat them all… optimizing for one thing is pessimizing for another and there’s no way around that.

2 Likes

THIS GUY USED GO WHILE I SPECIFICALLY SAID HIM TO USE DART!

It’s so annoying when some guy points a gun to our chest and force us to use the wrong tool for the job… It saddens me.

Golang is more suited for the things you need

For some things there is no way around that, unfortunately. Dart is of course also more suited for the GUIs I need to build.

I’m maybe just surprised that Dart has managed to get so far without implementing some things.

Perhaps Golang, in it’s architecture and stack, is easier to add features to?

Like?
Just Curious

Other than go routines, what are some major language features it has that dart doesnt

Most pressing one for me: cross compilation.
Flutter seem to have bolted this on somehow, in a way that Dart does not officially support. That means that it has never been supported, or even thought of from a language perspective, which surprises me.
I guess AOT was a quick fix for Flutter, and Flutter handled x-compilation itself.

Another one off the top of my head, file embedding: embed package - embed - Go Packages
Not super important, but useful for many.

Good point, Seems like this will be resolved this year

That’s assets. O.o

Future<String> loadAsset() async {
  return await rootBundle.loadString('assets/config.json');
}

Does that work with Dart command line applications?

From what I understand of both languages, there’s a little difference in how it works.

Bundled assets, after compilation still exists as independent files. The binary knows where to look for them and what to do with the file. But that file exists as a whole.

Go’s embed lets you make the file part of the binary (and it probably is able to be smart during compilation and remove the bytes that aren’t needed). So the file no longer exists as an independent file in the compiled output

Dart on compilation makes a binary, flutter on the other hand isn’t just a binary and has these metadata files including assets in the final output

It’s under active development here: native/pkgs/native_assets_cli at main · dart-lang/native · GitHub

This example seems to show exactly what you’re describing if you want to see how it looks in Dart specifically: native/pkgs/native_assets_cli/example/build/local_asset at main · dart-lang/native · GitHub

You might also be interested in this as a way to reuse your existing go code to help close come of those gaps you mentioned too: flutter-go-bridge/native_toolchain_go at master · csnewman/flutter-go-bridge · GitHub

1 Like