To my understanding there is no promotion of the web components as a
standard way of interacting with JS.
They are mentioned as a way of encapsulating complex JS that might fail.
In other words, one could use some complex widget (like google-maps) and
get some functionality into their elm app *fully aware* of the risks
involved.

1. Type safety:

There is none with web components BUT, you do get a nice border control and
black-box encapsulation from the perspective of Elm.
It very similar to using ports only that from my perspective, the
interaction is nicer.

2) Purity guarantees

You will be able to use a web component ONLY in the view will be as pure as
it is right now.
You will not be able to interrogate the web component, you will have to
subscribe to its events just like you subscribe to onClick on a button.
This is very different from Native that you can use all over the place.

3) Versioning guarantees

web components are not part of the Elm ecosystem and so, they are not and
will never be covered by elm-package. Maybe after we get the ability to
describe web-components in pure Elm, you will be able to find
web-components in elm-package.

So if the main motivation for discouraging the use of native is to promote
> safety, why encourage the use of web components?


Again, I don't think that the use of web components is encouraged.
They are only an escape hatch that is available to Elm programmers.

These being said, I do believe that the mechanism of web-components has a
lot to offer to Elm.

I have played with some prototypes and the experience of writing
web-components in Elm is quite lovely.
In an ideal world, we don't use <google-map> in Elm but rather <google-map>
becomes an Elm implemented web-component.
The web-component standard could be the official way to embed and interact
with Elm apps.






On Thu, Mar 23, 2017 at 1:57 AM, Maxwell Gurewitz <[email protected]>
wrote:

> Hi all.  I'm creating this thread to discuss the relative merits of web
> components and native code.
>
> It's my perception that web components are being promoted within the elm
> community as a standard means of javascript interop, while writing native
> code is discouraged.  In particular, Richard Feldman has recently added a
> section on web components to his book Elm in Action (great book btw, you
> should totally buy it!), and I'd love to get his feedback.
>
> I don't understand this preference for web components over native code.
> As far as I can tell web components and native code lack all of the same
> safety guarantees.
>
> 1) Type safety:
>
> Both native code, and js inside of custom web components have the
> potential to raise exceptions, or produce invalid results due to a lack of
> type safety.
>
> 2) Non-determinacy:
>
> Both native code and js inside of custom web components have the potential
> to introduce non-determinacy.  You can imagine that the google maps web
> component might receive a 500 status response from google during an outage,
> or the author of the component might simply include a Math.random.  This
> will violate the guarantees made by the elm-debugger which disables port
> code from running for exactly this reason, which could prevent you from
> being able to reliable replay UI interactions.
>
> 3) Versioning guarantees:
>
> Neither native code nor web components can be published in elm-package,
> and they both include javascript, so neither can benefit from elm's semver
> enforcement.
>
> Now I understand that web components may be more ergonomic than equivalent
> native code in certain situations e.g. in the google maps case, but they
> don't seem any more or less safe than native code.  Furthermore, they
> impose the cost of an additional build system (bower) and polyfills.
>
> So if the main motivation for discouraging the use of native is to promote
> safety, why encourage the use of web components?
>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to