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.
