To me, the biggest issue is reusability with both native code and ports. I agree 100% with the native code decision, but I think there’s a big problem with regard to certain web platform APIs that aren’t yet wrapped that require javascript currently.
The one I’ve been working on is the Media API. Just to do play, pause, load, etc, requires javascript currently. And to do more complicated things, like canPlayType or decode TimeRanges also requires javascript.
If you’re using the media API to write something like a podcast player, that’s fine. But the media API is used extremely widely on the internet, yet most web developers never touch it. The reason is that people who specialize in it, like myself, write reusable media players that they plug into their applications or pages.
This is a great use case for a reusable view, and in fact, I’ve written a prototype media API wrapper and a reusable view player (Shameless plug: here and here). I want people to be able to grab a reusable view audio or video player, and use it in their applications. My dream is for Elm-town’s website, for instance, to use my library to show us the audio.
Wiring up the number of ports required for a basic player would be pretty tedious. Doing it for one that supported more advanced features, especially media source extensions, tedious and difficult.
I don’t think Media API is alone in this. What about a reusable view Color Picker that requires canvas? I don’t much about FileReader and LocalStorage, but that’s the one I hear all the time. I’m sure others can think of other examples of reusable views that would be really wonderful to have, but require native/ports and some level of expertise. How about a Midi player written in Web Audio? (WHICH WOULD BE AWESOME)
I think this would be much less of a problem if more of the web platform were already wrapped. And some of the API’s that aren’t already wrapped lend themselves well to ports…that is, they don’t really tend to be reused. I think storage falls into this category, but I’m not sure.
But there’s another aspect to it that I think is causing a lot of the hurt feelings and strong opinions over this, which is that blocking native code without wrapping the whole web platform first creates winners and losers…that is, it advantages some use cases and disadvantages others.
Obviously we’re all using HTML, but from my perspective as a media specialist, it’s absolutely crazy that WebGL, which is not a widely used API from my perspective is wrapped, but localStorage and Media aren’t. I’m sure if I were a game developer I would feel differently. I love that SVG is wrapped, but I’m sure many never touch it, and would rather have web audio or canvas completed.
Ableton was one of the biggest companies doing elm stuff, for a while, am I wrong? I’m sure they needed to do web audio through ports, and that worked fine for them. But imagine how much better it would be for all of us if they had been able to refactor some of what they were doing into reusable packages on the elm-package?
I’m going to spend part of my day refactoring what I’ve done with Elm-Media into a package that uses ports, to help someone who specifically requested an easy to use audio player on slack. It’s still going to be complex for him to set up, as he needs to edit the package to use ports and also add the ports on the javascript side. I’m honestly not sure it’s feasibly achievable yet.