On Thursday, December 8, 2016 at 5:27:53 PM UTC, Vojtěch Král wrote: > > This resonates with me very much. This is _exactly_ the reason why I made > The Elm Alienation post on Reddit: > https://www.reddit.com/r/elm/comments/5g3540/the_elm_alienation/ >
If I can quote from that: "In a nutshell, Elm needs unsafe." I mostly agree with this, but have some reservations. The existing native API is easy enough to figure out, just look at any 'native' module implementation. Basically you follow the conventions you see for namespaing you javascript code and wrapping functions with helpers like F2, F3 and so on, and return an object containing all the functions you want to expose to Elm. Also code does not need to be made asynchronous to be made type-safe, you could use Result for synchronous calls. Just map all exceptions to Err, and succesfull calls to Ok. It would be nice if we could just mark our own native modules as 'unsafe' and have an 'unsafe' section on package.elm-lang.org to share them. >From what I've read about it, there is a another aspect to this that the keyword 'unsafe' doesn't quite cover. Elm could also run in a different environment to browser + javascript. To take a hypothetical example, it could be ported for writing native Windows applications. In which case the native parts of the platform that are currently written in javascript might end up getting rewritten as say C#. Then the exact same Elm code could produce a web application or a native windows application. For Android it would be Java, you get the idea. So we'd need a keyword and understanding about lack of potential forward compatability that expresses this, were there to be a way to provide some degree of official recognition that people want to write and share native code. Perhaps its an 'unsafe javascript elm18 module' that we need... I like that Evan has had the foresight to prevent Elm being locked in to its current runtime environment in order to keep options open for the future. If I need to delve into hacking javascript to do something that I can't do otherwise, I'm happy enough with taking the risk of no forward compatability, because I'm using the version of Elm that I currently have, to solve problems that I currently need to solve, and finding that Elm is good enough to be worth making an exception for. As I say, there is always elm-github-install for the hackers. -- 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.
