Vlad GURDIGA
2017-09-09 14:49:31 UTC
Hey everybody! ð
The other day I found myself writing a function to format numbers
<https://github.com/gurdiga/xo.elm/commit/eac3cb6b92823b9876053c4034de92d307812503#diff-96f92701886b3e767cf8eef9ccf8d9ceR21>.
The first question was: What is the right way to format a number? There
should be a standard or something. ð€ Googled a bit and found about the
Unicode CLDR Project <http://cldr.unicode.org/>. They have a huge amount of
structured data, and I surely found the data I was looking for. ð€
Now, seeing all that data, I thought: Wow! Wouldnât it be cool to have an
Elm library thatâl hold all that? elm-cldr? ð© Oh, itâd be enormous⊠What
if I only need number formatting? Oh, I know: elm-cldr-numbers!
and elm-cldr-dates! and elm-cldr-localenames! and⊠Ooooh yeah!! ð€
Then I remember that the CLDR website was saying that they provide data for
apps and operating systems. Hm⊠shouldnât it be there already somewhere in
the OS? ð€ Googled a bit more and found that browsers already have that as
window.Intl
<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl> and
MDN says it has quite good support, down to IE11. Couldnât believe that
one, so spun up my Windows VM and pasted a snippet into IE11âs console: it
worked! ðœ
Hm⊠OK⊠Now, itâd really be quite cool to build all those elm-cldr-* things
that I imagined, wouldnât it make more sense to reuse whatâs already there?
What would it be like to use that? OK, letâs go native! A couple hours
later I got myself Native.Intl
<https://github.com/gurdiga/xo.elm/commit/26c5046e9942433cd8f663bd04c18f1ccb6838ee>.
ð
Now, looking at all this I begun wondering what would it be like to have it
in the Elm standard library, and inevitably found Evanâs 2 threads (one
<https://groups.google.com/forum/#!topic/elm-discuss/DPuUPv72abc> and two
<https://groups.google.com/forum/#!topic/elm-dev/1JW6wknkDIo>) about the
philosophy around native in Elm, and I kind of see his point about keeping
Elm high-quality, but how about cases like this where weâre not talking
about JS libraries but about browserâs native APIs like Intl? ð€
Itâd probably be not that hard to get that data
<https://github.com/unicode-cldr/cldr-json> packaged into a few Elm
libraries, hopefully not-that-large each, but itâd still end up growing the
final app bundles, and probably some compilation time during the hundreds
of refreshes a day that a dev doesâŠð³ So Iâm not entirely sure itâs a
constructive idea. ð¶
So although for my little toy-project I can just use Elm native, how about
long-term? What would make more sense? I mean these two options:
1. implement Elm libraries using the CLDR data
<https://github.com/unicode-cldr/cldr-json>
2. hope that window.Intl will some day become part of Elm standard
library
What are some pros and cons? Are there any other options people have
considered? ð€
The other day I found myself writing a function to format numbers
<https://github.com/gurdiga/xo.elm/commit/eac3cb6b92823b9876053c4034de92d307812503#diff-96f92701886b3e767cf8eef9ccf8d9ceR21>.
The first question was: What is the right way to format a number? There
should be a standard or something. ð€ Googled a bit and found about the
Unicode CLDR Project <http://cldr.unicode.org/>. They have a huge amount of
structured data, and I surely found the data I was looking for. ð€
Now, seeing all that data, I thought: Wow! Wouldnât it be cool to have an
Elm library thatâl hold all that? elm-cldr? ð© Oh, itâd be enormous⊠What
if I only need number formatting? Oh, I know: elm-cldr-numbers!
and elm-cldr-dates! and elm-cldr-localenames! and⊠Ooooh yeah!! ð€
Then I remember that the CLDR website was saying that they provide data for
apps and operating systems. Hm⊠shouldnât it be there already somewhere in
the OS? ð€ Googled a bit more and found that browsers already have that as
window.Intl
<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl> and
MDN says it has quite good support, down to IE11. Couldnât believe that
one, so spun up my Windows VM and pasted a snippet into IE11âs console: it
worked! ðœ
Hm⊠OK⊠Now, itâd really be quite cool to build all those elm-cldr-* things
that I imagined, wouldnât it make more sense to reuse whatâs already there?
What would it be like to use that? OK, letâs go native! A couple hours
later I got myself Native.Intl
<https://github.com/gurdiga/xo.elm/commit/26c5046e9942433cd8f663bd04c18f1ccb6838ee>.
ð
Now, looking at all this I begun wondering what would it be like to have it
in the Elm standard library, and inevitably found Evanâs 2 threads (one
<https://groups.google.com/forum/#!topic/elm-discuss/DPuUPv72abc> and two
<https://groups.google.com/forum/#!topic/elm-dev/1JW6wknkDIo>) about the
philosophy around native in Elm, and I kind of see his point about keeping
Elm high-quality, but how about cases like this where weâre not talking
about JS libraries but about browserâs native APIs like Intl? ð€
Itâd probably be not that hard to get that data
<https://github.com/unicode-cldr/cldr-json> packaged into a few Elm
libraries, hopefully not-that-large each, but itâd still end up growing the
final app bundles, and probably some compilation time during the hundreds
of refreshes a day that a dev doesâŠð³ So Iâm not entirely sure itâs a
constructive idea. ð¶
So although for my little toy-project I can just use Elm native, how about
long-term? What would make more sense? I mean these two options:
1. implement Elm libraries using the CLDR data
<https://github.com/unicode-cldr/cldr-json>
2. hope that window.Intl will some day become part of Elm standard
library
What are some pros and cons? Are there any other options people have
considered? ð€
--
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 elm-discuss+***@googlegroups.com.
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 elm-discuss+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.