kuuhana
  • Communities
  • Multi-communities
  • Support Lemmy
  • Search
  • Login
  • Sign Up
Programming@programming.devbycodeinabox@programming.dev
4 months

Ship types, not docs

shiptypes.com English

cross-posted from: https://lemmy.bestiver.se/post/919071

Comments

10
    Types are the contract between services, docs are not
    You must log in or register to comment.

    • CombatWombatEsq@lemmy.worlddeleted by creator
      4 months

      deleted by creator

        • FizzyOrange@programming.dev
          4 months

          This has been the norm for literally decades. Doxygen was doing it in 1997 and I’m sure it wasn’t the first.

        • jonathan7luke@lemmy.zip
          4 months

          AI agents are becoming your biggest API consumers, and they can’t always DM other teams. If you want to be productive with AI, if you want your codebase to be a place where agents can actually work, you need to think of your codebase as an application that the agent is interacting with.

          So what you’re saying is: mis-type everything! 👉😉👉

            • KickMeElmo@sopuli.xyz
              4 months

              Yeaaaah, they may be the biggest consumers, but they’re not users and they’re not terribly useful to users. I’m not changing everything around to make some LLM spit out more easily believed misinformation.

            • ell1e@leminal.spaceEnglish
              4 months

              Seems like a solution would be 1. update docs and 2. don’t use LLMs to code.

              • FizzyOrange@programming.dev
                4 months

                Uhm, ship both. Most type systems are not expressive enough to 100% explain the correct use of an API.

                • codeinabox@programming.devEnglish
                  4 months

                  Regardless of what the author says about AI, they are bang on with this point:

                  You have the truth (your code), and then you have a human-written description of that truth (your docs). Every time you update the code, someone has to remember to update the description. They won’t. Not because they’re lazy, but because they’re shipping features, fixing bugs, responding to incidents. Documentation updates don’t page anyone at 3am.

                  A previous project I worked on we had a manually maintained Swagger document, which was the source of truth for the API, and kept in sync with the code. However no one kept it in sync, except for when I reminded them to do so.

                  Based on that and other past experiences, I think it’s easier for the code to be the source of truth, and use that to generate your API documentation.

                    • tavernusmaximus@piefed.socialEnglish
                      4 months

                      Every time you update the code, someone has to remember to update the description. They won’t.

                      I get there are some exceptions where devs don’t have access to the docs, but I read this more like “Every time I update the code, I have to remember to update the description. I won’t.” Which, fair, but that’s the author’s problem. Writing docs is part of the job, table stakes stuff.

                      • MagicShel@lemmy.zipEnglish
                        4 months

                        You can also use the OpenAPI generator to turn a well-formed Swagger document into code. I’ve used it before. I didn’t hate it.

                        The generated controllers have a lot of boilerplate (I want to say 5 classes per controller), but it does guarantee the code is in sync with the documentation.

                        That being said, fuck manually maintaining swagger documents. It’s the worst of all possible works.

                        • bobo@lemmy.ml
                          4 months

                          I mostly agree with your statement and I’m just nitpicking, but that document is not a source of truth if it has to be updated after the fact, it’s a reference.

                          • ell1e@leminal.spaceEnglish
                            4 months

                            There are solutions to this like having a doc comment right next to the function which is picked up by some API generator. Then it’s easier to keep in sync. That can work well even in languages without explicit parameter types.

                            Of course it won’t help LLMs as much, but I personally don’t mind that.

                          Programming@programming.dev

                          programming@programming.dev

                          Subscribe from remote instance

                          Create post

                          Report community

                          Modlog
                          You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !programming@programming.dev

                          Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

                          Cross posting is strongly encouraged in the instance. If you feel your post or another person’s post makes sense in another community cross post into it.

                          Hope you enjoy the instance!

                          Rules

                          Rules

                          • Follow the programming.dev instance rules
                          • Keep content related to programming in some way
                          • If you’re posting long videos try to add in some form of tldr for those who don’t want to watch videos

                          Wormhole

                          Follow the wormhole through a path of communities !webdev@programming.dev



                          Visibility: Public

                          This community is visible to everyone.

                          • 3 users / Day
                          • 189 users / Week
                          • 192 users / Month
                          • 7K users / 6 months
                          • 3.16K posts
                          • 46.1K comments
                          • 1 local subscriber
                          • 27.4K subscribers
                          • UI: 1.0.0-beta.0
                          • BE: 1.0.0-alpha.20
                          • Modlog
                          • Instances
                          • Docs
                          • Code
                          • join-lemmy.org