Skip to content

Rename __reql_type__ to $__reql_type__ in all current proposals #1149

Closed

Description

@mlucy

Etienne and Bill mentioned to me that a prefix $ is considered something of a standard for magic values in JSON land.

@jdoliner, @coffeemug -- any objections?

(I realize I'm breaking our timeboxing rules, but this seems like an incredibly easy fix that it would be really really good to get right the first time.)

Activity

  1. ghost assigned on Jul 9, 2013
  2. coffeemug commented on Jul 9, 2013

    @coffeemug
    Contributor

    No objections. It's ugly, but if that's what others use, we should too. One caveat is that if people use dollar sign for magic values $reql_type might be better than $__reql_type__. Let's just follow whichever conventions already exist as closely as we can.

  3. mlucy commented on Jul 9, 2013

    @mlucy
    MemberAuthor

    I sort of prefer $__reql_type__ because it seems an order of magnitude less likely to cause a conflict, and because frankly magic strings should be ugly sometimes. I could plausibly imagine myself typing $reql_type in a normal ruby program because global variables start with $; I can't imagine myself typing $__reql_type__ in a normal ruby program.

  4. coffeemug commented on Jul 9, 2013

    @coffeemug
    Contributor

    Ok. I don't feel strongly about this.

  5. jdoliner commented on Jul 9, 2013

    @jdoliner
    Contributor

    Eh, I feel like if $ is the standard then we should use only that (i.e. $reql_type) and if we're not satisfied that it's sufficiently resistant to collisions then we should use something else. Combining 2 standards just seems weird and like it's not going to feel familiar to people who know either standard.

  6. mlucy commented on Jul 10, 2013

    @mlucy
    MemberAuthor

    I don't quite follow; $__reql_type__ isn't a violation of the standard "special JSON keys start with a $", it's a key that follows that standard and is extra resistant to collisions.

  7. jdoliner commented on Jul 10, 2013

    @jdoliner
    Contributor

    It might not be a violation of the standard but it still looks odd because it's clearly inspired by python's treatment of magic values and json's treatment of magic values. I can't actually find an example of anyone using this standard (although it's pretty hard to google) but I'm betting they don't normally add underscores as well as the $ sign.

  8. coffeemug commented on Jul 10, 2013

    @coffeemug
    Contributor

    This is a bike we all want to shed :)

  9. mlucy commented on Jul 10, 2013

    @mlucy
    MemberAuthor

    My preferences, in order:

    1. $__reql_type__ (kinda ugly)
    2. __reql_type__ (supposedly not in line with an informal standard)
    3. $reql_type (in line with the standard but also something I could plausibly type)
  10. coffeemug commented on Jul 10, 2013

    @coffeemug
    Contributor

    I really think $__reql_type__ is cool. It's obviously ugly, but I really don't think it matters. Most users will never ever see this anyway.

  11. jdoliner commented on Jul 10, 2013

    @jdoliner
    Contributor

    @coffeemug Users are actually going to see this value pretty quickly I think. Neither javascript nor Ruby has a native duration type so all it's going to take is someone writing a query like:

    r.table("users").map{|x| x.merge({:membership_duration => DateTime.now() - x[:date_joined]})}

    and they're going to be getting back raw psuedo types. I feel like $__reql_type__ is just needlessly ugly and something users will being seeing fairly frequently (and something driver developers will be typing fairly frequently). My preferences would be:

    1. __reql_type__ (very readable, and I've really yet to see evidence that this is an actual standard)
    2. $reql_type (also fairly readable, perhaps collision prone)
    3. $__reql_type__ (needlessly ugly)

    Also I'm increasingly dubious that this is in anyway a standard, the number one hit on google for "dollar magic values JSON" is this issue and I can't find a single other mention of it. Also google has a JSON style guideline which makes no mention of this.

  12. neumino commented on Jul 10, 2013

    @neumino
    Member

    1 is better than 3 which is better than 2 from my point of view. Both 1 and 3 are fine. I'm just not a big fan of 2 since it means "global variable" for me.

    Anyway, since I'm not working on the internals of ReQL, I don't have a strong opinion on that.

  13. wmrowan commented on Jul 10, 2013

    @wmrowan
    Contributor

    @coffeemug Users are actually going to see this value pretty quickly I think. Neither javascript nor Ruby has a native duration type

    This is why, however we choose to represent such types on the server, I would prefer to add a datum type to the protobuf spec than simply return the object with the obfuscated field. This way the driver implementer is forced to choose a representation that makes sense for that language. For languages that support native date types this would mean converting to and from the native date type without having to scan every object for a special key.

    For languages that don't have a native type, the driver implementor will be forced to choose a representation. I can almost guarantee that few would choose to return an object (or dict, or hash, or map) with a special key that the user then has to deal with. Most likely, the driver would create a custom class or type to represent the ReQL date and duration types. However we handle it internally, we should nudge them towards this solution. Getting this to happen is way more important for user experience than the choice between __reql_type__, $reql_type, and $__reql_type__.

  14. coffeemug commented on Jul 10, 2013

    @coffeemug
    Contributor

    @coffeemug Users are actually going to see this value pretty quickly I think.

    I think that for things like duration we might want to convert the reql object to raw numbers on the driver side. It will lose the property that we can put it back in and get the same type, but I think it's way friendlier than the alternative.

    In any case, I don't have a strong opinion on this. Whatever we choose is fine by me.

  15. srh commented on Jul 10, 2013

    @srh
    Contributor

    We generally are too paranoid about conflicts. For some history of this kind of decision, see the browser-prefixes fiasco in CSS, see the X- prefix fiasco in headers. Going with $type or __type__ should be fine.

  16. 13 remaining items

  17. jdoliner commented on Jul 13, 2013

    @jdoliner
    Contributor

    I'm fine with $reql_type$

  18. srh commented on Jul 13, 2013

    @srh
    Contributor

    I don't get what's so worrisome about $reql_type.

  19. srh commented on Jul 13, 2013

    @srh
    Contributor

    In particular: Is anybody using $reql_type right now? (No.) Is anybody going to start using it once we lay claim to it? (No.)

  20. srh commented on Jul 13, 2013

    @srh
    Contributor

    Also (sorry for the stream of consciousness thing going here), to use $__reql_type__ or $reql_type$ means we're actually planning for a world where both $reql_type and $reql_type$ exist and are used and have different, incompatible meanings. We are actually trying to facilitate this future timeline.

  21. mlucy commented on Jul 14, 2013

    @mlucy
    MemberAuthor

    But, by choosing $reql_type we'd be facilitating a world where both $reql_type and $ql_type exist but have different meanings. By induction, we should clearly use the empty string for our magic constant name.

  22. srh commented on Jul 14, 2013

    @srh
    Contributor

    Why would it be a problem for $reql_type and $ql_type to have different meanings?

  23. mlucy commented on Jul 14, 2013

    @mlucy
    MemberAuthor

    Well, $reql_type and $rql_type, then. Or $reql_type and reql_type. Or $reql_type and $reql_typ.

  24. srh commented on Jul 14, 2013

    @srh
    Contributor

    There are good reasons (that I'd think would be obvious) why we'd use the field name $reql_type and not $rql_type, $reql_typ, or reql_type. Two are misspellings and one is missing the dollar sign prefix. There isn't a good reason to use $reql_type$ and not $reql_type.

  25. mlucy commented on Jul 15, 2013

    @mlucy
    MemberAuthor

    It was just a joke meant to demonstrate the problem with saying "well, if we pick this name, we'd be implicitly endorsing people using a shorter name for their own purposes" -- namely, that the new shorter name would, by that same logic, be endorsing an even shorter name.

  26. srh commented on Jul 15, 2013

    @srh
    Contributor

    Well then, clearly you're a cryptoendorser of ~.Xx__^-^__$reql_type$__^-^__xX.~.

  27. mlucy commented on Jul 15, 2013

    @mlucy
    MemberAuthor

    That doesn't start with a $.

  28. mlucy commented on Jul 15, 2013

    @mlucy
    MemberAuthor

    Although, this is a possibly-once-in-a-lifetime opportunity to work ^.^ into a magic constant that other people might have to type one day.

  29. mlucy commented on Jul 17, 2013

    @mlucy
    MemberAuthor

    Alright, I'm calling this in the interests of shipping this thing before the sun burns down to cold, dead cinder.

    Let's go with $reql_type$. We will claim the right to all keys of the form ^\$reql_.+\$$.

  30. mlucy commented on Jul 17, 2013

    @mlucy
    MemberAuthor

    @jdoliner, could you update the dates code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions