treeform / genny

Generate a shared library and bindings for many languages.
MIT License
224 stars 9 forks source link

Add Dart support. #20

Open UNIcodeX opened 3 years ago

UNIcodeX commented 3 years ago

Awesome project!

Adding generation of Flutter / Dart bindings could be useful for both increasing adoption of Nim and building more performant libraries for the cross platform UI library, Flutter.

treeform commented 3 years ago

We will probably be adding new languages based on popularity and our personal experience with them. It will be a while before we get to Dart as its not as popular and we have not used it before.

juancarlospaco commented 3 years ago

But... I understand that the Flutter actually has a C API ?.

UNIcodeX commented 3 years ago

@treeform I understand and appreciate the work you are doing.

Flutter does have a C API. I work with Python, Nim, and Flutter / Dart but I don't have much experience with C / C++ or glueing them together with other languages using their FFI APIs.

I opened the topic of adding support for Dart because the maintainer does have experience with these languages and interoperability therein, and Dart has a C API.

Dart's pub.dev is a fairly large repository of libraries and if more and more of them popped up using Nim, then that would be a great plus to the Nim community. Especially when coupled with the cross platform capabilites of Nim, since Flutter recently added support for desktop, bringing their platform support to include mobile (iOS and Android), desktop (Windows, Linux, Mac), and web targets; enabling a write-once-deploy-everywhere with minimal platform specific bits. It would mesh well with Nim's flexibility and strong typing.

Instead of having to write a Dart plugin in Swift for Apple, and C (or Java) for Android, and C for desktop, and JS for web, one could write the plugin once in Nim and have this utility output to ObjC, C, JS, WASM, etc... automatically.

juancarlospaco commented 3 years ago

Then maybe Nim can interop with Flutter using the C API ?, probably the best performance too...

treeform commented 3 years ago

I think you want a different reverse-genny that goes dart->nim, but genny only will go nim->dart?

Then you can use reverse-genny to wrap dart's flutter and use it in nim. But thats not what this genny does.

If you had a nim library like pixie, vmath or puppy or what ever and you want to expose that to dart, that is why you would use genny to expose that to dart.

genny would never be able to wrap a library like flutter.

kobi2187 commented 2 years ago

Hi treeform, very nice lib (looking at the python output), I have recently discovered Flutter over dart language, they create a nice vibrant UI experience. BUT:

its ffi lib is just so ugly, shudders! it's ffi interop is very verbose and looks annoying to get done, at the same time, devs seem to flock to this (relatively) new platform but not many want to get hands dirty in C code, so Nim to the rescue right?

Can genny also support the dart programming language? it's just generating a lot of ugly boilerplate code.

I think it's a chance to get more people to use Nim, and thereby building more libs and contributing to it, which was one of your purposes with genny.

Aside from that, I personally want to leverage Nim libraries that i and others have written, and use dart and flutter mainly for the GUI story (though in terms of features, dart looks to be a decent language. unfortunately for dart, in terms of syntax - verbose like java and I think no templates, but this is just first impressions.)

treeform commented 2 years ago

@kobi2187, I answered you in this issue: https://github.com/treeform/pixie-python/issues/15

kobi2187 commented 2 years ago

Sorry, I accidentally posted there! WRT dart ffi - I see a possible tool here: https://pub.dev/packages/ffigen you can see how verbose it is...

kobi2187 commented 2 years ago

Hi @treeform I am interested in adding support. How do I get started with genny? in particular, I assume there is a tree, from which I generate to the target language? I would like to add dart support. (as much as Dart supports it)