unicode-org / icu4x

Solving i18n for client-side and resource-constrained environments.
https://icu4x.unicode.org
Other
1.38k stars 176 forks source link

Define traits for Unicode and ECMA 402 APIs #20

Open filmil opened 4 years ago

filmil commented 4 years ago

This issue a companion of: https://github.com/unicode-org/rust-discuss/issues/14.

How interested are we in general in having a common set of trait-specified API surfaces to program against? The idea is to allow multiple implementations, say omnicu (this work) and based on icu4c (like https://github.com/google/rust_icu). The theory is great, but practice is proving to be a bit more difficult than I thought.

Trying my hand at this I found that rust puts constraints on how the traits can look like, specifically since it is involved to return some useful forms of iterator.

Here's my attempt to work this out for https://github.com/zbraniecki/unic-locale/tree/master/unic-langid. For example, having a trait that returns an iterator trait (e.g. ExactSizeIterator) seems quite complicated because of the need to arrange the correct lifetimes of the iterator, the iterated-over-objects themselves, and the owner of the iterated-over objects. I got to this, but I'm not very happy about the outcome: https://github.com/unicode-org/rust-discuss/pull/19/files

FYI @zbraniecki

nciric commented 4 years ago

The core goal of OmnICU is to implement low level i18n algorithms, e.g. date formatting, collation, etc. Each client language will implement a wrapper, either around Rust low level library, or say Wasm export for JS/Dart.

We should see where those wrappers are located - are they part of OmnICU project, or are they separate repos/crates. A good example is your repo that wraps ICU4C - we can replace ICU4C parts over time with native Rust implementation without your users noticing.

@sffc

sffc commented 4 years ago

I think answering this question will be hard without more concrete examples of what OmnICU functional and ergonomic layers will actually look like. Let's revisit this question later in Q2 or in Q3.

sffc commented 4 years ago

I'm going to close this issue for now. I have it labeled with "backlog" to make it easy to find again and reopen when it is more appropriate.