Basically, this question is more like food for thought.
I've been thinking of create a webview-based app (in order to be portable, one code base and all that) but do it in nim.
Of course, I know about Electron but it seems to me to bloated (plus, why add Node.js when I don't need it).
I've also had a look at Flutter. I'm not really sure how mature it is, but it does look interest. However, again, too bloated. (It took me 1 day only to get it installed on mac Os Catalina, and the files seem all over the place. Plus, Dart? Really?)
So... The idea is:
How would I go about that?
Check this repository: https://github.com/juancarlospaco/webgui
have a small PoC here where I use it for scientific charts:
The main issue with webview is that you don't have access to any filesystem operation (like saving or loading a file).
If it's any help, oskca/webview wasn't working for me witht he new version of webview. So I made some changes in a fork.
https://github.com/francisl/webview https://github.com/oskca/webview/pull/17
It doesn't have all the features of the original repo, but at least you can get going.
This is a great start, imo, to have something similar to electron. Even better, because you don't have to package a whole browser with your app. The drawback is that it can render differently on each OSes.
For mobile apps there's Cordova aka PhoneGap. It’s a packaging layer that wraps your web-based app in a native (iOS or Android) web view. I don’t know if it supports desktop apps though.
I agree about Electron being, um, sub-optimal. I hate the idea of each app carrying an entire Chromium browser with it.
It works like React that implemented on Nim side.
OK, that really got my attention. I’ve been wanting to build a great social/collaboration app for a long time (with a distributed/p2p back end.) It makes sense to use a web view as the primary UI since it involves lots of text & multimedia layout, but I really don’t want to implement the code as JS (or even Nim compiled to JS.) So this idea sounds great.
It sounds like this isn’t available in Nim, though, just Elixir? And implementing all the DOM-diffing and updating sounds challenging. Hmm.
(Incidentally, “like React but with native views” is exactly what Apple's new-ish SwiftUI framework is. You describe the UI declaratively in Swift, and it builds it out of UIKit or AppKit views. I’ve been learning it recently and really enjoying it.)
It sounds like this isn’t available in Nim, though, just Elixir? And implementing all the DOM-diffing and updating sounds challenging. Hmm.
Yes the LiveView is implementation of this concept in Elixir.
I don't think it will be too complicated to implement. Following things need to be implemented.
There are 2 things that make it easier:
I'm going to try to implement this approach in ~6 months, as I'm going to need to write some UI. It should take 1-2 weeks of full time work.
P.S.
I would say it would be beneficial to read how React.JS works and maybe built simple Todo app with it (React.JS TodoMVC is a good example).
You describe the UI declaratively in Swift, and it builds it out of UIKit or AppKit views
This approach goes one step further. It not only builds the initial version of UI, but also magically updates it when you update the model. I don't know if Swift UI also does that.
We can immediately rule out magical native reactivity as it's too hard to implement. Publish/Observe is very performance efficient but (at least in my understanding) requires more code to write than should be. I personally think that optimised brute-force way how React.JS works is most balanced way it's easy to implement and requires less code to write and has good enough performance something like (I may be wrong but seems it should be like that) O(log n) where n is the size of the component tree.