simolus3 / zap

Zap is a fast web framework built on Dart
https://simonbinder.eu/zap/
MIT License
239 stars 12 forks source link

Thoughts on a Flutter-like alternative? #17

Closed venkatd closed 2 years ago

venkatd commented 2 years ago

Hi there!

Have you considered a Flutter-esque syntax rather than templates that resemble svelte?

For example:

class MyInput extends StatelessWidget
{
  MyInput({this.onClick});

  final void Function()? onClick;

  @override
  Widget build(BuildContext context) {
    return Input(className: "my-input", onClick: onClick)
  }
}

In this case MyInput would be equivalent to a React component and we'd return a mix of our own instances of widgets and built-in html elements.

And StatelessWidget, BuildContext, and so on would be implemented from scratch but happen to have the same name.

There are some benefits I see:

I'm sure you've already weighed the options, but was curious to hear your thoughts!

We'd potentially be interested in sponsoring something for zap like this if there is interest.

simolus3 commented 2 years ago

Thanks for starting this discussion!

The teams that have Flutter apps don't have to understand a completely different paradigm if they are required to build a web-app but want to reuse some Dart business logic from the Flutter app

To be fair, if you want a Flutter-like experience for the web, Flutter web is probably the best thing you can get :D To me, it seems like valid reasons for not using Flutter web (like loading time and bundle size) are a direct consequence of all the convenience features Flutter provides. There's not going to be a Flutter-like framework without any of the costs, even if it's a closer wrapper around the DOM than Flutter.

We can lean on our code editors to help with autocomplete, refactoring, etc

That's true. I've considered working on an analyzer plugin to bring some of that to zap but it won't be as good as a pure-Dart framework.

The implementation effort may be lower -- you won't have to create a templating language, a compilation step, or any of that.

Fair enough, but I already did do all of these things :smile:

I think zap will continue to go in the direction of having a smart compiler to figure things out. Packages like wupper or jaspr are closer to what you probably had in mind already. Maybe those are interesting for you?

venkatd commented 2 years ago

To be fair, if you want a Flutter-like experience for the web, Flutter web is probably the best thing you can get :D

I should clarify that 90% of our code is already written in Flutter web.

There is a small percentage (say 10%) of our features that are much better suited as a pure web apps. For example: content-heavy UIs that need to load quickly on mobile browsers. In this cases, we don't want to use Flutter but we want to reuse a bunch of our Dart code (websocket management, auth, auto-completion, api access, etc)

I think zap will continue to go in the direction of having a smart compiler to figure things out. Packages like wupper or jaspr are closer to what you probably had in mind already. Maybe those are interesting for you?

I wasn't aware of wupper and jaspr. Thanks for sharing!