Witold, with all due respect, I am one of the people who has written
the _most_ Native code. I know a thing or two about it. You do not
need to lecture me, and my warning should be heeded.

Like I said, there are _some_ cases where a Native binding makes
sense. They are few and far between.  These problems are best
discussed on Slack, where we can drill down into the exact use case.
For example, is it only one currency format? If it is, re-writing in
Elm should be trivial.

On Sun, Apr 30, 2017 at 7:30 PM, Witold Szczerba <[email protected]> wrote:
> Noah, this is exactly the kind of problem to be solved by native binding.
> Dwayne wants to use his formatting library. This is a classic example of
> pure function. Nothing is going to crash if you wrap exception in Result and
> check types.
>
> Good advices of self reimplementig everything from scratch in Elm or using
> subscriptions for pure functions is nothing but making Elm people suffer
> instead of getting things done.
>
> Native bindings are not bad per se. Just use it wisely, be pragmatic or we
> will read another "Moving on", by Dwayne Crooks" this time.
>
> 30.04.2017 7:07 PM "Noah Hall" <[email protected]> napisał(a):
>>
>> Witold, this it not the advice that we give to people exploring such
>> problems in Elm. There are many reasons why Native bindings are bad. A
>> single error in your JS will cause the _entire_ application to crash
>> unrecoverably. Wrapping things as a result will not help you catch
>> those errors. Writing carefully thought out and tested code will.
>> While there are cases where a Native function helps out a lot, it
>> should _never_ be the first thing to reach for.
>>
>>
>> Dwayne, I suggest discussing things on the Elm Slack. It will be
>> easier to get to the exact use case you have for your formatting
>> issue.
>>
>>
>> On Sun, Apr 30, 2017 at 7:03 PM, Witold Szczerba <[email protected]>
>> wrote:
>> > Ports and subscriptions are for executing actions with effects, in my
>> > opinion. Native bindings for pure functions are nothing bad. Just keep
>> > away
>> > from exceptions, use Result in case of possible troubles.
>> >
>> > 30.04.2017 4:00 PM "Dwayne Crooks" <[email protected]> napisał(a):
>> >>
>> >> Thanks guys.
>> >>
>> >> I explored Noah's approach to see how the solution would turn out. But
>> >> I
>> >> didn't like it. The code change required to format a list of floats as
>> >> money
>> >> is ridiculous. Here's what I started with
>> >>
>> >> https://gist.github.com/dwayne/550341a5b27ba3c03ce7eba92d33873d#file-0-start-elm.
>> >> And here's what I ended up with
>> >>
>> >> https://gist.github.com/dwayne/550341a5b27ba3c03ce7eba92d33873d#file-1a-useports-elm,
>> >>
>> >> https://gist.github.com/dwayne/550341a5b27ba3c03ce7eba92d33873d#file-1b-useports-html.
>> >>
>> >> P.S. The solution still doesn't quite work because all money receives
>> >> the
>> >> first incoming subscription message causing them to display the same
>> >> formatted value. I didn't bother to fix it because the solution is bad
>> >> enough.
>> >>
>> >> I think we can safely rule out ports. Noah, do you have any thoughts on
>> >> the code? Did I miss anything?
>> >>
>> >> That leaves us with:
>> >>
>> >> Using a Native module. (Looks like the best compromise for my needs in
>> >> the
>> >> short-term.)
>> >> Rewrite in pure Elm. (Looks like the best long-term solution.)
>> >>
>> >> Next step: I will write up a Native solution and see how that goes.
>> >>
>> >> --
>> >> 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.
>> >
>> > --
>> > 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.
>>
>> --
>> 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.
>
> --
> 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.

-- 
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