[ 
https://issues.apache.org/jira/browse/THRIFT-2429?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13963438#comment-13963438
 ] 

Jens Geyer commented on THRIFT-2429:
------------------------------------

Hi all,
some more cents from me, quoting Ben's posts below.

{quote}
For this to work properly, both reader and writer of the data in question must 
have the same understanding of the default value. This is hugely problematic! 
If the goal is to save bits in the wire -protocol-, it would be more reasonable 
to ask the bit-saving programmer to handle this themselves and write custom 
code. As-is, we're adding a gotcha for (IMO) questionable benefit. 
{quote}
{quote}
it is unsafe to change the default value in the future; it becomes as essential 
to the field as its tag number.
{quote}

That's the exact feeling I have vis-รก-vis defaults. Could not have expressed it 
any better. As I pointed out in my post above, my biggest concern is whether 
typical IDL developers are aware of the fact, that changing the defaults may 
become a compatibility problem. Randy correctly replied that the child is in 
the well already, at least to some extent. 

{quote}
My extreme proposal would be to remove default values entirely... 
{quote}

I have to admin that I had similar thoughts, asking myself whether or not the 
decision to allow for defaults was such a great idea. On the other hand, if we 
do the only sane thing ...

{quote}
short of that, though, the only sane thing to do is to send them over the wire.
{quote}

then it seems much less problematic, as the default is applied purely on the 
senders side and the wire format has nothing to do with it, thus next to none 
opportunities for any incompatibilities due to changed defaults.

{quote}
I essentially never use `required` (when I was at google there was even a 
movement to ban `required`, as so many critical protocols had to swallow bitter 
pills when they realized required things weren't actually required after one 
migration or another), "opting" (pun!) for `optional` since it's harder to 
paint yourself into a corner with it. (...) For my own projects, I just won't 
use default values.
{quote}

Although I use {{required}} frequently, I'm usually very careful with it and 
think at least twice, before I do it. You just don't know what you don't know, 
and the problem with predictions is that they relate to the future. I never use 
default values in my IDLs either. But of course, the fact that I don't use it 
does not imply that it is a feature that nobody should use. If it works for 
you, that's perfectly ok.

*Bottom line* (for me): Having a well-defined, robust behaviour will certainly 
be a good thing. I appreciate the efforts you guys spend on this task and I 
will support it as much as I can. 

> Provide option to not write default values, rely on receiver default 
> construction instead
> -----------------------------------------------------------------------------------------
>
>                 Key: THRIFT-2429
>                 URL: https://issues.apache.org/jira/browse/THRIFT-2429
>             Project: Thrift
>          Issue Type: Improvement
>          Components: C++ - Compiler
>    Affects Versions: 0.9.1
>            Reporter: Chris Stylianou
>            Assignee: Randy Abernethy
>              Labels: default, optional, required
>
> Would there be any objections to a patch that does not write default values 
> (essentially the same logic as the optional attributes). This obviously 
> relies on the receiving application using the same IDL version to ensure the 
> defaults used on object construction match the senders.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to