You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@neumino I think that just because lowercase happens to be a frequently searched word doesn't necessarily make it a good choice it's obviously going to have a lot more people searching for it since it's an actual english word. toUpper and toLower are the ones that sound the most natural to me.
I'm cool with toUpper/toLower and upcase/downcase, but not toUpperCase/toUppercase/toLowerCase/toLowercase/upperCase/lowerCase. All of the latter examples seem really bad to me.
I wouldn't worry too much about people searching through the docs and not finding what they want because we can solve it pretty easily by just putting keywords into the description.
Since the discussion period is over, and there's no real consensus, I arbitrarily pick upcase, since two people liked it and it's the name used by one of our client languages. The corresponding command will be downcase.
For those watching this issue, it will almost certainly happen before RethinkDB 2.0, but not before 1.9 and possibly 1.10/1.9.1 is out. There is a bit of accumulated technical debt we have to pay back, and we're trying to push even small enhancements back until that done.
Sorry if this causes you pain, if it's really important to you, please let us know and we'll see if we can reprioritize.
Restarting this discussion, after sitting on this for a few months, I'm cool with upcase/downcase (and actually prefer it). We can use keywords lower/upper in the docs to make sure people find these commands, so I don't think search is actually a problem.
JSON uses UTF-8 because it's a format for storing and retrieving text. If that's all you're doing, there's no reason not to have Unicode support. We also support storing and retrieving Unicode text.
Committing to manipulating Unicode text correctly is entirely different.
There are three main reasons I don't want to do this:
Implementing upcase and downcasecorrectly is probably doable with a bit of work, but it will create the expectation that RethinkDB can do unicode-aware string manipulation, and I don't think that we want to promise that.
Unicode transformations are, in general, insane.
I don't believe that it's possible to upper-case a Unicode string without reference to a locale. The boost library you linked to takes a locale for its to_upper function, and produces different results in different locales. I don't think we want to make the result of ReQL operations depend on what locale you're in, for obvious reasons, and if we settle on an agnostic standard like the C locale, people will get unexpected results from upper-casing strings.
Doing "correct" Unicode transformations can cause extremely non-obvious things to happen. For example, in some locales, upper-casing a Unicode string with ICU can change its length. Not its visual length, but the actual number of code points.
The boost library you link to can either use ICU as the backend, or use a smaller non-ICU boost backend. (Note that case-manipulation on Unicode strings produces different results depending on which backend you're using, since the ICU backend will sometimes convert one code point to many or vice-versa while changing case and the pure-boost backend will not.) I don't think we want to package ICU with RethinkDB, but I also don't think we want to give people the custom non-ICU boost backend, which cursory googling suggests isn't very smart.
Most other languages don't do this. Ruby, for example, doesn't touch Unicode characters:
Actually, on the topic of locale-specific behaviors, if we have deterministic ReQL terms which behave differently in different locales (which I think we'd have to for Unicode upcase/downcase) then we'd have to ensure that all servers in a cluster reside in the same locale, since otherwise you could get data divergence between nodes if you do a locale-dependent atomic update.
Oh, that's cool then. (Note that we won't be able to link against different versions of ICU on different platforms unless we are 100% sure that they always produce the same output given the same input (see my previous comment about data divergence). I'm not sure how much of a wrench that throws into the packaging.)
Python 3.2.3 on Newton appears not to upper-case or lower-case Unicode characters either:
Well, the question is how much we want to commit to doing string manipulation at all.
If we want to commit to that, we should do it properly and support Unicode. Otherwise those operations would be completely crippled for most applications I can think of (everything that deals with text on the web is usually expected to work with Unicode for example).
upcase and downcase are basic enough that they can have some limited use cases, even when crippled like that (most of which I guess do not involve user-supplied data). But even comparing user-provided text in a case-insensitive way wouldn't work properly, except for the 5% of people in the world who use English as their first language and the few more who use primarily a language which uses the same alphabet. [1]
I guess I would be ok with having upcase and downcase not properly support Unicode, but we should very clearly explain that fact in the documentation.
Having a change of encoding length doesn't seem to be a problem in our case, is it? I don't think we are going to use these functions for in-place manipulation, are we?
Being dependent on a locale would indeed be annoying. On the other hand we already support locales for our time functions, so it wouldn't be such a huge step. I'm also not sure in how far using a default locale would make these functions less useful. As far as I know most web services run with a fixed locale for their string processing, and they don't seem to run into problems due to it (but I might just not be aware of the cases where they do).
[1] I know this is a bit biased. When dealing with computers, many more people use primarily English. However there's still a significant number of people for whom missing Unicode support would be an issue.
The former depends on the locale, the latter does not:
By contrast to strtolower(), 'alphabetic' is determined by the Unicode character properties. Thus the behaviour of this function is not affected by locale settings and it can convert any characters that have 'alphabetic' property, such as A-umlaut (Ä).
I don't know enough about Unicode to fully understand the implications here, but there seems to be a way of doing this in a locale-independent way.
Edit: Actually there is a comment on that page which gives an example of why locale matters:
Turkish is a good example of this. In Turkish, the letter I/i has a dotted-upper-case form (İ) and a dotless-lower-case form (ı).
This means that you cannot correctly convert between upper-case and lower-case without also knowing the locale of the data.
Since the function does not let you specify a locale, you should only use this function for text written in languages that follow the same orthography as English.
I definitely agree that we should try to keep RethinkDB's string manipulation to a minimum. If we ever decide to push further into the realm of string processing, we may want to take a second look at supporting Unicode text-manipulation.
This isn't to say that other languages aren't important -- they definitely are -- but it's not like we're adding a feature that will only work for 5% of people using the product.
Also, empirically, the fact that e.g. Ruby and Python don't seem to support Unicode case-manipulation out of the box doesn't seem to have hurt their adoption as web languages.
I don't really understand the locale issue as well as I'd like. I've spent about 20 minutes googling around, and I can't seem to find a straight answer as to how en_US.UTF-8 and de_DE.UTF-8 are treated differently by different libraries.
The boost library requires that a locale be passed to the to_upper function, and the documentation seems to suggest that it affects the output.
Maybe the normalization is different in different locales? (Many characters, like letters with accents over them, can be produced by multiple different sequences of code points, and most Unicode processing libraries consider these different sequences of code points to be equivalent. To make life easier, the Unicode text is usually normalized to a single canonical representation prior to processing.)
So yeah I guess I would be ok with this limited toupper/tolower, but it still feels like a bad compromise.
I think the behavior of PHP's mb_strtolower would be almost strictly preferable. It still has limitations, but it sets the bar a lot higher and isn't dependent on locale. If we could find a reasonable easy way of getting that behavior without huge additional libraries I think we should do that.
Also note that 55% of the web content being English doesn't mean that 55% of web services can get away with supporting only English. Many web services have to deal with multiple languages, even though most of their content might be English. That aside, I did of course exaggerate with the 5% and the truth is probably somewhere in between.
I would strongly prefer to keep internationalization of these functions out of the scope of this issue. (We should go back to the problem, though, but not within the scope of 1.12)
Activity
neumino commentedon May 22, 2013
I would rather name them upperCase and lowerCase.
I know that ruby use upcase and downcase, but here is a good reason to go for upperCase and lowerCase:
jdoliner commentedon Jun 11, 2013
@neumino I think that just because lowercase happens to be a frequently searched word doesn't necessarily make it a good choice it's obviously going to have a lot more people searching for it since it's an actual english word.
toUpperandtoLowerare the ones that sound the most natural to me.Also science:
http://www.google.com/trends/explore#q=upcase%2C%20toUpper&cmpt=q
mlucy commentedon Jun 11, 2013
On the other hand: http://docs.oracle.com/cd/B12037_01/olap.101/b10339/x_trap016.htm
coffeemug commentedon Jun 11, 2013
I'm cool with
toUpper/toLowerandupcase/downcase, but nottoUpperCase/toUppercase/toLowerCase/toLowercase/upperCase/lowerCase. All of the latter examples seem really bad to me.I wouldn't worry too much about people searching through the docs and not finding what they want because we can solve it pretty easily by just putting keywords into the description.
jdoliner commentedon Jun 11, 2013
What about
iDesireThatWhichIsMyFirstArgumentToBeUpperCasePlease?Edit: manners.
coffeemug commentedon Jun 11, 2013
I'm cool with that, but only as long as we change every other command we have to end with
Please. It's actually really nice:There's a lot to be said for a codebase with good manners.
coffeemug commentedon Jun 11, 2013
Or alternatively, to save typing, we could just change
runtorunPlease:Not much typing, and very polite. It's a win-win.
jdoliner commentedon Jun 11, 2013
I assume @neumino and @AtnNn are going to start the classic
runPleasevs.runSiVousPlaitdebate any second now.neumino commentedon Jun 11, 2013
I would be fine with both if
runPleasereturns some random results from time to time (but notrunSilVousPlait)mlucy commentedon Jun 21, 2013
Alright, here's the summary:
upcase-- mlucy, Slava, rubyupper-- pythonto_upper-- Joe, Slavato_upper_case-- JS, MichelSince the discussion period is over, and there's no real consensus, I arbitrarily pick
upcase, since two people liked it and it's the name used by one of our client languages. The corresponding command will bedowncase.coffeemug commentedon Aug 6, 2013
For those watching this issue, it will almost certainly happen before RethinkDB 2.0, but not before 1.9 and possibly 1.10/1.9.1 is out. There is a bit of accumulated technical debt we have to pay back, and we're trying to push even small enhancements back until that done.
Sorry if this causes you pain, if it's really important to you, please let us know and we'll see if we can reprioritize.
coffeemug commentedon Nov 25, 2013
Restarting this discussion, after sitting on this for a few months, I'm cool with
upcase/downcase(and actually prefer it). We can use keywordslower/upperin the docs to make sure people find these commands, so I don't think search is actually a problem.mlucy commentedon Nov 26, 2013
This is tagged as API_settled from last time we discussed it, so I concur.
upcase/downcaseit is.5 remaining items
danielmewes commentedon Dec 4, 2013
I strongly think that we should implement unicode-aware case-manipulation.
That is what people expect. Our data format is JSON. JSON uses Unicode.
There is support for it in Boost.
http://www.boost.org/doc/libs/1_49_0/libs/locale/doc/html/index.html
mlucy commentedon Dec 4, 2013
JSON uses UTF-8 because it's a format for storing and retrieving text. If that's all you're doing, there's no reason not to have Unicode support. We also support storing and retrieving Unicode text.
Committing to manipulating Unicode text correctly is entirely different.
There are three main reasons I don't want to do this:
upcaseanddowncasecorrectly is probably doable with a bit of work, but it will create the expectation that RethinkDB can do unicode-aware string manipulation, and I don't think that we want to promise that.to_upperfunction, and produces different results in different locales. I don't think we want to make the result of ReQL operations depend on what locale you're in, for obvious reasons, and if we settle on an agnostic standard like the C locale, people will get unexpected results from upper-casing strings.mlucy commentedon Dec 4, 2013
Actually, on the topic of locale-specific behaviors, if we have deterministic ReQL terms which behave differently in different locales (which I think we'd have to for Unicode upcase/downcase) then we'd have to ensure that all servers in a cluster reside in the same locale, since otherwise you could get data divergence between nodes if you do a locale-dependent atomic update.
AtnNn commentedon Dec 4, 2013
We already link to ICU transitively through v8 on certain platforms.
Most other languages were designed before Unicode became ubiquitous. See Python 3 and Go for better examples of Unicode support by default.
mlucy commentedon Dec 4, 2013
Oh, that's cool then. (Note that we won't be able to link against different versions of ICU on different platforms unless we are 100% sure that they always produce the same output given the same input (see my previous comment about data divergence). I'm not sure how much of a wrench that throws into the packaging.)
Python 3.2.3 on Newton appears not to upper-case or lower-case Unicode characters either:
I don't know enough Go to test easily, but I would give it even odds that it doesn't touch Unicode characters when upper/lower-casing either.
The other objections (setting expectations, locale-dependency, and unintuitive behavior) still stand.
danielmewes commentedon Dec 4, 2013
Well, the question is how much we want to commit to doing string manipulation at all.
If we want to commit to that, we should do it properly and support Unicode. Otherwise those operations would be completely crippled for most applications I can think of (everything that deals with text on the web is usually expected to work with Unicode for example).
upcaseanddowncaseare basic enough that they can have some limited use cases, even when crippled like that (most of which I guess do not involve user-supplied data). But even comparing user-provided text in a case-insensitive way wouldn't work properly, except for the 5% of people in the world who use English as their first language and the few more who use primarily a language which uses the same alphabet. [1]I guess I would be ok with having
upcaseanddowncasenot properly support Unicode, but we should very clearly explain that fact in the documentation.Having a change of encoding length doesn't seem to be a problem in our case, is it? I don't think we are going to use these functions for in-place manipulation, are we?
Being dependent on a locale would indeed be annoying. On the other hand we already support locales for our time functions, so it wouldn't be such a huge step. I'm also not sure in how far using a default locale would make these functions less useful. As far as I know most web services run with a fixed locale for their string processing, and they don't seem to run into problems due to it (but I might just not be aware of the cases where they do).
[1] I know this is a bit biased. When dealing with computers, many more people use primarily English. However there's still a significant number of people for whom missing Unicode support would be an issue.
danielmewes commentedon Dec 4, 2013
Something which might be interesting about locale-dependency:
In PHP, there are two functions.
strtolowerhttp://php.net/manual/en/function.strtolower.phpand
mb_strtolowerhttp://www.php.net/manual/en/function.mb-strtolower.php .The former depends on the locale, the latter does not:
I don't know enough about Unicode to fully understand the implications here, but there seems to be a way of doing this in a locale-independent way.
Edit: Actually there is a comment on that page which gives an example of why locale matters:
I guess this is kind of tricky.
mlucy commentedon Dec 4, 2013
I definitely agree that we should try to keep RethinkDB's string manipulation to a minimum. If we ever decide to push further into the realm of string processing, we may want to take a second look at supporting Unicode text-manipulation.
I think "crippled" is a little strong though. English is used by way more than 5% of the web (Wikipedia places it at 55% (http://en.wikipedia.org/wiki/Languages_used_on_the_Internet), and it doesn't seem to be going down very quickly (http://w3techs.com/technologies/history_overview/content_language/ms/y)). For the particular subset of the web that's likely to be RethinkDB customers, I think 55% is probably a large under-estimate.
This isn't to say that other languages aren't important -- they definitely are -- but it's not like we're adding a feature that will only work for 5% of people using the product.
Also, empirically, the fact that e.g. Ruby and Python don't seem to support Unicode case-manipulation out of the box doesn't seem to have hurt their adoption as web languages.
I don't really understand the locale issue as well as I'd like. I've spent about 20 minutes googling around, and I can't seem to find a straight answer as to how
en_US.UTF-8andde_DE.UTF-8are treated differently by different libraries.The boost library requires that a locale be passed to the
to_upperfunction, and the documentation seems to suggest that it affects the output.Maybe the normalization is different in different locales? (Many characters, like letters with accents over them, can be produced by multiple different sequences of code points, and most Unicode processing libraries consider these different sequences of code points to be equivalent. To make life easier, the Unicode text is usually normalized to a single canonical representation prior to processing.)
danielmewes commentedon Dec 4, 2013
So yeah I guess I would be ok with this limited toupper/tolower, but it still feels like a bad compromise.
I think the behavior of PHP's mb_strtolower would be almost strictly preferable. It still has limitations, but it sets the bar a lot higher and isn't dependent on locale. If we could find a reasonable easy way of getting that behavior without huge additional libraries I think we should do that.
Also note that 55% of the web content being English doesn't mean that 55% of web services can get away with supporting only English. Many web services have to deal with multiple languages, even though most of their content might be English. That aside, I did of course exaggerate with the 5% and the truth is probably somewhere in between.
AtnNn commentedon Dec 4, 2013
Following all this discussion, I believe that i18n is out of the scope of this issue.
@mlucy your python example uses bytestrings, not unicode strings. Go has the same behaviour as Python 3:
mlucy commentedon Dec 4, 2013
@AtnNn -- What's i18n?
(Also, it's pretty cool that Python 3 does that out of the box. I am legitimately surprised by that.)
AtnNn commentedon Dec 4, 2013
i18n is internationalisation
coffeemug commentedon Dec 4, 2013
I would strongly prefer to keep internationalization of these functions out of the scope of this issue. (We should go back to the problem, though, but not within the scope of 1.12)
mlucy commentedon Dec 6, 2013
This is in next, sans internationalization.