5 ms·
Dart actually has a lot of characteristics that make it appealing for a lot of the areas I'd have (begrudgingly) used Go - command-line tools or local utilities
by blandflakes 6y ago
Dart actually has a lot of characteristics that make it appealing for a lot of the areas I'd have (begrudgingly) used Go - command-line tools or local utilities. It "can" be scripted, but also AOT compiles, has a saneish type system with generics, and doesn't have pointers to deal with. It's hard for me to want to use it on the web, but I keep watching it and wishing good things for it.
- vetinari 6y ago> command-line tools or local utilities. FFI is quite a PITA, though. Soomer or later you will have to interface some platform libraries, and Dart doesn't make that easy.
- jamil7 6y ago> FFI is quite a PITA This is what made me nope out of it last time I experimented with a Flutter module in my app. I'm still watching it closely though as it could be a great fit for other projects.
- kjksf 6y agoThis might be outdated opinion (hard to tell without OP explaining what he finds "a PITA"). dart:ffi (https://dart.dev/guides/libraries/c-interop https://dart.dev/guides/libraries/c-interop) is a recent addition to Dart and from where I stand it's a decent FFI system. Maybe not as good as PInvoke in C# or ffi in luajit but better than, say, jni in Java (and any other FFI system that requires you to write glue code in C i.e. python, ruby, nodejs).
- malkia 6y agogood thing to have in an FFI system is ability from one language to call another from callback, and back and forth (if it need to). I believe Dart allows for that. That to be said, stack walking is going to be painful to decode (probably), best I've seen is C#/C++ on Windows - where it flows naturally from one to another.
- jamil7 6y agoThanks good to know, my experience was most likely outdated as well.
- timsneath 6y agoCurious what platforms you're interested in integrating with. We're experimenting here and looking for feedback. As a fun demonstration of the effectiveness of FFI, you can now build Petzold-style native Windows code with Dart: https://github.com/timsneath/win32/blob/master/example/hello.dart https://github.com/timsneath/win32/blob/master/example/hello... And here's a 500-line version of the Kilo console text editor built with Dart: https://github.com/timsneath/dart_console/blob/master/example/kilo.dart https://github.com/timsneath/dart_console/blob/master/exampl... Unlike the original, it runs on both Windows and UNIX-based operating systems.
- vetinari 6y agoI'm actually more interested in Linux side of things. That doesn't prevent me from looking how things are done on Windows, of course. To be fair, last time I looked into dart, the idea of FFI was ports, which was too overcomplicated and undercapable, if you needed something like Gtk or Vulkan. Looking into it now, I see the dart:ffi package is shaping up nicely, so I will have another look at dart again.
- malkia 6y agoTim, it should be possible that the main .exe (or binary on linux/osx) to export functions, and they can be found back through the flutter_engine.dll/.so, right? (At least on windows it's possible for the exe to __declspec(dllexport) things, not sure on Linux). But even if not, if there is a way to (given might be slow and tedious) to compile what would've been flutter_engine.dll statically linked to your main (host) app, and maybe somewhat hinting here is how to find the "GetProcAddr/dlsym/etc." functions - if one is to look for them. Further on, the generated from dart .so file can be embded (as resource? or slapped at the end of the binary/.exe?) + slapping all other resource - resulting in single app :) I know it's possible, just not so easy to support it (I guess). It's similar to have java/python can be packed into one executable with all C/C++ ffi functions they call (at cost of some build time and effort to achieve so). Then you'll have killer platform for video conferencing (zoom, bluejeans, etc.), messaging (slack, etc.) - and just single binary to deploy. (Oh, on top of that slap a web server into it, and make it that if called with specific command-line option, now it acts as web-server, and the app is visible through the web).
- wstrange 6y agoDart produces surprisingly small docker images for server code. I recently created small Cloud Run web service with Dart - the docker image is 5.2MB compressed, 12.9 MB as reported by docker. I'm not even sure Go would do better on image size. Tree shaking does wonders here.
- deleted 6y ago[deleted]