Ports for everything?

(This follows up on the native code and Elm 0.19 thread that got redacted.)

The common response whenever native code issues come up is “use ports”. My question is: If ports are a great way to structure programs could we get rid of all of the effects managers — e.g., HTTP — in favor of writing it all with ports and would that make for better programs? (I’ll assume here that there is a standard distribution implementation for various ports.) For example, a port-based HTTP interface would presumably have a command port to send an HTTP request and then a subscription port that would deliver all HTTP responses. Or am I missing something about ports?

Mark

1 Like

Ports are for JS interop.

I don’t think using them for structuring programs is a good idea! I’d just stick to using them for JS interop.

Point taken. Let me rephrase that as “a great way to interact with JavaScript services other than the DOM”. An example of such a service would be HTTP requests. Why doesn’t Elm use a ports-style interface for HTTP?

I can imagine all sorts of answers ranging from some demonstration of how it would actually have been a great way for Elm to handle HTTP — that would be a convincing argument for ports as THE answer for interop — to some sort of argument that ports are indeed awkward but they are also conceptually simple and easy to firewall — to a variation on the foregoing that shows some inclination to make ports less awkward in the future. Or maybe there’s an argument that HTTP and the other things currently exposed through effects managers are unique. Or maybe there’s an answer here I haven’t thought of.

I’m looking for something that breaks the cycle of “just use ports”, “ports are awkward”, “what’s wrong with them”, “…”, “you’re using them wrong”, “but I’m trying to interface with JavaScript services the way other commands and subscriptions do”, “just use ports”, etc

Mark

Mark, I see your posts very often. I would characterize them as “I disagree, and I want you to know why.” Generally independent of anyone else’s goals in the conversation.

We disagree about (1) how interop should work and (2) the timeline for having more Elm packages for web platform. This is not new ground. I’m sure you’ve read (and participated) in many of the past discussions of this exact topic. If the “Learn” tag on this post was your genuine goal, I struggle to see how it has not happened already.

Anyway, it is Saturday. I want folks like Richard to have a nice time with his SO or go to a park or have any sort of joyful time with friends and family. You and I disagree about language design. We probably disagree about loads of things! We do not have to reverify that every single week.

If you really want to “Learn” about some specific thing, great! Folks here can help with specific issues. If you want to just tell people how you feel, there is no a clear category for that on purpose. I hope the root thing I’m trying to say here in a moderator capacity is clear.

4 Likes