Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-3170

Initialism code in the Go compiler causes chaos

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 0.9.2
    • Fix Version/s: 0.9.3
    • Component/s: Go - Compiler
    • Labels:
      None
    • Environment:

      Go/C++/Java

      Description

      The code introduced in THRIFT-3027 (now closed) created issues.

      1. It's inconsistent. Compare thrift name and Go names:

      type Foo struct {
              Id     int32 `thrift:"id,1" json:"id"`
              MyID   int32 `thrift:"my_id,2" json:"my_id"`
              NumCPU int32 `thrift:"num_cpu,3" json:"num_cpu"`
              NumGpu int32 `thrift:"num_gpu,4" json:"num_gpu"`
              My_ID  int32 `thrift:"my_ID,5" json:"my_ID"`
      }
      

      CPU vs Gpu, Id vs ID, ...

      2. It's one-way. This is a serious problem. Go code dealing with databases and other things assumes convertibility between snake_case and CamelCase in both directions for things like SQL column names. This breaks that.

      3. Generated code is explicitly NOT subject to this in the Go initialism guideline, for good reasons.

      "Code generated by the protocol buffer compiler is exempt from this rule. Human-written code is held to a higher standard than machine-written code."

      4. Working across Go/C++/Java, these inconsistencies are really messing with engineers that aren't as familiar with Thrift internals, which will inevitably lead to mistakes, so it's a usability issue.

      My recommendation: Strongly suggest removing the initialism rewriting code, those wanting initials in caps can still specify them in the thrift definitions without any problems in Go (but then Java has problems). If not make it a command line option usable by those working only in Go without other dependencies, but that still leaves problems 1 & 3.

      I can quickly prepare a patch to remove or flag-ify, but would like discussion.

        Attachments

          Issue Links

          There are no Sub-Tasks for this issue.

            Activity

              People

              • Assignee:
                magrath Paul Magrath
                Reporter:
                beberg Adam Beberg
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 0.5h
                  0.5h
                  Remaining:
                  Remaining Estimate - 0.5h
                  0.5h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified