Meme transcription:

Panel 1: Bilbo Baggins ponders, “After all… why should I care about the difference between int and String?

Panel 2: Bilbo Baggins is revealed to be an API developer. He continues, “JSON is always String, anyways…”

  • xthexder@l.sw0.com
    link
    fedilink
    arrow-up
    7
    ·
    edit-2
    4 months ago

    Well, you’re right. I wasn’t getting it, but I’ve also never seen any piece of software that would treat a single leading zero as octal. That’s just a recipe for disaster, and it should use 0o116 to be unambiguous

    (I am a software engineer, but was assuming you meant it was hardcoded to parse as octal, not some weird auto-detect)

      • xthexder@l.sw0.com
        link
        fedilink
        arrow-up
        5
        ·
        edit-2
        4 months ago

        Interesting that strtol in C does that. I’ve always explicitly passed in base 10 or 16, but I didn’t know it would auto-detect if you passed 0. TIL.

    • Doc Avid Mornington@midwest.social
      link
      fedilink
      English
      arrow-up
      0
      ·
      4 months ago

      It’s been a long time, but I’m pretty sure C treats a leading zero as octal in source code. PHP and Node definitely do. Yes, it’s a bad convention. It’s much worse if that’s being done by a runtime function that parses user input, though. I’m pretty sure I’ve seen that somewhere in the past, but no idea where. Doesn’t seem likely to be common.