• @V0ldek
    link
    English
    3313 days ago

    You also definitely shouldn’t be using String non-monotonic UUIDs for primary keys in a database, like, literally ever, but what the fuck do I know, I just do databases for a living, I’m not the all-knowing GPT code wizard.

    • flere-imsaho
      link
      English
      1512 days ago

      i’m not doing databases for living but the idea of stringifying a perfectly cromulent unique number in order to store it in the database comes as slightly weird to me.

    • deborah
      link
      English
      1213 days ago

      If you’re using a new-to-you ORM, and you don’t ever check the docs to see the basic primary key syntax… it’s SQLAchemy, it’s well documented and there’s tons of prior art.

      Also I don’t understand their business case but if a user has a primary key, a unique user ID, and a unique customer ID, then all three of those uniquely identify the customer. (Weird, but there are some plausible explanations.) But then why would you need both the user ID and the customer ID in the subscription table is this some stripe thing I don’t understand or are they just bad at this?

      • @froztbyte
        link
        English
        1313 days ago

        20 bucks the datastructure was designed for easiest access from the semantics of whatever du jour js lib they were using for the app

        • @froztbyte
          link
          English
          1213 days ago

          “designed”, rather

          Even “derived from” feels too strong a statement. “Was the result of”?

          • @blakestaceyA
            link
            English
            1112 days ago

            “Sediment precipitated from”?

        • Sailor Sega Saturn
          link
          English
          1112 days ago

          20 bucks their database schema was copy pasted from chat-gpt.

      • @gianni@lemmy.ca
        link
        fedilink
        English
        1012 days ago

        Yes, it’s some Stripe thing. Stripe requires you to create a customer to be able to vault payment methods and make charges. However it’s possible that not all users in their product require this functionality.

        • deborah
          link
          English
          812 days ago

          ah, thank you!

    • @Imacat@lemmy.dbzer0.com
      link
      fedilink
      English
      -313 days ago

      UUIDs make great primary keys in some applications. If you generated 100 trillion UUID4s, there’s about a 1 in a billion chance of finding a duplicate. Thats usually good enough for my databases.

      The issue here was that they used a single UUID instead of generating a new one for each record.

      • deborah
        link
        English
        1913 days ago

        There are countless issues here. They didn’t do exception handling, they used a string to store their UUIDs (even if this was a DB constraint, you use sqlalchemy.Uuid and let the ORM and DB handle the translation), and as the person you’re replying to stressed, they’re using non-monotonic UUIDs. Also if you have a unique user_id and you’re never exposing your primary keys, you don’t need to get fancy, just let the ORM handle it with auto-incrementing, for most use cases. And so many other tragic things about this one tiny blog post.

        tl;dr if you’re going to copy code you don’t understand, copy it from the docs, not from everything in the kitchen thrown into a blender.

      • flere-imsaho
        link
        English
        11
        edit-2
        12 days ago

        they also stored this thing as a fucking string. looking up strings is costly.

        • @froztbyte
          link
          English
          1312 days ago

          naw bro we’ve got indexes bro it’ll be fine bro

          • @froztbyte
            link
            English
            1012 days ago

            can’t wait for the Clever Idea to offload costly string indices to an external source composed of redis box and some shitfuck app doing tf-idf after a Extensive Research into how to make string lookups be faster

        • This sounds like a case of premature optimization to me. We have plenty of databases using strings as Ids and they’re all more than fast enough for any of our purposes. And that’s with considerable volume going through.

          I’ve never seen bad performance from string ids be an issue.

          • @sinedpick
            link
            English
            1412 days ago

            so we’re calling “not doing pointless unnecessary work” premature optimization now? cool cool

          • @ebu
            link
            English
            1112 days ago

            “what are you talking about? a hammer removes bolts just fine. i personally don’t have an issue with the tiny bit of extra elbow grease to wedge the claw around the bolt-head and twist; if anything, it’s saving me effort from having to use a wrench.”

          • @V0ldek
            link
            English
            712 days ago

            I’ve never seen bad performance from string ids be an issue.

            You haven’t seen shit then, simple as that.

          • flere-imsaho
            link
            English
            712 days ago

            why is it always programming dot dev?

      • @froztbyte
        link
        English
        1013 days ago

        You’re missing the entire point of the post you replied to

        • @Imacat@lemmy.dbzer0.com
          link
          fedilink
          English
          313 days ago

          I was reading it as an endorsement for autoincrementing int primary keys and a condemnation of uuids in general which is a genuine stance I’ve known people to take. Is that not it?

          • @froztbyte
            link
            English
            813 days ago

            indeed, that is not it

            hint: don’t try to “read in” any extra meanings. just read the actual statement that was posted.

            • @froztbyte
              link
              English
              713 days ago

              second hint: throw “monotonic UUIDs” into your search engine of choice

              • @Imacat@lemmy.dbzer0.com
                link
                fedilink
                English
                113 days ago

                Would they not have monotonic uuids after altering the code in the article to use a function or lambda as they suggested?

                • @ebu
                  link
                  English
                  5
                  edit-2
                  12 days ago

                  you might know what “monotonic” means if you had googled it, which would also give you the answer to your question

                  edit: this was far too harsh of a reply in retrospect, apologies. the question is answered below, but i’ll echo it: a “monotonic UUID” is one that numerically increases as new UUIDs are generated. this has an advantage when writing new UUIDs to indexed database columns, since most database index structures are more efficient when inserting at the end than at a random point (non-monotonic UUID’s).

          • JackbyDev
            link
            fedilink
            English
            1
            edit-2
            12 days ago

            Everything after this is so pointlessly condescending and confusing. Even if someone knows what monotonic ids are it doesn’t automatically mean they’re going to have any clue about what that means with regards to index performance. In the spirit of not being an asshole, I’ll write it out here based on my research since everyone else just seems interested in putting others down rather than being helpful.

            • “Monotonic” implies something that is always increasing (or decreasing). You’ll never get a result that’s lower than one you’ve gotten before (or higher if you’re dealing with monotonically decreasing stuff).
            • Random UUIDs are not monotonic because they’re random.
            • Even time based UUIDs are not monotonic because of the format. Rather than being store high, medium, low, they’re stored low, medium, high. Think of it like storing numbers like “1 20 300” for 321. 322 would be “2 20 300”. To make it worse, the end of them is “random” (a MAC address). So, not monotonic at all because MAC addresses can change. (See here for proposed new formats, where they mention this as a problem https://www.ietf.org/archive/id/draft-peabody-dispatch-new-uuid-format-04.html)
            • Monotonic primary keys are useful because they’re more easily inserted into an index because you’re always inserting into one specific part of the index rather.
            • @ebu
              link
              English
              10
              edit-2
              12 days ago

              putting my 2¢ forward: this is a forum for making fun of overconfident techbros. i work in tech, and it is maddening to watch a massively overvalued industry buy into yet another hype bubble, kept inflated by seemingly endless amounts of money from investors and VCs. and as a result it’s rather cathartic to watch (and sneer at) said industry’s golden goose shit itself to death over and over again due to entirely foreseeable consequences of the technology they’re blindly putting billions of dollars into. this isn’t r/programming, this is Mystery Science Theater 3000.

              i do not care if someone does or does not understand the nuances of database administration, schema design, indexing and performance, and different candidates for the types of primary keys. hell, i barely know just enough SQL to shoot myself in the foot, which is why i don’t try to write my own databases, in the hypothetical situation where i try to engineer a startup that “extracts web data at scale with multimodal codegen”, whatever that means.

              if someone doesn’t understand, and they come in expressing confusion or asking for clarification? that’s perfectly fine – hell, if anything, i’d welcome bringing people up to speed so they can join in the laughter.

              but do not come in here clueless and confidently (in)correct the people doing the sneering and expect to walk away without a couple rotten tomatoes chucked at you. if you want to do that, reddit and hacker news are thataway.

            • @slopjockey
              link
              English
              712 days ago

              Yeah, I’m all for dunking on promplets, but just being wrong about best practice isn’t a big deal. The reaction here is excessively harsh.

              • @selfA
                link
                English
                1012 days ago

                agreed. we’ve veered a bit too close to slashdot’s tone on this one.

                with that said, I’m also acutely aware of the tactics that programming.dev reply guys use to generate these kinds of responses. to our guests: it’s best to take your questions about database best practices literally anywhere else but here.

                • @froztbyte
                  link
                  English
                  611 days ago

                  with that said, I’m also acutely aware of the tactics that programming.dev reply guys

                  I wasn’t actually aware of this, and will be taking note of it in future. for my part I tried to make my reply “uhh go look at $x and learn” post without, y’know, overtly making things into a not-meant-for-here debate setup, but that didn’t seem to have worked out entirely well :)

              • @V0ldek
                link
                English
                912 days ago

                Just to be clear, if a person is wrong about best practices then it’s not a big deal.

                In context of spicy autocomplete as coding assistance, it better output immaculate, robust code every fucking time or we should be clowning on it with zero remorse.

                • @slopjockey
                  link
                  English
                  611 days ago

                  Wait a second…to err is to be human. Programmers err sometimes. ChatGPT shits itself all the time…😟. Yud et al. were right

            • @froztbyte
              link
              English
              612 days ago

              Read the sidebar. This is literally not the place.

              • JackbyDev
                link
                fedilink
                English
                -512 days ago

                The fuck is a side bar? My app doesn’t have that. Be more specific, please.

                • @blakestaceyA
                  link
                  English
                  1111 days ago

                  If your “app” cannot show basic information about the forum to which you are posting, your “app” is bad.

                • @selfA
                  link
                  English
                  1012 days ago

                  no, programming.dev, let’s fucking not

      • @Hexarei@programming.dev
        link
        fedilink
        English
        -1
        edit-2
        12 days ago

        They’re good for large, distributed applications for sure. Better than incrementing integers for those kinds of applications at the very least.

        For the folks in the article though? lol they were making no good decisions

        • deborah
          link
          English
          14
          edit-2
          12 days ago

          when you do not yet have (1) customers, (B) unit tests, (ג) developers who can write their own code, or (IV) exception handling, the term-of-art that comes to mind for doing anything besides auto-incrementing primary keys is YAGNI. (Especially because nobody who is making thoughtful, careful database tuning decisions is using chat-gippity to convert their models. And more to the point, they aren’t using SQLAlchemy of all things to make large, distributed applications that need UUID primary keys.)

          • @Hexarei@programming.dev
            link
            fedilink
            English
            0
            edit-2
            12 days ago

            Oh for sure, the article folks are inept and absolutely not the people I was talking about. I’m just talking about stuff more like Discord or Steam that are huge distributed systems that don’t use centralized databases.

            Edit: that don’t use centralized databases. I blame the ADHD.

            Edit 2: I am agreeing with this person

            • @ebu
              link
              English
              912 days ago

              I’m just talking about stuff more like Discord or Steam that are huge distributed systems that don’t use databases.

              huh???

              • @Hexarei@programming.dev
                link
                fedilink
                English
                812 days ago

                Whoops, I flubbed that message hard and didn’t catch it at the time: Meant to say “don’t use centralized databases.” They definitely use databases lmao. No idea how I screwed that message up so hard. I blame ADHD for not proofreading.

                Just so we’re on the same page, let me be more specific. I’m saying the individuals in the article were making terrible decisions. Lots of them.

                I am also saying that UUIDs are good primary keys for very specific purposes: Large, distributed systems that handle large amounts of small data, powered by databases like Cassandra that are designed to handle millions of record insertions per hour across several hundred nodes, to the point where inserts are very likely to happen at the exact same time on two different replicas of the same schema.

                Hope that makes more sense than my previous flub. lol

                • @ebu
                  link
                  English
                  5
                  edit-2
                  11 days ago

                  okay that’s a little more sensible lol

                  i think the original comment that this thread is in reply to is avoiding non-monotonic UUIDs. i don’t think anyone is contesting that autoincrementing ints create headaches when trying to distribute the database

              • @froztbyte
                link
                English
                512 days ago

                See, reason being is they use aethernet - that’s the only way you get to get scale it like this. Without that, communication and storage would just be impossible!

                • @Hexarei@programming.dev
                  link
                  fedilink
                  English
                  812 days ago

                  I accidentally a word in the original comment, it was supposed to say they don’t use *centralized databases. Instead it said I’m a moron lmao.

                • @froztbyte
                  link
                  English
                  612 days ago

                  And I just saw what that poster’s domain is, fuck me

  • @Architeuthis
    link
    English
    26
    edit-2
    12 days ago

    Honestly, the evident plethora of poor programming practices is the least notable thing about all this; using roided autocomplete to cut corners was never going to be a well calculated decision, it’s always the cherry on top of a shit-cake.

    • @ebu
      link
      English
      2212 days ago

      the upside: we can now watch “disruptive startups” go through the aquire funding -> slapdash development -> catastrophic failure -> postmortem cycle at breakneck speeds

    • @swlabr
      link
      English
      1211 days ago

      roided autocomplete

      My autocomplete:

      • written in an hour on a whiteboard for a job interview
      • uses only the finest words, hand-selected by unix
      • speed and size efficient

      Roided autocomplete:

      • years of development, billions of dollars of investment
      • hallucinates constantly
      • projected to use all computing capacity at current rates
  • @gerikson
    link
    English
    22
    edit-2
    13 days ago

    The original post was removed, hence the archive link.

    HN figures the real issue was the lack of testing/monitoring, not specifically the use of ChatGPT. But the kind of person who’s ok with letting spicy autocomplete write their customer acquisition code is probably not the kind of person knowing how to test and monitor.

    https://news.ycombinator.com/item?id=40627558

    • @fubarx@lemmy.ml
      link
      fedilink
      English
      1613 days ago

      I actually tried letting ChatGPT-4o write some tests the other day.

      Easily 50% of the tests were wrong. They ignored DB uniqueness constrains or even datatypes. In a few cases, they just hallucinated field names that didn’t exist.

      I ended up spending just as much time cleaning up the cruft as writing them. I could easily see someone just starting out letting the code go through.

    • Sailor Sega Saturn
      link
      English
      1412 days ago

      Commit messages are overrated.

      Now that’s the kind of bad hot take I read awful.systems for! Let’s all call ourselves “engineers” but write no documents but emoji laden jokes, and produce no work except for the copy-pasted excreta from a chatbot!

  • @froztbyte
    link
    English
    16
    edit-2
    13 days ago

    friend of mine happened to dm me this the other day, and here are my reactions from chat, verbatim (albeit timestamps removed)

    fucking sfba method, man
    so many things in that post, man, god
    linear extrapolation forlost sales”, doing the double presumption of both constant uptake and that everyone would definitely have been a customerwhatever youre thinking, double itbayfucker advice
    and just …. everything
    fucking hell
    

    and the code. fuck me the fucking code. it’s always “nice” to see just how very very clever all the yc fuckers are. but christ does it give me feelings.

    but they gotta go fast! if they’re barely approaching redshift, are they even agile?!

    • deborah
      link
      English
      1413 days ago

      It’s okay to copy/paste your basic model structure for SQLAlchemy classes, but copy and paste from the SQLAlchemy docs. Sweet suffering stack overflow, did nobody even look at the docs ever, or did they only trust ChatGPT? SQLAlchemy‘s simple for basic use cases.

      Also here is such a nutshell of everything wrong with YC: jackhole prompt fondlers with no tests, no paying customers, who turn on the most important new feature in prod at the end of the day (jesus wept), and yet with all that clown show,

      We had eight ECS tasks on AWS, all running five instances of our backend (overkill, yes we know, but to be fair we had AWS credits).

      What the actual fuck.

      • @froztbyte
        link
        English
        1113 days ago

        Oh yeah I entirely agree about copying - hell, lord knows how much interlang tools suck, I entirely get copycloning some defs best-match

        But yeah indeed they super fucked up :D

        With a nice cushy bit of “free” to make the problem go away. Whereas recently a fedi admin got their their instance turboscraped and were stressing about a sub-10k bill that would’ve probably killed their entirely service. My contempt for these bayfucker dickweeds knows no bound.

    • David GerardOPMA
      link
      English
      1212 days ago

      bayfucker advice

      perfect

  • @Soyweiser
    link
    English
    14
    edit-2
    13 days ago

    How did they not find this while testing?

    e: Regardless, I don’t regret the experience.

    eurgh

    • Sailor Sega Saturn
      link
      English
      20
      edit-2
      12 days ago

      Even with inadequate tests, inadequate monitoring, and an inadequate integration testing environment; how did it not go like this:

      “Hmm the web server appears to be working, but maybe the database is making an oopsie we did just do that whole stupid db migration without a gradual ramp up”

      “Oh hey here’s an idea, why don’t we make sure error messages from the database are logged maybe it’s silently crying out in pain right now :D”